0.0.9 • Published 10 months ago
@luolapeikko/cache-types v0.0.9
@luolapeikko/cache-types
Typescript Cache interfaces.
Cache interface is a simple Map like key-value interface with basic operations like get, set, has, delete and clear with cache related options like "set" method to add entry ttl to the cache and "expires" method to get current entry ttl.
Example
import {type ICache} from '@luolapeikko/cache-types';
function foo(cache: ICache<string>) {
const value = cache.get('key');
cache.set('key', 'value' /*, ttl: Date */);
cache.has('key'); // true
cache.expires('key'); // Date or undefined
cache.delete('key');
cache.clear();
cache.size(); // 0
}