Simple in-memory caching for Javascript.
$ npm install simple-stash --save
const cache = require('simple-stash');
const data = [
{
id: 'test-uuid-1',
name: 'John Smith'
},
{
id: 'test-uuid-2',
name: 'Jane Miller'
}
];
cache.set('users', data);
const customer = cache.get('users:id:test-uuid-1');
console.log(customer);
Logs:
{
"id": "test-uuid-1",
"name": "John Smith"
}
const cache = require('simple-stash');
const data = [
{
id: 'test-uuid-1',
name: 'John Smith'
},
{
id: 'test-uuid-2',
name: 'John Smith'
},
{
id: 'test-uuid-3',
name: 'Jane Miller'
}
];
cache.set('users', data);
const customers = cache.getAll('users:name:John Smith');
console.log(customers);
Logs:
[
{
"id": "test-uuid-1",
"name": "John Smith"
},
{
"id": "test-uuid-2",
"name": "John Smith"
}
]
You can also remove all items from storage.
cache.clear();
We use SemVer for versioning. For the versions available, see the tags on this repository.