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

node-cache

Package Overview
Dependencies
Maintainers
2
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 5.0.0-alpha.1 to 5.0.0

4

index.js
/*
* node-cache 5.0.0-alpha.1 ( 2019-10-19 )
* node-cache 5.0.0 ( 2019-10-23 )
* https://github.com/mpneuried/nodecache

@@ -15,4 +15,4 @@ *

exports.version = '5.0.0-alpha.1';
exports.version = '5.0.0';
}).call(this);
/*
* node-cache 5.0.0-alpha.1 ( 2019-10-19 )
* node-cache 5.0.0 ( 2019-10-23 )
* https://github.com/mpneuried/nodecache

@@ -277,4 +277,2 @@ *

useClones: true,
// en/disable throwing errors when trying to `.get` missing or expired values.
errorOnMissing: false,
// whether values should be deleted automatically at expiration

@@ -281,0 +279,0 @@ deleteOnExpire: true,

@@ -28,3 +28,3 @@ {

],
"version": "5.0.0-alpha.1",
"version": "5.0.0",
"author": "mpneuried <mp@tcs.de>",

@@ -75,3 +75,3 @@ "maintainers": [

"grunt-run": "^0.8.1",
"istanbul": "0.x",
"istanbul": "^0.4.5",
"mocha": "^6.1.4",

@@ -78,0 +78,0 @@ "should": "11.x",

![Logo](./logo/logo.png)
[![Build Status](https://secure.travis-ci.org/mpneuried/nodecache.svg?branch=master)](http://travis-ci.org/mpneuried/nodecache)
[![Windows Tests](https://img.shields.io/appveyor/ci/mpneuried/nodecache.svg?label=Windows%20Test)](https://ci.appveyor.com/project/mpneuried/nodecache)
[![Dependency Status](https://david-dm.org/mpneuried/nodecache.svg)](https://david-dm.org/mpneuried/nodecache)
[![Build Status](https://secure.travis-ci.org/node-cache/node-cache.svg?branch=master)](http://travis-ci.org/node-cache/node-cache)
[![Windows Tests](https://img.shields.io/appveyor/ci/erdii/node-cache.svg?label=Windows%20Test)](https://ci.appveyor.com/project/node-cache/node-cache)
[![Dependency Status](https://david-dm.org/node-cache/node-cache.svg)](https://david-dm.org/node-cache/node-cache)
[![NPM version](https://badge.fury.io/js/node-cache.svg)](http://badge.fury.io/js/node-cache)
[![Coveralls Coverage](https://img.shields.io/coveralls/mpneuried/nodecache.svg)](https://coveralls.io/github/mpneuried/nodecache)
[![Coveralls Coverage](https://img.shields.io/coveralls/node-cache/node-cache.svg)](https://coveralls.io/github/node-cache/node-cache)

@@ -20,8 +20,14 @@ [![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/tcs-de/nodecache?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge)

## ATTENTION - BREAKING MAJOR RELEASE INCOMING!!!
## BREAKING MAJOR RELEASE v5.x
The upcoming 5.0.0 Release will drop support for node versions before 6.x!
(We are thinking about dropping node 6.x too, because it recently reached end-of-life.)
The recent 5.x release:
* dropped support for node versions before 8.x!
* removed the callback-based api from all methods (you can re-enable them with the option `enableLegacyCallbacks`)
## BREAKING MAJOR RELEASE v6.x UPCOMING
Although not breaking per definition, our typescript rewrite will change internal functions and their names.
Please get in contact with us, if you are using some parts of node-cache's internal api so we can work something out!
# Install

@@ -50,5 +56,7 @@

`0` = no periodic check.
- `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 example](https://runkit.com/mpneuried/useclones-example-83) showing the different behavior_
- `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 if you want **simplicity**, because it'll behave like a server-based cache (it caches copies of plain data).
- `false` is recommended if you want to achieve **performance** or save mutable objects or other complex types with mutability involved and wanted, because it'll only store references of your data.
- _Here's a [simple code example](https://runkit.com/mpneuried/useclones-example-83) showing the different behavior_
- `deleteOnExpire`: *(default: `true`)* whether variables will be deleted automatically when they expire.

@@ -85,2 +93,19 @@ 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.

## Store multiple keys (MSET):
`myCache.mset(Array<{key, val, ttl?}>)`
Sets multiple `key` `val` pairs. It is possible to define a `ttl` (seconds).
Returns `true` on success.
```js
const obj = { my: "Special", variable: 42 };
const obj2 = { my: "other special", variable: 1337 };
const success = myCache.mset([
{key: "myKey", val: obj, ttl: 10000},
{key: "myKey2", val: obj2},
])
```
## Retrieve a key (GET):

@@ -111,13 +136,2 @@

**Since `3.1.0`**
`errorOnMissing` option added
```js
try{
value = myCache.get( "not-existing-key", true );
} catch( err ){
// ENOTFOUND: Key `not-existing-key` not found
}
```
## Get multiple keys (MGET):

@@ -244,3 +258,2 @@

```js
/* sync */
exists = myCache.has( 'myKey' );

