Registry / database / typeorm-cache

typeorm-cache

JSON →
library1.1.3jsnpmunverified

A TypeORM cache provider backed by keyv, enabling pluggable cache storage (memory, Redis, MongoDB, etc.) for TypeORM v0.2.x. Version 1.1.3 is the latest stable release; the package is mature with no frequent updates. Unlike built-in TypeORM cache (only supports redis or ioredis), this library leverages keyv's adapter ecosystem, supporting multiple backends with a unified API. Ships TypeScript definitions and requires keyv v4 and TypeORM v0.2 as peer dependencies.

npm install typeorm-cache
INSTALL
IMPORT
SIG · TYPEORM-CACHE
T
typeorm-cache
databasejavascriptv1.1.3
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.

KeyvCacheProvider
✓ import { KeyvCacheProvider } from 'typeorm-cache'
✗ const KeyvCacheProvider = require('typeorm-cache')
Named export, ESM-style import recommended. Package supports CommonJS require but returns { KeyvCacheProvider }.
KeyvCacheProvider
✓ import { KeyvCacheProvider } from 'typeorm-cache'
✗ import KeyvCacheProvider from 'typeorm-cache'
Default import does not exist; must use named import.
createConnection
✓ import { createConnection } from 'typeorm'
Not from this package; shown for context.

Basic TypeORM connection using KeyvCacheProvider with optional Redis URL from environment variable.

import { createConnection } from 'typeorm' import { KeyvCacheProvider } from 'typeorm-cache' createConnection({ type: 'postgres', host: process.env.DB_HOST ?? 'localhost', port: Number(process.env.DB_PORT) || 5432, username: process.env.DB_USER ?? 'test', password: process.env.DB_PASS ?? '', database: process.env.DB_NAME ?? 'test', entities: [/* your entities */], cache: { provider() { return new KeyvCacheProvider(process.env.REDIS_URL ?? '') } } }).then(() => console.log('Connected with cache'))
Debug
Known issues
breakingKeyvCacheProvider requires keyv v4 and typeorm >=0.2.0 but <0.3.0
fix
Ensure keyv@4 and typeorm@~0.2.x are installed. Not compatible with TypeORM v0.3+.
affects: >=1.0.0
gotchaCalling new KeyvCacheProvider() with no URI defaults to in-memory store; no data persistence across restarts
fix
Provide a URI like 'redis://...' for persistent caching.
affects: >=1.0.0
deprecatedPackage last updated in 2021; no explicit deprecation but TypeORM v0.3 has breaking API changes
fix
Consider switching to TypeORM's built-in cache or an alternative if using TypeORM 0.3+.
affects: >=1.1.0
Errors
Common errors & fixes
TypeError: Class extends value undefined is not a constructor or null
Missing peer dependency keyv or incompatible version
fix
Install compatible keyv: npm install keyv@4
DataError: keyvURI must be a string or an object
Passing a boolean/undefined as constructor argument
fix
Use new KeyvCacheProvider(undefined) or new KeyvCacheProvider() for default memory store
Upgrade
Version history
1.1.3latest on npm
Audit
Dependencies
keyvrequiredPeer dependency; core caching backend
typeormrequiredPeer dependency; the ORM requiring cache provider
Agent activity
17 hits · last 30 days
node
14
Amazon
1
OpenAI (training)
1
Resources
typeorm-cache — npm install typeorm-cache · libregistry