Skip to content

Latest commit

 

History

History
27 lines (21 loc) · 782 Bytes

cache.md

File metadata and controls

27 lines (21 loc) · 782 Bytes

Data Structure - Cache

cache-file-ts cache-gzip-ts cache-brotli-ts

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

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');