kv-cache-manager
v1.0.2
Published
key-value rule-based cache stores manager
Downloads
7
Readme
key-value rule-based cache stores manager
Installation
npm install --save kv-cache-manager
Simple usage
var Manager = require('..');
var MemoryStore = Manager.MemoryStore, FileStore = Manager.FileStore;
var mng = new Manager();
mng.addStore('memory', new MemoryStore());
mng.addStore('file', new FileStore());
mng.addRule('memory', /^m\//);
mng.addRule('file', /^f\//);
mng.set('m/name', 'memory');//save in memory store
mng.set('f/name', 'file');//save in file store
assert.equal(mng.get('m/name'), 'memory');
assert.equal(mng.get('f/name'), 'file');
API
set()
set(key: string, val: any, options?: number|object): void set(key: array|object|, options?: number|object): void
parameter key is array: [key1, val1, key2, val2, ...] parameter key is object: {key1: val1, key2: val2, ...} parameter options is number: means the ttl parameter options is object: {ttl: number}
get(key: string): any
mget()
mget(key: array<string>
): object
mget(key1: string, key2: string, ...keyn: string): object
License
Licensed under MIT
Copyright (c) 2015-2016 kiliwalk