rl-store
v0.1.1
Published
A cache story limited size
Downloads
6
Readme
rl-store
A map which be limited size of storage for catching.
Rin&Len store.
const RlStroe = require('rl-store');
const store = new RlStroe(1000); // Limite the store only retain 1000 length of string.
// to test the key exist
'key0' in store.data
// or
store.has('key0')
// to set
store.data['key1'] = 'value1';
store.dispatch('set', {key: 'key1'});
// or
store.set('key1', 'value1')
// to get
let value1 = store.data['key2'];
store.dispatch('get', {key: 'key2'});
// or
store.get('key2')
// to remove a key maunally
store.delete('key1');
And, you can extend RLStore to get the event when store be called into get()
, set()
and delete()
.
const RlStroe = require('rl-store');
class MyRlStroe extends RlStroe {
onGet(payload :any){
console.log('got!');
super.onGet(payload);
}
}