Registry / storage / think-cache-file

think-cache-file

JSON →
library1.1.2jsnpmunverified

File cache adapter for ThinkJS framework (v1.1.2, stable). Provides a file-based caching mechanism with configurable cache path, depth, and garbage collection interval. Designed specifically for ThinkJS's cache system. Alternative to in-memory or database caches. No longer maintained alongside ThinkJS's evolution.

npm install think-cache-file
INSTALL
IMPORT
SIG · THINK-CACHE-FILE
T
think-cache-file
storagejavascriptv1.1.2
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.

fileCache
const fileCache = require('think-cache-file');
CommonJS require; library does not have ESM exports.
fileCache (ESM)
import fileCache from 'think-cache-file';
import { fileCache } from 'think-cache-file';
Default export; named import will fail.
config export
const fileCache = require('think-cache-file'); module.exports.cache = { type: 'file', file: { handle: fileCache } }
import { cache } from 'think-cache-file';
The package exports a constructor/class, not a config object.

Instantiates file cache adapter, sets and retrieves a cached value.

const fileCache = require('think-cache-file'); const cache = new fileCache({ cachePath: '/tmp/cache', pathDepth: 1, timeout: 60000 }); await cache.set('key', { data: 'value' }); const value = await cache.get('key'); console.log(value); // { data: 'value' }
Debug
Known issues
gotchacachePath must be an absolute path; relative paths cause silent failures
fix
Provide absolute path like '/home/user/data' or use path.resolve().
affects: >=0.0.0
deprecatedThinkJS v3+ no longer uses this adapter; use think-cache-file or migrate to other cache adapters
fix
Use think-cache-file if still on ThinkJS 3, or migrate to think-model-cache or other solutions.
affects: >=3.0.0
gotchagcInterval defaults to undefined; no garbage collection runs unless set
fix
Explicitly set gcInterval in config, e.g., 24*60*60*1000 for daily cleanup.
affects: >=0.0.0
gotchapathDepth controls subdirectory nesting; depth > 2 can cause performance issues with many files
fix
Keep pathDepth low (0-2). Use 0 for flat directory.
affects: >=0.0.0
breakingv1.0.0 changed timeout from seconds to milliseconds
fix
Ensure timeout values are in milliseconds (e.g., 60000 for 1 minute).
affects: >=1.0.0
Errors
Common errors & fixes
TypeError: fileCache is not a constructor
Using named import instead of default import in ES6 module context
fix
Use `import fileCache from 'think-cache-file';`
Error: ENOENT: no such file or directory, open '...'
cachePath directory does not exist or is not writable
fix
Create the directory manually or ensure it exists before starting the app.
fileCache is not a function
Using `fileCache()` as function call instead of `new fileCache()`
fix
Use `new fileCache(options)` to instantiate.
Upgrade
Version history
1.1.2latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
29 hits · last 30 days
node
26
Resources
think-cache-file — npm install think-cache-file · libregistry