Registry / database / cachified-redis-adapter

cachified-redis-adapter

JSON →
library2.0.2jsnpmunverified

cachified-redis-adapter is a Redis cache adapter for @epic-web/cachified, extracted into its own package to avoid breaking changes in the core library. Current stable version is 2.0.2, requiring Node >=16 and @epic-web/cachified ^5.0.0. It ships TypeScript types and is maintained by the community. Unlike the bundled adapters in older cachified versions, this package allows independent versioning. It provides a simple redisCacheAdapter function that wraps a Redis client. For JSON data, consider the companion cachified-redis-json-adapter.

npm install cachified-redis-adapter
INSTALL
IMPORT
SIG · CACHIFIED-REDIS-AD
C
cachified-redis-adapter
databasejavascriptv2.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.

redisCacheAdapter
import { redisCacheAdapter } from 'cachified-redis-adapter'
const redisCacheAdapter = require('cachified-redis-adapter')
ESM-only, ship with TypeScript types. CommonJS require is not supported.
redisCacheAdapter (default)
import redisCacheAdapter from 'cachified-redis-adapter'
import { default as redisCacheAdapter } from 'cachified-redis-adapter'
There is no default export; only named export 'redisCacheAdapter' is available.
redisCacheAdapter type
import type { CacheEntry } from '@epic-web/cachified'
Types for the adapter itself are not separately exported; cachified types are used.

Creates a Redis client, wraps it with redisCacheAdapter, and uses it with cachified to cache a value.

import { createClient } from 'redis' import { redisCacheAdapter } from 'cachified-redis-adapter' const redis = createClient({ url: process.env.REDIS_URL ?? 'redis://localhost:6379' }) await redis.connect() const cache = redisCacheAdapter(redis) import { cachified } from '@epic-web/cachified' const value = await cachified({ cache, key: 'user-1', getFreshValue: () => Promise.resolve('user@example.org'), ttl: 60_000 }) console.log(value)
Debug
Known issues
breakingRequires @epic-web/cachified ^2.0.0 or later. Older versions are incompatible.
fix
Update @epic-web/cachified to >=2.0.0.
affects: <=1.0.0
gotchaThe adapter does not handle Redis connection failures or reconnection logic. If Redis is unavailable, operations will throw.
fix
Implement custom error handling and reconnection strategy on the Redis client.
affects: *
gotchaThe adapter serializes all cache entries using JSON.stringify/JSON.parse. Custom types or circular references will cause errors.
fix
Ensure values are JSON-serializable or use cachified-redis-json-adapter for JSON-specific handling.
affects: *
gotchaRedis client must be explicitly connected before passing to the adapter. Connection is not managed internally.
fix
Call redis.connect() before creating the cache adapter.
affects: *
Errors
Common errors & fixes
Error: Cannot find module 'cachified-redis-adapter'
Package not installed or Node.js version <16.
fix
Run npm install cachified-redis-adapter and ensure Node >=16.
TypeError: redisCacheAdapter is not a function
Using default import instead of named import.
fix
Use import { redisCacheAdapter } from 'cachified-redis-adapter'.
TypeError: redis.createClient is not a function
Incorrect import of redis package.
fix
Use import { createClient } from 'redis'.
Upgrade
Version history
2.0.2latest on npm
Audit
Dependencies
@epic-web/cachifiedrequiredPeer dependency required to provide the cache interface
redisrequiredRequired to create a Redis client instance passed to the adapter
Agent activity
16 hits · last 30 days
node
12
OpenAI (training)
1
Resources
cachified-redis-adapter — npm install cachified-redis-adapter · libregistry