Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/pubkey/oblivious-set
Like a JavaScript Set() but with a TTL for entries
https://github.com/pubkey/oblivious-set
Last synced: about 2 months ago
JSON representation
Like a JavaScript Set() but with a TTL for entries
- Host: GitHub
- URL: https://github.com/pubkey/oblivious-set
- Owner: pubkey
- License: mit
- Created: 2021-06-07T20:39:28.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2024-04-08T00:19:19.000Z (5 months ago)
- Last Synced: 2024-07-19T04:17:20.627Z (about 2 months ago)
- Language: TypeScript
- Size: 20.5 KB
- Stars: 7
- Watchers: 3
- Forks: 2
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-list - oblivious-set
README
# 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
```ts
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();
```