@luolapeikko/cache-types
v0.0.7
Published
Typescript cache interfaces
Downloads
34
Readme
@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
}