Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

node-cache

Package Overview
Dependencies
Maintainers
1
Versions
34
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

node-cache - npm Package Compare versions

Comparing version 2.0.1 to 2.1.0

2

index.js

@@ -6,4 +6,4 @@ (function() {

exports.version = '2.0.1';
exports.version = '2.1.0';
}).call(this);

@@ -52,3 +52,3 @@ (function() {

NodeCache.prototype.get = function(key, cb) {
var _err, _ret;
var _ret;
if ((this.data[key] != null) && this._check(key, this.data[key])) {

@@ -63,9 +63,6 @@ this.stats.hits++;

this.stats.misses++;
_err = this._error("ENOTFOUND", {
key: key
});
if (cb != null) {
cb(_err);
cb(null, void 0);
}
return _err;
return void 0;
}

@@ -72,0 +69,0 @@ };

@@ -6,3 +6,3 @@ {

"tags": [ "cache", "caching", "local", "variable", "multi", "memory", "internal", "node", "memcached", "object" ],
"version": "2.0.1",
"version": "2.1.0",
"author": "tcs-de <github@tcs.de>",

@@ -9,0 +9,0 @@ "main": "./index.js",

@@ -47,3 +47,3 @@ node-cache

`0` = no periodic check.
**Note:** If you use `checkperiod > 0` you script will not exit at the end, because a internal timeout will allways be active.
**Note:** If you use `checkperiod > 0` you script will not exit at the end, because a internal timeout will always be active.

@@ -88,3 +88,3 @@ ```js

Gets a saved value from the cache.
Returns an Error with the name `ENOTFOUND` if not found or expired.
Returns a `undefined` if not found or expired.
If the value was found it returns an object with the `key` `value` pair.

@@ -95,7 +95,9 @@

if( !err ){
console.log( value );
//{ my: "Special", variable: 42 }
// ... do something ...
} else if( err.name === "ENOTFOUND" ){
// key not found
if(value == undefined){
// key not found
}else{
console.log( value );
//{ my: "Special", variable: 42 }
// ... do something ...
}
}

@@ -110,3 +112,3 @@ });

value = myCache.get( "myKey" );
if ( !value instanceof Error ){
if ( value == undefined ){
// handle miss!

@@ -121,2 +123,7 @@ }

**Since `2.1.0`**:
The return format changed to the simple value, but a due to discussion in #11 a miss shouldn't return an error.
So until 2.1.0 it'll return a `undefined`.
## Get multiple keys (MGET):

@@ -313,3 +320,3 @@

This will clear the interval timeout which is set on checkperiod option.
This will clear the interval timeout which is set on check period option.

@@ -370,3 +377,3 @@ ```js

After adding io.js to the travis test here are the benchmark results for set and get of 100000 elements.
But be carefull with this results, because it has been executed on travis machines, so it is not guaranteed, that was executed on similar hardware.
But be careful with this results, because it has been executed on travis machines, so it is not guaranteed, that was executed on similar hardware.

@@ -406,3 +413,3 @@ **node.js `0.10.36`**

> As you can see the version 2.0.x will increase the GET performance up to 200x in node 0.10.x.
This is possible because the memeroy allocation for the object returned by 1.x is very expensive.
This is possible because the memory allocation for the object returned by 1.x is very expensive.

@@ -412,3 +419,4 @@ ## Release History

|:--:|:--:|:--|
|2.0.1|2015-04-17|Added close function (Thanks to [ownagedj ](https://github.com/ownagedj)). Changed the development environment to use grunt.|
|2.1.0|2015-04-17|Changed get miss to return `undefined` instead of an error. Thanks to all [#11](https://github.com/tcs-de/nodecache/issues/11) contributors |
|2.0.1|2015-04-17|Added close function (Thanks to [ownagedj](https://github.com/ownagedj)). Changed the development environment to use grunt.|
|2.0.0|2015-01-05|changed return format of `.get()` with a error return on a miss and added the `.mget()` method. *Side effect: Performance of .get() up to 330 times faster!*|

@@ -430,3 +438,3 @@ |1.1.0|2015-01-05|added `.keys()` method to list all existing keys|

|:--|:--|
|[**rsmq**](https://github.com/smrchy/rsmq)|A really simple message queue based on Redis|
|[**rsmq**](https://github.com/smrchy/rsmq)|A really simple message queue based on redis|
|[**redis-sessions**](https://github.com/smrchy/redis-sessions)|An advanced session store for NodeJS and Redis|

@@ -436,5 +444,5 @@ |[**connect-redis-sessions**](https://github.com/mpneuried/connect-redis-sessions)|A connect or express middleware to simply use the [redis sessions](https://github.com/smrchy/redis-sessions). With [redis sessions](https://github.com/smrchy/redis-sessions) you can handle multiple sessions per user_id.|

|[**systemhealth**](https://github.com/mpneuried/systemhealth)|Node module to run simple custom checks for your machine or it's connections. It will use [redis-heartbeat](https://github.com/mpneuried/redis-heartbeat) to send the current state to redis.|
|[**task-queue-worker**](https://github.com/smrchy/task-queue-worker)|A powerful tool for background processing of tasks that are run by making standard http requests.|
|[**soyer**](https://github.com/mpneuried/soyer)|Soyer is small lib for serverside use of Google Closure Templates with node.js.|
|[**grunt-soy-compile**](https://github.com/mpneuried/grunt-soy-compile)|Compile Goggle Closure Templates ( SOY ) templates inclding the handling of XLIFF language files.|
|[**task-queue-worker**](https://github.com/smrchy/task-queue-worker)|A powerful tool for background processing of tasks that are run by making standard http requests
|[**soyer**](https://github.com/mpneuried/soyer)|Soyer is small lib for server side use of Google Closure Templates with node.js.|
|[**grunt-soy-compile**](https://github.com/mpneuried/grunt-soy-compile)|Compile Goggle Closure Templates ( SOY ) templates including the handling of XLIFF language files.|
|[**backlunr**](https://github.com/mpneuried/backlunr)|A solution to bring Backbone Collections together with the browser fulltext search engine Lunr.js|

@@ -441,0 +449,0 @@

@@ -72,5 +72,3 @@ (function() {

n++;
assert.isNotNull(err, err);
assert.eql(err.constructor.name, "Error");
assert.eql("ENOTFOUND", err.name);
assert.isNull(err, err);
assert.isUndefined(res, res);

@@ -103,5 +101,3 @@ });

n++;
assert.isNotNull(err, err);
assert.eql(err.constructor.name, "Error");
assert.eql("ENOTFOUND", err.name);
assert.isNull(err, err);
assert.isUndefined(res, res);

@@ -144,5 +140,3 @@ });

res = localCache.get("xxx");
console.log("error", res instanceof Error);
assert.eql(res.constructor.name, "Error");
assert.eql(res.name, "ENOTFOUND");
assert.isUndefined(res, res);
res = localCache.del("xxx");

@@ -160,4 +154,3 @@ assert.equal(0, res);

res = localCache.get(key);
assert.eql(res.constructor.name, "Error");
assert.eql(res.name, "ENOTFOUND");
assert.isUndefined(res, res);
res = localCache.set("zero", 0, 0);

@@ -293,5 +286,3 @@ assert.ok(res, res);

++n;
assert.isNotNull(err, err);
assert.eql(err.constructor.name, "Error");
assert.eql("ENOTFOUND", err.name);
assert.isNull(err, err);
assert.isUndefined(res, res);

@@ -398,5 +389,3 @@ });

localCache.get(key, function(err, res) {
assert.isNotNull(err, err);
assert.eql(err.constructor.name, "Error");
assert.eql("ENOTFOUND", err.name);
assert.isNull(err, err);
assert.isUndefined(res, res);

@@ -467,5 +456,3 @@ });

res = localCache.get(key3);
assert.isNotNull(res, res);
assert.eql(res.constructor.name, "Error");
assert.eql("ENOTFOUND", res.name);
assert.isUndefined(res, res);
assert.isUndefined(localCache.data[key3]);

@@ -511,5 +498,3 @@ }, 500);

res = localCache.get(key5);
assert.isNotNull(res, res);
assert.eql(res.constructor.name, "Error");
assert.eql("ENOTFOUND", res.name);
assert.isUndefined(res, res);
localCacheTTL._checkData(false);

@@ -516,0 +501,0 @@ assert.isUndefined(localCacheTTL.data[key5]);

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc