Registry / storage / raptor-cache

raptor-cache

JSON →
library2.0.5jsnpmunverified

Efficient JavaScript cache implementation for Node.js that supports asynchronous reading and writing, prevents duplicate work via cache entry holds, and provides out-of-box in-memory and disk-based cache stores. Version 2.0.5 is current. It solves concurrency challenges with asynchronous cache stores and allows custom stores (e.g., Redis, memcached). Key differentiators: hold mechanism to avoid rebuilding same key, configurable time-to-live and time-to-idle, and support for combined file or separate files disk stores.

npm install raptor-cache
INSTALL
IMPORT
SIG · RAPTOR-CACHE
R
raptor-cache
storagejavascriptv2.0.5
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.

createCache
import { createCache } from 'raptor-cache'
const createCache = require('raptor-cache').createCache
ESM named export. CommonJS require returns the module object with createCache method.
createMemoryCache
import { createMemoryCache } from 'raptor-cache'
const raptorCache = require('raptor-cache'); const cache = raptorCache.createMemoryCache(...)
Same pattern as createCache, but specifically for in-memory store.
createDiskCache
import { createDiskCache } from 'raptor-cache'
const createDiskCache = require('raptor-cache').createDiskCache; new createDiskCache(...)
Function, not constructor. DiskCache is also accessible via createCache with store:'disk'.

Creates a disk-backed cache with TTL and idle settings, then retrieves a value with a builder function.

import { createCache } from 'raptor-cache'; const cache = createCache({ store: 'disk', timeToLive: 10000, timeToIdle: 7000, freeDelay: 5000, dir: '.cache/my-cache', flushDelay: 1000, encoding: 'utf8' }); cache.get('hello', (callback) => { setTimeout(() => callback(null, 'world'), 1000); }, (err, value) => { console.log(value); // 'world' });
Debug
Known issues
gotchaThe disk store with separate files requires a directory that must be writable; if missing, the cache may fail silently.
fix
Ensure the configured directory exists before creating the cache or use the 'autoCreate' option (if available).
affects: >=2.0.0
breakingVersion 2.0.0 changed to ESM-only. CommonJS require() will return the module object, not the named exports directly.
fix
Use named imports: import { createCache } from 'raptor-cache' or use require('raptor-cache').createCache.
affects: >=2.0.0
deprecatedThe method 'raptorCache.createMemoryCache' is deprecated in favor of 'createCache({ store: 'memory' })'.
fix
Replace createMemoryCache(options) with createCache({ store: 'memory', ...options }).
affects: >=2.0.0
gotchaCache values in the combined file disk store cannot be null or undefined. Passing such values will cause errors.
fix
Ensure builder functions always return a truthy value or use a sentinel.
affects: >=0.1.0
Errors
Common errors & fixes
TypeError: createCache is not a function
Using import { createCache } from 'raptor-cache' in a CommonJS environment without transpilation, or using require incorrectly.
fix
If in CommonJS: const raptorCache = require('raptor-cache'); const createCache = raptorCache.createCache;
Error: ENOENT: no such file or directory, open '...'
The disk cache directory does not exist and auto-creation is disabled or not supported.
fix
Create the directory manually before initializing the cache, or use a different store like 'memory'.
Error: Cannot flush because cache is not dirty
Calling flush() when no modifications have been made since last flush.
fix
Check if the cache is dirty via cache.isDirty() before calling flush().
Upgrade
Version history
2.0.5latest on npm
Audit
Dependencies

No dependency data recorded yet.

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