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 4.1.1 to 4.2.0

_src/test/typedefinition_test.ts

6

index.js
/*
* node-cache 4.1.0 ( 2016-12-21 )
* node-cache 4.1.1 ( 2018-01-31 )
* https://github.com/mpneuried/nodecache

@@ -8,3 +8,3 @@ *

*
* Maintained by M. Peter ( https://github.com/mpneuried )
* Maintained by ( )
*/

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

exports.version = '4.1.0';
exports.version = '4.1.1';
}).call(this);
/*
* node-cache 4.1.0 ( 2016-12-21 )
* node-cache 4.1.1 ( 2018-01-31 )
* https://github.com/mpneuried/nodecache

@@ -8,3 +8,3 @@ *

*
* Maintained by M. Peter ( https://github.com/mpneuried )
* Maintained by ( )
*/

@@ -70,3 +70,4 @@ (function() {

useClones: true,
errorOnMissing: false
errorOnMissing: false,
deleteOnExpire: true
}, this.options);

@@ -362,9 +363,12 @@ this.stats = {

NodeCache.prototype._check = function(key, data) {
var _retval;
_retval = true;
if (data.t !== 0 && data.t < Date.now()) {
this.del(key);
if (this.options.deleteOnExpire) {
_retval = false;
this.del(key);
}
this.emit("expired", key, this._unwrap(data));
return false;
} else {
return true;
}
return _retval;
};

@@ -371,0 +375,0 @@

@@ -28,10 +28,18 @@ {

],
"version": "4.1.1",
"version": "4.2.0",
"author": "mpneuried <mp@tcs.de>",
"maintainers": {
"name": "M. Peter",
"email": "mp@tcs.de",
"url": "https://github.com/mpneuried"
},
"maintainers": [
{
"name": "M. Peter",
"email": "mp@tcs.de",
"url": "https://github.com/mpneuried"
},
{
"name": "Joshy",
"email": "erdiicodes@gmail.com",
"url": "https://blog.werise.de/"
}
],
"main": "./index.js",
"types": "./index.d.ts",
"homepage": "https://github.com/mpneuried/nodecache",

@@ -47,4 +55,4 @@ "repository": {

"scripts": {
"test": "COFFEECOV_INIT_ALL=false mocha --compilers coffee:coffee-script/register --require coffee-coverage/register-istanbul _src/test/mocha_test.coffee -R spec",
"test-docker": "SILIENT_MODE=1 mocha test/mocha_test.js -R min",
"test": "COFFEECOV_INIT_ALL=false mocha --compilers coffee:coffee-script/register --require coffee-coverage/register-istanbul _src/test/mocha_test.coffee -R spec && tsc",
"test-docker": "SILENT_MODE=1 mocha test/mocha_test.js -R min && tsc",
"build": "grunt build"

@@ -57,2 +65,3 @@ },

"devDependencies": {
"@types/node": "^8.9.4",
"coffee-coverage": "1.x",

@@ -63,2 +72,3 @@ "coffee-script": "1.x",

"grunt-banner": "0.6.x",
"grunt-cli": "^1.2.0",
"grunt-contrib-clean": "1.0.x",

@@ -73,4 +83,5 @@ "grunt-contrib-coffee": "1.0.x",

"mocha": "3.x",
"should": "11.x"
"should": "11.x",
"typescript": "^2.6.1"
}
}

@@ -16,8 +16,8 @@ node-cache

A simple caching module that has `set`, `get` and `delete` methods and works a little bit like memcached.
Keys can have a timeout (`ttl`) after which they expire and are deleted from the cache.
A simple caching module that has `set`, `get` and `delete` methods and works a little bit like memcached.
Keys can have a timeout (`ttl`) after which they expire and are deleted from the cache.
All keys are stored in a single object so the practical limit is at around 1m keys.
**Since `4.1.0`**:
*Key-validation*: The keys can be given as either `string` or `number`, but are casted to a `string` internally anyway.
*Key-validation*: The keys can be given as either `string` or `number`, but are casted to a `string` internally anyway.
All other types will either throw an error or call the callback with an error.

@@ -45,9 +45,12 @@

- `stdTTL`: *(default: `0`)* the standard ttl as number in seconds for every generated cache element.
- `stdTTL`: *(default: `0`)* the standard ttl as number in seconds for every generated cache element.
`0` = unlimited
- `checkperiod`: *(default: `600`)* The period in seconds, as a number, used for the automatic delete check interval.
- `checkperiod`: *(default: `600`)* The period in seconds, as a number, used for the automatic delete check interval.
`0` = no periodic check.
- `errorOnMissing`: *(default: `false`)* en/disable throwing or passing an error to the callback if attempting to `.get` a missing or expired value.
- `useClones`: *(default: `true`)* en/disable cloning of variables. If `true` you'll get a copy of the cached variable. If `false` you'll save and get just the reference.
- `useClones`: *(default: `true`)* en/disable cloning of variables. If `true` you'll get a copy of the cached variable. If `false` you'll save and get just the reference.
**Note:** `true` is recommended, because it'll behave like a server-based caching. You should set `false` if you want to save mutable objects or other complex types with mutability involved and wanted.
_Here's a [simple code exmaple](https://runkit.com/mpneuried/useclones-example-83) showing the different behavior_
- `deleteOnExpire`: *(default: `true`)* whether variables will be deleted automatically when they expire.
If `true` the variable will be deleted. If `false` the variable will remain. You are encouraged to handle the variable upon the event `expired` by yourself.

@@ -63,3 +66,3 @@ ```js

Sets a `key` `value` pair. It is possible to define a `ttl` (in seconds).
Sets a `key` `value` pair. It is possible to define a `ttl` (in seconds).
Returns `true` on success.

@@ -80,3 +83,3 @@

**Since `1.0.0`**:
**Since `1.0.0`**:
Callback is now optional. You can also use synchronous syntax.

@@ -113,3 +116,3 @@

**Since `1.0.0`**:
**Since `1.0.0`**:
Callback is now optional. You can also use synchronous syntax.

@@ -125,3 +128,3 @@

**Since `2.0.0`**:
**Since `2.0.0`**:

@@ -169,3 +172,3 @@ The return format changed to a simple value and a `ENOTFOUND` error if not found *( as `callback( err )` or on sync call as result instance of `Error` )*.

**Since `1.0.0`**:
**Since `1.0.0`**:
Callback is now optional. You can also use synchronous syntax.

@@ -183,3 +186,3 @@

**Since `2.0.0`**:
**Since `2.0.0`**:

@@ -203,3 +206,3 @@ The method for mget changed from `.get( [ "a", "b" ] )` to `.mget( [ "a", "b" ] )`

**Since `1.0.0`**:
**Since `1.0.0`**:
Callback is now optional. You can also use synchronous syntax.

@@ -227,3 +230,3 @@

**Since `1.0.0`**:
**Since `1.0.0`**:
Callback is now optional. You can also use synchronous syntax.

@@ -246,3 +249,3 @@

Redefine the ttl of a key. Returns true if the key has been found and changed. Otherwise returns false.
Redefine the ttl of a key. Returns true if the key has been found and changed. Otherwise returns false.
If the ttl-argument isn't passed the default-TTL will be used.

@@ -291,3 +294,3 @@

myCache.set( "ttlKey", "MyExpireData" )
myCache.set( "noTtlKey", 0, "NonExpireData" )
myCache.set( "noTtlKey", "NonExpireData", 0 )

@@ -316,3 +319,3 @@ ts = myCache.getTtl( "ttlKey" )

Returns an array of all existing keys.
Returns an array of all existing keys.

@@ -340,3 +343,3 @@ ```js

Returns the statistics.
Returns the statistics.

@@ -360,3 +363,3 @@ ```js

Flush all data.
Flush all data.

@@ -396,3 +399,3 @@ ```js

myCache.on( "set", function( key, value ){
// ... do something ...
// ... do something ...
});

@@ -408,3 +411,3 @@ ```

myCache.on( "del", function( key, value ){
// ... do something ...
// ... do something ...
});

@@ -420,3 +423,3 @@ ```

myCache.on( "expired", function( key, value ){
// ... do something ...
// ... do something ...
});

@@ -431,3 +434,3 @@ ```

myCache.on( "flush", function(){
// ... do something ...
// ... do something ...
});

@@ -447,4 +450,4 @@ ```

Due to the [Issue #30](https://github.com/mpneuried/nodecache/issues/30) and [Issue #27](https://github.com/mpneuried/nodecache/issues/27) variables will now be cloned.
This chould break your code, because for some variable types ( e.g. Promise ) its not possible to clone them.
Due to the [Issue #30](https://github.com/mpneuried/nodecache/issues/30) and [Issue #27](https://github.com/mpneuried/nodecache/issues/27) variables will now be cloned.
This could break your code, because for some variable types ( e.g. Promise ) its not possible to clone them.
You can disable the cloning by setting the option `useClones: false`. In this case it's compatible with version `2.x`.

@@ -459,13 +462,13 @@

**node.js `0.10.36`**
SET: `324`ms ( `3.24`µs per item )
GET: `7956`ms ( `79.56`µs per item )
**node.js `0.10.36`**
SET: `324`ms ( `3.24`µs per item )
GET: `7956`ms ( `79.56`µs per item )
**node.js `0.12.0`**
SET: `432`ms ( `4.32`µs per item )
GET: `42767`ms ( `427.67`µs per item )
**node.js `0.12.0`**
SET: `432`ms ( `4.32`µs per item )
GET: `42767`ms ( `427.67`µs per item )
**io.js `v1.1.0`**
SET: `510`ms ( `5.1`µs per item )
GET: `1535`ms ( `15.35`µs per item )
**io.js `v1.1.0`**
SET: `510`ms ( `5.1`µs per item )
GET: `1535`ms ( `15.35`µs per item )

@@ -476,17 +479,17 @@ ### Version 2.0.x

**node.js `0.6.21`**
SET: `786`ms ( `7.86`µs per item )
GET: `56`ms ( `0.56`µs per item )
**node.js `0.6.21`**
SET: `786`ms ( `7.86`µs per item )
GET: `56`ms ( `0.56`µs per item )
**node.js `0.10.36`**
**node.js `0.10.36`**
SET: `353`ms ( `3.53`µs per item )
GET: `41`ms ( `0.41`µs per item )
GET: `41`ms ( `0.41`µs per item )
**node.js `0.12.2`**
SET: `327`ms ( `3.27`µs per item )
GET: `32`ms ( `0.32`µs per item )
**node.js `0.12.2`**
SET: `327`ms ( `3.27`µs per item )
GET: `32`ms ( `0.32`µs per item )
**io.js `v1.7.1`**
SET: `238`ms ( `2.38`µs per item )
GET: `34`ms ( `0.34`µs per item )
**io.js `v1.7.1`**
SET: `238`ms ( `2.38`µs per item )
GET: `34`ms ( `0.34`µs per item )

@@ -500,16 +503,16 @@ > As you can see the version 2.x will increase the GET performance up to 200x in node 0.10.x.

**node.js `0.6.21`**
SET: `786`ms ( `7.24`µs per item )
GET: `56`ms ( `1.14`µs per item )
**node.js `0.6.21`**
SET: `786`ms ( `7.24`µs per item )
GET: `56`ms ( `1.14`µs per item )
**node.js `0.10.38`**
**node.js `0.10.38`**
SET: `353`ms ( `5.41`µs per item )
GET: `41`ms ( `1.23`µs per item )
GET: `41`ms ( `1.23`µs per item )
**node.js `0.12.4`**
SET: `327`ms ( `4.63`µs per item )
GET: `32`ms ( `0.60`µs per item )
**node.js `0.12.4`**
SET: `327`ms ( `4.63`µs per item )
GET: `32`ms ( `0.60`µs per item )
**io.js `v2.1.0`**
SET: `238`ms ( `4.06`µs per item )
**io.js `v2.1.0`**
SET: `238`ms ( `4.06`µs per item )
GET: `34`ms ( `0.67`µs per item )

@@ -521,12 +524,12 @@

**node.js `v0.10.41`**
SET: `305ms` ( `3.05µs` per item )
**node.js `v0.10.41`**
SET: `305ms` ( `3.05µs` per item )
GET: `104ms` ( `1.04µs` per item )
**node.js `v0.12.9`**
SET: `337ms` ( `3.37µs` per item )
**node.js `v0.12.9`**
SET: `337ms` ( `3.37µs` per item )
GET: `167ms` ( `1.67µs` per item )
**node.js `v4.2.6`**
SET: `356ms` ( `3.56µs` per item )
**node.js `v4.2.6`**
SET: `356ms` ( `3.56µs` per item )
GET: `83ms` ( `0.83µs` per item )

@@ -542,3 +545,4 @@

|:--:|:--:|:--|
|4.1.1|2016-12-21|fix internal check interval for node < 0.10.25, thats teh default node for ubuntu 14.04. Thanks to [Jimmy Hwang](https://github.com/JimmyHwang) for for the pull [#78](https://github.com/mpneuried/nodecache/pull/78); added more docker tests|
|4.2.0|2018-02-01|Add options.promiseValueSize for promise value. Thanks to [Ryan Roemer](https://github.com/ryan-roemer) for the pull [#84]; Added option `deleteOnExpire`; Added DefinitelyTyped Typescript definitions. Thanks to [Ulf Seltmann](https://github.com/useltmann) for the pulls [#90] and [#92]; Thanks to [Daniel Jin](https://github.com/danieljin) for the readme fix in pull [#93]; Optimized test and ci configs.|
|4.1.1|2016-12-21|fix internal check interval for node < 0.10.25, thats the default node for ubuntu 14.04. Thanks to [Jimmy Hwang](https://github.com/JimmyHwang) for the pull [#78](https://github.com/mpneuried/nodecache/pull/78); added more docker tests|
|4.1.0|2016-09-23|Added tests for different key types; Added key validation (must be `string` or `number`); Fixed `.del` bug where trying to delete a `number` key resulted in no deletion at all.|

@@ -545,0 +549,0 @@ |4.0.0|2016-09-20|Updated tests to mocha; Fixed `.ttl` bug to not delete key on `.ttl( key, 0 )`. This is also relevant if `stdTTL=0`. *This causes the breaking change to `4.0.0`.*|

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