{"library":"oblivious-set","title":"ObliviousSet","description":"ObliviousSet provides a JavaScript Set-like data structure where each entry is associated with a Time-To-Live (TTL). Unlike traditional caching mechanisms that often rely on intervals or timeouts for eviction, ObliviousSet's design avoids these, enabling proper garbage collection of the set instance when no active references exist. The current stable version is 2.0.0, which targets modern Node.js environments (>=16). While a strict release cadence isn't published, the package is actively maintained with updates released as needed for features or bug fixes. Its key differentiator is the efficient, passive expiration model where entries are only 'removed' (marked as expired) when explicitly checked via the `has()` method or when iterating over active elements, rather than through eager background processes. This minimizes overhead and resource consumption.","language":"javascript","status":"active","last_verified":"Sun Apr 19","install":{"commands":["npm install oblivious-set"],"cli":null},"imports":["import { ObliviousSet } from 'oblivious-set';","import type { ObliviousSet } from 'oblivious-set';"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import { ObliviousSet } from 'oblivious-set';\n\n// Create a set with a TTL of 100 milliseconds\nconst obliviousSet = new ObliviousSet(100);\n\n// Add a value; its TTL starts now\nobliviousSet.add('user_session_123');\n\n// Check existence immediately\nconsole.log('Has user_session_123 after add:', obliviousSet.has('user_session_123')); // true\n\n// Wait for the TTL to expire\nsetTimeout(() => {\n  console.log('Has user_session_123 after 150ms:', obliviousSet.has('user_session_123')); // false\n\n  // Add another value and check its initial state\n  obliviousSet.add('another_item');\n  console.log('Has another_item:', obliviousSet.has('another_item')); // true\n\n  // Clear all entries from the set\n  obliviousSet.clear();\n  console.log('Set size after clear:', obliviousSet.size); // 0\n}, 150);","lang":"typescript","description":"Demonstrates how to create an ObliviousSet, add elements, check for their existence before and after expiration, and clear the set.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}