Registry / storage / time-cache

time-cache

JSON →
library0.3.0jsnpmunverified

A simple key-value cache with per-entry expiry dates. Version 0.3.0, maintained by Protocol Labs (IPFS ecosystem). Provides basic put/get/has operations with customizable validity periods. Suitable for IPFS PubSub and other distributed systems requiring ephemeral caching. Low dependency footprint.

npm install time-cache
INSTALL
IMPORT
SIG · TIME-CACHE
T
time-cache
storagejavascriptv0.3.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

TimeCache
import TimeCache from 'time-cache'
const TimeCache = require('time-cache')
ESM default export
TimeCache
const { TimeCache } = require('time-cache')
const TimeCache = require('time-cache')
CommonJS destructured import

Creates a TimeCache, adds entries with validity in ms, checks existence, and verifies expiration.

import TimeCache from 'time-cache'; const cache = new TimeCache(); cache.put('key1', 'value1', 10000); console.log(cache.has('key1')); // true setTimeout(() => { console.log(cache.has('key1')); // false (expired) }, 11000); cache.put('key2', 'value2', 5000); console.log(cache.get('key2')); // 'value2'
Debug
Known issues
gotchaValidity is in milliseconds, not seconds.
fix
Pass milliseconds: 5000 for 5 seconds.
affects: >=0.1.0
Errors
Common errors & fixes
TypeError: TimeCache is not a constructor
Using require('time-cache') which returns an object with TimeCache property, not the constructor directly.
fix
Use const { TimeCache } = require('time-cache');
Upgrade
Version history
0.3.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
30 hits · last 30 days
node
28
OpenAI (training)
1
Resources
time-cache — npm install time-cache · libregistry