9.9.14 • Published 3 years ago
@zero-version/key-value-storage.cache v9.9.14
Key/value storage as a cache.
Usage
import { cacheKeyValueStore } from '@zero-version/key-value-storage.cache';
import { memoryKeyValueStore } from '@zero-version/key-value-storage.memory';
const store = memoryKeyValueStore(); // Can be any key/value store
const cache = cacheKeyValueStore(store, 500); // 500 ms expiry
const run = async () => {
cache.set('my-value', { some: 'value' });
console.log(cache.get('my-value'));
// -> { some: 'value' } (cache hit)
// Wait a second...
await new Promise((resolve) => setTimeout(resolve, 1000));
console.log(cache.get('my-value'));
// -> undefined (cache miss)
};
run();
Support ☕
Are you using a package I've developed and finding it useful? Or have you looked at one of my repositories and learnt something new? If so, please consider buying me a coffee. Thanks!
0.1.0-beta
3 years ago
0.0.0-beta
3 years ago
9.9.10
3 years ago
9.9.12
3 years ago
9.9.13
3 years ago
9.9.14
3 years ago
0.0.73-beta
3 years ago
0.0.72-beta
3 years ago
0.0.71-beta
3 years ago
0.0.70-beta
3 years ago
0.0.40-beta
3 years ago
0.0.6-beta
3 years ago
0.0.5-beta
3 years ago
0.0.4
3 years ago
0.0.3
3 years ago