Comparing version 0.0.1 to 0.0.3
@@ -53,3 +53,3 @@ /** | ||
/** | ||
* remove an item from the cach | ||
* remove an item from the cache | ||
*/ | ||
@@ -61,2 +61,12 @@ BasicCache.prototype.remove = function(key) { | ||
/** | ||
* clear all items from the cache | ||
*/ | ||
BasicCache.prototype.clear = function() { | ||
for (var key in this.cache) { | ||
if (!this.cache.hasOwnProperty(key)) continue; | ||
delete this.cache[key]; | ||
} | ||
}; | ||
/** | ||
* internal debug function | ||
@@ -63,0 +73,0 @@ */ |
@@ -1,1 +0,1 @@ | ||
function BasicCache(e){this.opts=e||{},this.cache={}}"undefined"!=typeof exports&&(module.exports=BasicCache),BasicCache.prototype.get=function(e){var c=Date.now();return void 0===this.cache[e]?(this.debug('failed to pull "'+e+'" from cache'),void 0):c>this.cache[e].invalid?(this.debug('key "'+e+'" expired at: '+this.cache[e].invalid),delete this.cache[e],void 0):(this.debug('key "'+e+'" pulled from cache'),this.cache[e].value)},BasicCache.prototype.set=function(e,c,t){var i=Date.now()+(t||3e5);return this.cache[e]={},this.cache[e].value=c,this.cache[e].invalid=i,this.cache[e].invalid},BasicCache.prototype.remove=function(e){delete this.cache[e]},BasicCache.prototype.debug=function(){this.opts.debug&&console.log.apply(console,arguments)}; | ||
function BasicCache(e){this.opts=e||{},this.cache={}}"undefined"!=typeof exports&&(module.exports=BasicCache),BasicCache.prototype.get=function(e){var c=Date.now();return void 0===this.cache[e]?(this.debug('failed to pull "'+e+'" from cache'),void 0):c>this.cache[e].invalid?(this.debug('key "'+e+'" expired at: '+this.cache[e].invalid),delete this.cache[e],void 0):(this.debug('key "'+e+'" pulled from cache'),this.cache[e].value)},BasicCache.prototype.set=function(e,c,t){var a=Date.now()+(t||3e5);return this.cache[e]={},this.cache[e].value=c,this.cache[e].invalid=a,this.cache[e].invalid},BasicCache.prototype.remove=function(e){delete this.cache[e]},BasicCache.prototype.clear=function(){for(var e in this.cache)this.cache.hasOwnProperty(e)&&delete this.cache[e]},BasicCache.prototype.debug=function(){this.opts.debug&&console.log.apply(console,arguments)}; |
{ | ||
"name": "basiccache", | ||
"description": "An extremely basic cache with a simple expiry system", | ||
"version": "0.0.1", | ||
"version": "0.0.3", | ||
"author": "Dave Eddy <dave@daveeddy.com> (http://www.daveeddy.com)", | ||
@@ -6,0 +6,0 @@ "main": "./basiccache.js", |
@@ -72,2 +72,6 @@ basiccache.js | ||
### cache.clear() | ||
remove all entries from the cache | ||
License | ||
@@ -74,0 +78,0 @@ ------- |
6428
9
124
80