Registry /
database / sequelize-transparent-cache-ioredis
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');
})();
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.
fixUse `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.
fixEnsure 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.
fixStart a Redis server or configure ioredis with correct connection options.
Audit
Dependencies
sequelize-transparent-cacherequiredPeer dependency; this adapter requires the core caching library.
ioredisrequiredPeer dependency; the Redis client instance must be provided.