Skip to main content

Redis Cluster Adapter

Package: @nauth-toolkit/storage-redis Type: Storage Adapter (Production HA)

High-availability Redis Cluster storage for production deployments.

npm install @nauth-toolkit/storage-redis redis

Usage

import { createCluster } from 'redis';
import { RedisStorageAdapter } from '@nauth-toolkit/storage-redis';

const clusterClient = createCluster({
rootNodes: [
{ url: 'redis://node1:6379' },
{ url: 'redis://node2:6379' },
{ url: 'redis://node3:6379' },
],
});
await clusterClient.connect();

AuthModule.forRoot({
storageAdapter: new RedisStorageAdapter(clusterClient),
})

Or with factory:

import { createRedisClusterAdapter } from '@nauth-toolkit/nestjs';

AuthModule.forRoot({
storageAdapter: createRedisClusterAdapter([
{ url: 'redis://node1:6379' },
{ url: 'redis://node2:6379' },
{ url: 'redis://node3:6379' },
]),
})

Features

  • High availability (automatic failover)
  • Horizontal scaling
  • Same RedisStorageAdapter class as single instance
  • Uses createCluster() instead of createClient()