Registry / database / sequelize-transparent-cache-ioredis

sequelize-transparent-cache-ioredis

JSON →
library2.3.0jsnpmunverified

This package is an adapter for sequelize-transparent-cache that uses ioredis as the caching backend. Version 2.3.0 is stable and compatible with sequelize-transparent-cache v2+. It stores Sequelize model instances as JSON strings in Redis, with optional namespace prefix and TTL. Unlike other adapters, it directly integrates with ioredis, providing robust Redis features like clustering and Sentinel. Release cadence is low; updates follow ioredis major versions.

npm install sequelize-transparent-cache-ioredis
INSTALL
IMPORT
SIG · SEQUELIZE-TRANSPAR
S
sequelize-transparent-cache-ioredis
databasejavascriptv2.3.0
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.

default
import RedisAdaptor from 'sequelize-transparent-cache-ioredis'
const { RedisAdaptor } = require('sequelize-transparent-cache-ioredis')
The package exports a single default class. Named import will fail. CommonJS require gets the default, but destructuring does not work.
RedisAdaptor
const RedisAdaptor = require('sequelize-transparent-cache-ioredis')
const RedisAdaptor = require('sequelize-transparent-cache-ioredis').default
CJS require returns the constructor directly; no .default needed.
RedisAdaptor (ESM with namespace)
import * as pkg from 'sequelize-transparent-cache-ioredis'; const RedisAdaptor = pkg.default
import { RedisAdaptor } from 'sequelize-transparent-cache-ioredis'
No named export exists; must use namespace import and access .default.

Shows how to set up the ioredis adapter with sequelize-transparent-cache and cache a Sequelize model.

const Redis = require('ioredis'); const redis = new Redis({ host: 'localhost', port: 6379 }); const Sequelize = require('sequelize'); const sequelize = new Sequelize('sqlite::memory:'); const RedisAdaptor = require('sequelize-transparent-cache-ioredis'); const cacheAdaptor = new RedisAdaptor({ client: redis, namespace: 'myapp', lifetime: 3600 }); const { init } = require('sequelize-transparent-cache'); const { withCache } = init(cacheAdaptor); const User = sequelize.define('User', { name: Sequelize.STRING }); const CachedUser = withCache(User); (async () => { await sequelize.sync(); const user = await CachedUser.create({ name: 'Alice' }); console.log('User cached in Redis'); })();
Debug
Known issues
gotchaThe adapter expects an ioredis instance; providing a Redis client from another library will fail at runtime.
fix
Use `new Redis()` from the `ioredis` package, not `redis` or `node-redis`.
affects: >=1.0.0
deperecatedThe package does not follow semantic versioning strictly; minor versions may introduce breaking changes if peer dependencies change.
fix
Pin to exact version or test upgrades carefully.
affects: >=2.0.0
gotchaNamespace must not contain colon ':' as it is used as delimiter; otherwise keys may collide or be ambiguous.
fix
Avoid colons in namespace string.
affects: >=1.0.0
gotchalifetime is set per adapter instance, not per model; all cached objects share the same TTL unless overridden at query level.
fix
If per-model TTL needed, consider multiple adapters or custom logic.
affects: >=1.0.0
Errors
Common errors & fixes
TypeError: RedisAdaptor is not a constructor
Importing the module incorrectly, e.g., using named import when it's a default export.
fix
Use `const RedisAdaptor = require('sequelize-transparent-cache-ioredis')` or `import RedisAdaptor from ...`.
Error: Invalid client provided. Expected ioredis instance.
Passing a Redis client from a different library (e.g., `redis` package) or not passing a client at all.
fix
Ensure the client is created via `new Redis()` from the `ioredis` package.
Error: connect ECONNREFUSED 127.0.0.1:6379
No Redis server running or wrong host/port.
fix
Start a Redis server or configure ioredis with correct connection options.
Upgrade
Version history
2.3.0latest on npm
Audit
Dependencies
sequelize-transparent-cacherequiredPeer dependency; this adapter requires the core caching library.
ioredisrequiredPeer dependency; the Redis client instance must be provided.
Agent activity
18 hits · last 30 days
node
14
Meta
2
Resources
sequelize-transparent-cache-ioredis — npm install sequelize-transparent-cache-ioredis · libregistry