connect-ioredis-store
v1.0.0
Published
ioredis session store for express session
Maintainers
Readme
connect-ioredis-store
A session store for express-session using ioredis.
Why?
connect-redis recently dropped
support for ioredis and now only works with the official node redis client.
If you're still using ioredis and want to keep using it, this library is
for you. It's designed to be an almost drop-in replacement for connect-redis.
Installation
npm install connect-ioredis-store express-session ioredisUsage
import session from "express-session";
import { Redis } from "ioredis";
import { IORedisStore } from "connect-ioredis-store";
const redis = new Redis();
app.use(
session({
store: new IORedisStore({
client: redis,
prefix: "myapp:"
}),
secret: "your-secret-key",
resave: false,
saveUninitialized: false
})
);Options
client(required): Your ioredis client instanceprefix: Key prefix in Redis (default:"sess:")ttl: Session TTL in seconds (default:86400- 24 hours). Can be a number or a function that returns a number based on the session dataserializer: Custom serializer (default:JSON). Must havestringifyandparsemethodsdisable_touch: Disable touch (default:false)disable_ttl: Disable TTL expiration (default:false)scan_count: Count option for Redis SCAN command (default:100)
Limitations
- No Redis Cluster support yet - Currently only works with standalone Redis instances. Cluster support is planned for a future release.
License
MIT
