Registry / database / typeorm-in-memory-cache

typeorm-in-memory-cache

JSON →
library1.0.2jsnpmunverified

Provides an in-memory cache provider for TypeORM, wrapping node-cache. Version 1.0.2 is the latest stable release. This package is a thin wrapper around node-cache, offering simplicity and minimal configuration. It is suitable for development or single-process applications, but lacks distributed cache features found in alternatives like ioredis or redis. No significant release cadence; appears unmaintained since 2020.

npm install typeorm-in-memory-cache
INSTALL
IMPORT
SIG · TYPEORM-IN-MEMORY-
T
typeorm-in-memory-cache
databasejavascriptv1.0.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.

InMemoryCacheProvider
✓ import InMemoryCacheProvider from 'typeorm-in-memory-cache'
✗ const InMemoryCacheProvider = require('typeorm-in-memory-cache')
Default export; CJS require works but TypeScript may prefer ESM import with default.
InMemoryCacheProvider
✓ import { InMemoryCacheProvider } from 'typeorm-in-memory-cache'
✗ import { InMemoryCacheProvider } from 'typeorm-in-memory-cache'
Named import also works as the package has a named export alias, but default is more common.
NodeCache
✓ import NodeCache from 'node-cache'
✗ const NodeCache = require('node-cache');
If customizing node-cache options, import NodeCache separately. The wrapper accepts an optional NodeCache instance.

Shows how to configure TypeORM to use the in-memory cache provider with a default node-cache instance.

import InMemoryCacheProvider from 'typeorm-in-memory-cache'; import { DataSource } from 'typeorm'; const AppDataSource = new DataSource({ type: 'sqlite', database: ':memory:', entities: [], synchronize: true, cache: { duration: 60000, provider() { return new InMemoryCacheProvider(); } } }); AppDataSource.initialize().then(() => { console.log('Data Source has been initialized!'); }).catch((err) => { console.error('Error during Data Source initialization', err); });
Debug
Known issues
gotchaThe cache is in-memory and not shared across processes/instances. For clustered or multi-process applications, use a distributed cache like Redis.
fix
Consider using typeorm's Redis or ioredis cache provider for distributed setups.
affects: >=0.0.0
gotchaThe package is a thin wrapper around node-cache; node-cache is not included as a dependency but as a peer dependency? Actually, node-cache is a transitive dependency of typeorm-in-memory-cache, but ensure node-cache is installed.
fix
Run npm install node-cache if you encounter errors.
affects: >=0.0.0
deprecatedThe package has not been updated since 2020 and may not be compatible with future TypeORM versions. TypeORM 0.3.x introduced breaking changes in cache API.
fix
Check TypeORM version compatibility; use with TypeORM 0.2.x only. For 0.3.x, consider using TypeORM's built-in caching or another cache provider.
affects: >=1.0.0
Errors
Common errors & fixes
ERR_REQUIRE_ESM: require() of ES Module not supported
Using CommonJS require() when package is ESM-only or has default export that is an ES module.
fix
Use import statement or set type: 'module' in package.json.
TypeError: InMemoryCacheProvider is not a constructor
Possibly due to incorrect import (e.g., importing named export when only default exists) or module resolution issue.
fix
Ensure import statement is correct: import InMemoryCacheProvider from 'typeorm-in-memory-cache';
Cannot find module 'node-cache'
node-cache is a dependency of typeorm-in-memory-cache, but may not be installed if npm did not resolve automatically.
fix
Run npm install node-cache to explicitly install it.
Upgrade
Version history
1.0.2latest on npm
Audit
Dependencies
typeormrequiredPeer dependency; required to use the cache provider with TypeORM
Agent activity
18 hits · last 30 days
node
14
OpenAI (training)
2
Amazon
1
Resources
typeorm-in-memory-cache — npm install typeorm-in-memory-cache · libregistry