oblivious-set
TypeScript icon, indicating that this package has built-in type declarations

1.4.0 • Public • Published

oblivious-set

Like a JavaScript Set() but with a TTL for entries.

In difference to other caches with TTLs out there, this one does not need intervals or timeouts to work. This means it can be properly garbage collected when there is no more reference to the instance.

Usage

import { ObliviousSet } from 'oblivious-set';

// create a set
const obliviousSet = new ObliviousSet(
    100 // TTL in milliseconds
);

// add a value
obliviousSet.add('foobar');

// check existence
console.log(obliviousSet.has('foobar')); // > true
console.log(obliviousSet.has('barfoo')); // > false


// clear
obliviousSet.clear();

Readme

Keywords

Package Sidebar

Install

npm i oblivious-set

Weekly Downloads

1,746,977

Version

1.4.0

License

MIT

Unpacked Size

28.8 kB

Total Files

28

Last publish

Collaborators

  • pubkey