node-cache
Advanced tools
Comparing version 1.0.0 to 1.0.2
{ | ||
"name": "node-cache", | ||
"description": "Simple and fast NodeJS internal caching. Node internal in memory cache", | ||
"keywords": [ "cache", "caching", "local", "variable", "coffee", "coffee-script", "underscore", "multi", "memory", "internal", "node"], | ||
"tags": [ "cache", "caching", "local", "variable", "coffee", "coffee-script", "underscore", "multi", "memory", "internal", "node" ], | ||
"version": "1.0.0", | ||
"description": "Simple and fast NodeJS internal caching. Node internal in memory cache like memcached.", | ||
"keywords": [ "cache", "caching", "local", "variable", "multi", "memory", "internal", "node", "memcached", "object" ], | ||
"tags": [ "cache", "caching", "local", "variable", "multi", "memory", "internal", "node", "memcached", "object" ], | ||
"version": "1.0.2", | ||
"author": "tcs-de <github@tcs.de>", | ||
@@ -8,0 +8,0 @@ "main": "./index.js", |
@@ -8,5 +8,4 @@ node-cache | ||
[![NPM](https://nodei.co/npm/node-cache.png?downloads=true&downloadRank=true&stars=true)](https://nodei.co/npm/node-cache/) | ||
[![NPM](https://nodei.co/npm/node-cache.png?downloads=true&stars=true)](https://nodei.co/npm/node-cache/) | ||
# Simple and fast NodeJS internal caching. | ||
@@ -66,3 +65,3 @@ | ||
**Since `1.0.0`**: | ||
Callback is now optional. Yo Can also use a sync syntax. | ||
Callback is now optional. You can also use synchronous syntax. | ||
@@ -95,3 +94,3 @@ ```js | ||
**Since `1.0.0`**: | ||
Callback is now optional. Yo Can also use a sync syntax. | ||
Callback is now optional. You can also use synchronous syntax. | ||
@@ -127,3 +126,3 @@ ```js | ||
**Since `1.0.0`**: | ||
Callback is now optional. Yo Can also use a sync syntax. | ||
Callback is now optional. You can also use synchronous syntax. | ||
@@ -156,3 +155,3 @@ ```js | ||
**Since `1.0.0`**: | ||
Callback is now optional. Yo Can also use a sync syntax. | ||
Callback is now optional. You can also use synchronous syntax. | ||
@@ -180,3 +179,3 @@ ```js | ||
**Since `1.0.0`**: | ||
Callback is now optional. Yo Can also use a sync syntax. | ||
Callback is now optional. You can also use synchronous syntax. | ||
@@ -220,3 +219,3 @@ ```js | ||
**Since `1.0.0`**: | ||
Callback is now optional. Yo Can also use a sync syntax. | ||
Callback is now optional. You can also use synchronous syntax. | ||
@@ -315,2 +314,4 @@ ```js | ||
|:--:|:--:|:--| | ||
|v1.0.2|2014-09-17|Small change for better ttl handling| | ||
|v1.0.1|2014-05-22|Readme typos. Thanks to [mjschranz](https://github.com/mjschranz)| | ||
|v1.0.0|2014-04-09|Made `callback`s optional. So it's now possible to use a syncron syntax. The old syntax should also work well. Push : Bugfix for the value `0`| | ||
@@ -317,0 +318,0 @@ |v0.4.1|2013-10-02|Added the value to `expired` event| |
// Generated by CoffeeScript 1.6.3 | ||
(function() { | ||
var VCache, ks, localCache, localCacheTTL, randomString, vs, _; | ||
var VCache, ks, localCache, localCacheTTL, randomString, vs, _, | ||
__indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; }; | ||
@@ -357,3 +358,3 @@ _ = require("underscore"); | ||
"ttl": function(beforeExit, assert) { | ||
var key, key2, key3, key4, key5, n, val; | ||
var key, key2, key3, key4, key5, n, val, _keys; | ||
console.log("\nSTART TTL TEST"); | ||
@@ -366,2 +367,3 @@ val = randomString(20); | ||
key5 = randomString(7); | ||
_keys = [key, key2, key3, key4, key5]; | ||
n = 0; | ||
@@ -379,3 +381,3 @@ localCache.set(key, val, 0.5, function(err, res) { | ||
}); | ||
localCache.set(key2, val, 0.4, function(err, res) { | ||
localCache.set(key2, val, 0.3, function(err, res) { | ||
assert.isNull(err, err); | ||
@@ -418,32 +420,36 @@ assert.ok(res); | ||
}); | ||
}, 300); | ||
}, 250); | ||
setTimeout(function() { | ||
var startKeys, _testExpired, _testSet, | ||
_this = this; | ||
startKeys = localCache.getStats().keys; | ||
key = "autotest"; | ||
_testExpired = function(_key, _val) { | ||
assert.equal(_key, key); | ||
assert.equal(_val, val); | ||
}; | ||
_testSet = function(_key) { | ||
assert.equal(_key, key); | ||
}; | ||
localCache.once("set", _testSet); | ||
return localCache.set(key, val, 0.5, function(err, res) { | ||
assert.isNull(err, err); | ||
assert.ok(res); | ||
assert.equal(startKeys + 1, localCache.getStats().keys); | ||
return localCache.get(key, function(err, res) { | ||
var pred; | ||
pred = {}; | ||
pred[key] = val; | ||
assert.eql(pred, res); | ||
localCache.on("expired", _testExpired); | ||
return setTimeout(function() { | ||
localCache._checkData(false); | ||
assert.isUndefined(localCache.data[key]); | ||
localCache.removeAllListeners("set"); | ||
return localCache.removeAllListeners("expired"); | ||
}, 700); | ||
return process.nextTick(function() { | ||
var startKeys, _testExpired, _testSet, | ||
_this = this; | ||
startKeys = localCache.getStats().keys; | ||
key = "autotest"; | ||
_testExpired = function(_key, _val) { | ||
if (__indexOf.call(_keys, _key) < 0) { | ||
assert.equal(_key, key); | ||
assert.equal(_val, val); | ||
} | ||
}; | ||
_testSet = function(_key) { | ||
assert.equal(_key, key); | ||
}; | ||
localCache.once("set", _testSet); | ||
return localCache.set(key, val, 0.5, function(err, res) { | ||
assert.isNull(err, err); | ||
assert.ok(res); | ||
assert.equal(startKeys + 1, localCache.getStats().keys); | ||
return localCache.get(key, function(err, res) { | ||
var pred; | ||
pred = {}; | ||
pred[key] = val; | ||
assert.eql(pred, res); | ||
localCache.on("expired", _testExpired); | ||
return setTimeout(function() { | ||
localCache._checkData(false); | ||
assert.isUndefined(localCache.data[key]); | ||
localCache.removeAllListeners("set"); | ||
return localCache.removeAllListeners("expired"); | ||
}, 700); | ||
}); | ||
}); | ||
@@ -475,4 +481,4 @@ }); | ||
return setTimeout(function() { | ||
localCache._checkData(false); | ||
return assert.isUndefined(localCache.data[key3]); | ||
assert.eql(localCache.get(key3), {}); | ||
assert.isUndefined(localCache.data[key3]); | ||
}, 500); | ||
@@ -524,2 +530,3 @@ }); | ||
return setTimeout(function() { | ||
assert.eql(localCache.get(key5), {}); | ||
localCacheTTL._checkData(false); | ||
@@ -526,0 +533,0 @@ return assert.isUndefined(localCacheTTL.data[key5]); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
59803
11
841
340