Light Cache is a lightweight and simple in-memory internal cache module for NodeJS.
- [extend] - Simple function to extend objects
Light Cache requires at least Node.js v6.10.0+ to run.
$ npm install light-cache
var LightCache = require('light-cache');
var lightCache = new LightCache("Cache Store One");
var todoList = lightCache.get('todos');
lightCache.set('todos', 'first to do');
lightCache.set('todos', {foo: bar});
lightCache.set('todos', [0, 1, 2]);
var todoList = lightCache.mget(['todos', 'meetings']);
var todoList = lightCache.mget(
['todos', 'meetings'],
[
{
todo_one: 1
},
{
todo_two: 2
}
]
);
var isKeyExists = lightCache.exists('todos');
// true
var areKeysExists = lightCache.mexists(['todos', 'meetings']);
{
todos: true,
meetings: true
}
lightCache.del('todos');
lightCache.mdel(['todos','metings']);
lightCache.append('todos', {todo:3});
lightCache.prepend('todos', {todo:0});
lightCache.stats();
{
get: 50,
set: 300,
mget: 74,
mset: 54,
exists: 93,
mexists: 596,
del: 165,
mdel: 874,
append: 806,
prepend: 960
}
lightCache.flush();