Spaces:
Paused
Paused
Download storage/cache.js from oqz-labs/newnodejs2: direct link, hf CLI and curl.
- Browser
- Download file 330 Bytes
-
https://huggingface.co/spaces/oqz-labs/newnodejs2/resolve/main/storage/cache.js
- Command line
-
hf download hf://spaces/oqz-labs/newnodejs2/storage/cache.js
-
curl -L -o cache.js https://huggingface.co/spaces/oqz-labs/newnodejs2/resolve/main/storage/cache.js
330 Bytes
| const cache = {}; | |
| function set(key, value, ttl = 5000) { | |
| cache[key] = { | |
| value, | |
| expiry: Date.now() + ttl | |
| }; | |
| } | |
| function get(key) { | |
| const item = cache[key]; | |
| if (!item) return null; | |
| if (Date.now() > item.expiry) { | |
| delete cache[key]; | |
| return null; | |
| } | |
| return item.value; | |
| } | |
| module.exports = { set, get }; |