Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

[api] Added cap for amount of local records which can be stored.

  • Loading branch information...
commit 9e5254663da051754c1a21fb52444e0c577c08a4 1 parent 52ca8fc
Marak Marak authored
Showing with 10 additions and 0 deletions.
  1. +10 −0 lib/hnet.js
10 lib/hnet.js
View
@@ -34,6 +34,9 @@ var Hnet = exports.Hnet = function (options) {
// Default to not resolviing circular data sets
self.ttl = options.ttl || -1;
+ // Default amount of items we will allow to be stored in self.store
+ // TODO: size limit should be based on array size as bytes, not array size as elements.
+ self.MAXRECORDS = 100;
//
// TODO: upgrade EE2 to version that has "**"
@@ -148,6 +151,13 @@ Hnet.prototype.parseDocument = function (node, doc, options) {
});
}
doc.forEach(function(record){
+ //
+ // Determine if we've reached the capped size, if so, shift off some records,
+ // we dont need them
+ //
+ if(self.store.length >= self.MAXRECORDS) {
+ self.store.shift();
+ }
self.store.push(record);
});
}
Please sign in to comment.
Something went wrong with that request. Please try again.