Registry / storage / cachefactory

cachefactory

JSON →
library3.0.0jsnpmunverified

A simple synchronous key-value cache for the browser that supports TTL-based expiration with aggressive deletion, localStorage persistence, and manual cache management. Version 3.0.0 is the latest stable release, last updated in 2017. Key differentiators: minimalistic API, synchronous operations, optional localStorage backing, and automatic expiration recycling. The package ships TypeScript types. Maintenance is low, with no recent updates.

npm install cachefactory
INSTALL
IMPORT
SIG · CACHEFACTORY
C
cachefactory
storagejavascriptv3.0.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.

CacheFactory
import { CacheFactory } from 'cachefactory'
const CacheFactory = require('cachefactory')
ESM-only since v3
CacheFactory
import CacheFactory from 'cachefactory'
const CacheFactory = require('cachefactory'); const cacheFactory = new CacheFactory()
Default import also works in TypeScript with esModuleInterop
Cache
import { Cache } from 'cachefactory'
import { CacheFactory } from 'cachefactory'; const cache = new Cache()
Cache is exported as a named interface/class for TypeScript types

Shows basic setup: creating a cache with expiration, storing/retrieving an object, and cleanup.

import { CacheFactory } from 'cachefactory'; const cacheFactory = new CacheFactory(); let cache; if (!cacheFactory.exists('my-cache')) { cache = cacheFactory.createCache('my-cache', { deleteOnExpire: 'aggressive', recycleFreq: 60000 }); } else { cache = cacheFactory.getCache('my-cache'); } cache.put('/books/1', { title: 'BookOne', id: 1 }); const book = cache.get('/books/1'); console.log(book); cache.remove('/books/1'); cacheFactory.destroy('my-cache');
Debug
Known issues
deprecatedCacheFactory is no longer actively maintained. Last publish in 2017. Consider using lru-cache or quick-lru for newer projects.
fix
Migrate to a maintained library like lru-cache.
affects: >=3.0.0
gotchaUsing require('cachefactory') returns the module with default export? Actually, v3 is ESM-only; require will throw an error.
fix
Use import syntax or enable esModuleInterop in TypeScript and use default import.
affects: >=3.0.0
breakingVersion 3.0.0 removed support for CommonJS require. Only ES modules are supported.
fix
Update imports to ES module syntax.
affects: >=3.0.0
Errors
Common errors & fixes
ERR_REQUIRE_ESM: require() of ES Module
Trying to use require() with an ES module package.
fix
Use import syntax: import { CacheFactory } from 'cachefactory'; or enable ESM in your project.
Cannot find module 'cachefactory'
Package not installed or incorrect path.
fix
Run npm install cachefactory --save
TypeError: cacheFactory.createCache is not a function
Importing default export incorrectly (e.g., using CacheFactory from default export without new).
fix
Ensure you import { CacheFactory } from 'cachefactory' and instantiate: new CacheFactory()
Upgrade
Version history
3.0.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
31 hits · last 30 days
node
30
Resources
cachefactory — npm install cachefactory · libregistry