A cache of values with a max size to ensure that too much old data is not stored. The deletion system uses the FIFO policy
import { Cache } from 'gis-tools-ts';const onDelete = (key: string, value: string) => { console.log(`Deleted key ${key} with value ${value}`);};const cache = new Cache<string, string>(10, onDelete);cache.set('key', 'value');console.log(cache.get('key')); // 'value'cache.delete('key'); Copy
import { Cache } from 'gis-tools-ts';const onDelete = (key: string, value: string) => { console.log(`Deleted key ${key} with value ${value}`);};const cache = new Cache<string, string>(10, onDelete);cache.set('key', 'value');console.log(cache.get('key')); // 'value'cache.delete('key');
the max size of the cache before dumping old data
Optional
if provided, will be called when a value is removed
the offset position in the data
the value to store
this
Cache System
Description
A cache of values with a max size to ensure that too much old data is not stored. The deletion system uses the FIFO policy
Usage