Registry / storage / mega-hybrid-cache

mega-hybrid-cache

JSON →
library1.0.31jsnpmunverified

A Node.js hybrid caching library combining LRU in-memory cache with file-based persistence for automatic fallback and data recovery across restarts. Current stable version 1.0.31, updated periodically. Key differentiator: seamless integration of memory and disk caching without manual sync, suitable for read-heavy workloads where cache durability matters.

npm install mega-hybrid-cache
INSTALL
IMPORT
SIG · MEGA-HYBRID-CACHE
M
mega-hybrid-cache
storagejavascriptv1.0.31
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.

HybridCache
import HybridCache from 'mega-hybrid-cache'
const HybridCache = require('mega-hybrid-cache')
Default export only; CommonJS require not supported
default
import HybridCache from 'mega-hybrid-cache'
import { HybridCache } from 'mega-hybrid-cache'
This package uses default export, not named export
type definitions
npm install --save-dev @types/mega-hybrid-cache
Types are not bundled; need separate @types package

Initializes a hybrid cache with memory limit and file path, sets, gets, and deletes a value.

import HybridCache from 'mega-hybrid-cache'; const cache = new HybridCache({ memoryMaxSize: 100, filePath: './cache/data.json', ttl: 60000 }); async function main() { await cache.set('key', { value: 'example' }); const val = await cache.get('key'); console.log(val); await cache.del('key'); } main().catch(console.error);
Debug
Known issues
gotchaFile cache path must exist or be writable; error on creation not handled internally.
fix
Ensure directory exists or use absolute path in system temp.
affects: all
deprecatedset() and get() are async but return promises; missing await leads to silent failures.
fix
Always use await or .then() when calling async methods.
affects: >=1.0.0
gotchaMemory cache is LRU with max size; exceeding size evicts least recently used item silently.
fix
Monitor cache size via cache.size property or set appropriate memoryMaxSize.
affects: all
gotchaFile cache persists data as JSON; non-serializable values (e.g., undefined, functions) will cause errors.
fix
Only store JSON-serializable values.
affects: all
breakingIn v1.0.0, the constructor argument changed from single object to options object.
fix
Update constructor call to pass { memoryMaxSize, filePath, ttl }.
affects: <1.0.0
Errors
Common errors & fixes
TypeError: HybridCache is not a constructor
CommonJS require used instead of ESM import.
fix
Use import HybridCache from 'mega-hybrid-cache'
Error: ENOENT: no such file or directory, open '...'
File cache directory does not exist.
fix
Create directory or use existing path.
TypeError: Converting circular structure to JSON
Attempting to cache a circular object.
fix
Store a serializable copy or use a library like flatted.
Upgrade
Version history
1.0.31latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
21 hits · last 30 days
node
20
OpenAI (training)
1
Resources
mega-hybrid-cache — npm install mega-hybrid-cache · libregistry