A
Setimplementation with expirable keys
Memory is automatically released when an item expires by removing it from the Set.
$ npm install expiry-set
import ExpirySet from 'expiry-set';
const set = new ExpirySet(1000, [
'unicorn'
]);
set.has('unicorn');
//=> true
set.add('rainbow');
console.log(set.size);
//=> 2
// Wait for 1 second...
set.has('unicorn');
//=> false
console.log(set.size);
//=> 0Type: number
Milliseconds until a key in the Set expires.
Type: Object
An Array or other iterable object.
Any of the Set methods.
- expiry-map - A
Mapimplementation with expirable items - map-age-cleaner - Automatically cleanup expired items in a Map
MIT © Sam Verschueren