@@ -360,84 +373,9 @@

## Benchmarks
### version `5.x`
### Version 1.1.x
Callbacks are deprecated in this version. They are still useable when enabling the `enableLegacyCallbacks` option when initializing the cache. Callbacks will be completely removed in `6.x`.
After adding io.js to the travis test here are the benchmark results for set and get of 100000 elements.
But be careful with this results, because it has been executed on travis machines, so it is not guaranteed, that it was executed on similar hardware.
**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 )
**io.js `v1.1.0`**
SET: `510`ms ( `5.1`µs per item )
GET: `1535`ms ( `15.35`µs per item )
### Version 2.0.x
Again the same benchmarks by travis with version 2.0
**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`**
SET: `353`ms ( `3.53`µ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 )
**io.js `v1.7.1`**
SET: `238`ms ( `2.38`µs per item )
GET: `34`ms ( `0.34`µs per item )
> As you can see the version 2.x will increase the GET performance up to 200x in node 0.10.x.
This is possible because the memory allocation for the object returned by 1.x is very expensive.
### Version 3.0.x
*see [travis results](https://travis-ci.org/mpneuried/nodecache/builds/64560503)*
**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`**
SET: `353`ms ( `5.41`µ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 )
**io.js `v2.1.0`**
SET: `238`ms ( `4.06`µs per item )
GET: `34`ms ( `0.67`µs per item )
> until the version 3.0.x the object cloning is included, so we lost a little bit of the performance
### Version 3.1.x
**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 )
GET: `167ms` ( `1.67µs` per item )
**node.js `v4.2.6`**
SET: `356ms` ( `3.56µs` per item )
GET: `83ms` ( `0.83µs` per item )
## Compatibility
This module should work well back until node `0.6.x`.
But it's only tested until version `0.10.x` because the build dependencies are not installable ;-) .
Node-Cache supports all node versions >= 8

@@ -447,2 +385,3 @@ ## Release History

|:--:|:--:|:--|
|5.0.0|2019-10-23|Remove lodash dependency, add .has(key) and .mset([{key,val,ttl}]) methods to the cache. Thanks to [Regev Brody](https://github.com/regevbr) for PR [#132] and [Sujesh Thekkepatt](https://github.com/sujeshthekkepatt) for PR [#142]! Also thank you, to all other contributors that remain unnamed here!|
|4.2.1|2019-07-22|Upgrade lodash to version 4.17.15 to suppress messages about unrelated security vulnerability|

@@ -500,3 +439,3 @@ |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.|

Copyright © 2013 Mathias Peter, http://www.tcs.de
Copyright © 2019 Mathias Peter and the node-cache maintainers, https://github.com/node-cache/node-cache

@@ -503,0 +442,0 @@ Permission is hereby granted, free of charge, to any person obtaining

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