Registry / storage / throwaway-local-cache

throwaway-local-cache

JSON →
library1.3.0jsnpmunverified

A lightweight Node.js library for maintaining a fast local disk-backed cache without strict persistence guarantees. Version 1.3.0 is the latest stable release. It stores data on the filesystem, queuing writes and deletions to be batched and flushed asynchronously. Unlike persistent databases, it prioritizes speed over durability, making it ideal for temporary or disposable caches. It has minimal dependencies and a simple synchronous-like API using async/await.

npm install throwaway-local-cache
INSTALL
IMPORT
SIG · THROWAWAY-LOCAL-CA
T
throwaway-local-cache
storagejavascriptv1.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.

Cache
const Cache = require('throwaway-local-cache')
import Cache from 'throwaway-local-cache'
This package is CommonJS only; ESM imports will fail.
Cache
import Cache from 'throwaway-local-cache'
If using ESM, the default import works but requires the package to be loaded via createRequire or a bundler.
Cache
const { Cache } = require('throwaway-local-cache')
const cache = require('throwaway-local-cache')
The default export is the Cache constructor, but destructuring also works.

Creates a cache instance in a local folder, puts an entry, retrieves it, deletes it, and flushes all changes to disk.

const Cache = require('throwaway-local-cache'); const path = require('path'); async function main() { const c = new Cache(path.join(__dirname, 'cache')); await c.put('key', { value: true }); console.log(await c.get('key')); // { value: true } await c.del('key'); await c.flush(); } main().catch(console.error);
Debug
Known issues
gotchaData may be lost on crash: queued puts/deletes are not immediately persisted.
fix
Call await cache.flush() before exiting to ensure data is written.
affects: *
gotchaThe cache does not support TTL or automatic eviction; manual deletion required.
fix
Implement your own cleanup logic or use a library like lru-cache if automatic eviction is needed.
affects: *
Errors
Common errors & fixes
Cannot find module 'throwaway-local-cache'
Package not installed or not in node_modules.
fix
Run 'npm install throwaway-local-cache' in your project directory.
TypeError: Cache is not a constructor
Using ESM import but the package is CommonJS.
fix
Use require() instead of import, or use a bundler that handles CommonJS.
Upgrade
Version history
1.3.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
27 hits · last 30 days
node
24
Resources
throwaway-local-cache — npm install throwaway-local-cache · libregistry