Registry / storage / think-cache

think-cache

JSON →
library1.1.2jsnpmunverified

think-cache is a caching middleware for ThinkJS 3.x, version 1.1.2, providing in-memory and file-based caching with a simple API. It integrates seamlessly with ThinkJS controllers and services, leveraging ES6+ features and TypeScript types. Released on a maintenance cycle, it is not actively developed and deprecated in favor of newer caching solutions like lru-cache or node-cache. Differentiators include its tight coupling with ThinkJS's ecosystem and trivial setup for rapid prototyping.

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

Cache
import Cache from 'think-cache'
const Cache = require('think-cache')
ESM-only. CommonJS require may work but is not guaranteed for all bundlers.
Cache
import { Cache } from 'think-cache'
Named export available for tree-shaking but default import is preferred.
getCache
import { getCache } from 'think-cache'
const getCache = require('think-cache').getCache
Named utility function; ESM required.

Demonstrates creating a file-based cache instance, setting and getting a value, then removing it.

import Cache from 'think-cache'; const cache = new Cache({ type: 'file', prefix: 'myapp', timeout: 3600 }); await cache.set('key', 'value'); const value = await cache.get('key'); console.log(value); // 'value' await cache.rm('key');
Debug
Known issues
deprecatedThe package is deprecated and no longer actively maintained. Use modern alternatives like lru-cache or node-cache.
fix
Replace with lru-cache or node-cache.
affects: >=0.0.0
breakingBreaking change in v1.0.0: renamed from think-cache@0.x to think-cache@1.x with API changes (removed synchronous methods).
fix
Update all cache calls to use async/await or Promises.
affects: >=1.0.0 <2.0.0
gotchaFile cache type may cause permission issues on shared hosting environments.
fix
Set proper write permissions or switch to memory cache.
affects: >=0.0.0
gotchaMemory cache is not shared across Node.js cluster workers; each worker has its own cache store.
fix
Use a centralized caching solution like Redis for clustered environments.
affects: >=0.0.0
Errors
Common errors & fixes
Cannot find module 'think-cache'
Package not installed or ESM module resolution issue.
fix
Run npm install think-cache and ensure you are using ESM imports.
this.cache is not a function
Missing await or not calling Cache constructor with new.
fix
Use await (new Cache()).get(...) or ensure you await the initialization.
TypeError: cache.set is not a function
Using CommonJS require instead of ESM import.
fix
Replace const cache = require('think-cache') with import cache from 'think-cache'.
Upgrade
Version history
1.1.2latest on npm
Audit
Dependencies
thinkjsoptionalRuntime peer dependency required for integration with ThinkJS application context.
Agent activity
27 hits · last 30 days
node
26
OpenAI (training)
1
Resources
think-cache — npm install think-cache · libregistry