Skip to content
This repository has been archived by the owner on May 24, 2024. It is now read-only.

Commit

Permalink
use ioredis instead of redis
Browse files Browse the repository at this point in the history
  • Loading branch information
Metauriel committed Mar 28, 2024
1 parent 6bfaf04 commit 43fc1b1
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 85 deletions.
145 changes: 68 additions & 77 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"@nestjs/platform-socket.io": "^10.3.3",
"@nestjs/websockets": "^10.3.3",
"@socket.io/redis-adapter": "^8.3.0",
"redis": "^4.6.13",
"ioredis": "^5.3.2",
"reflect-metadata": "^0.2.0",
"rxjs": "^7.8.1",
"socket.io": "^4.7.4",
Expand Down
9 changes: 2 additions & 7 deletions src/socket/socket/redis-adapter.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,13 @@
import { IoAdapter } from '@nestjs/platform-socket.io';
import { Redis } from "ioredis";
import { ServerOptions } from 'socket.io';
import { createAdapter } from '@socket.io/redis-adapter';
import { createClient } from 'redis';

export class RedisIoAdapter extends IoAdapter {
private adapterConstructor: ReturnType<typeof createAdapter>;

async connectToRedis(): Promise<void> {
if (process.env.REDIS_URI) {
console.log('found a secret redis uri')
} else {
console.log('did not find a secret redis uri')
}
const pubClient = createClient({ url: process.env.REDIS_URI || `redis://localhost:6379` });
const pubClient = new Redis(process.env.REDIS_URI || `redis://localhost:6379`);
const subClient = pubClient.duplicate();

await Promise.all([pubClient.connect(), subClient.connect()]);
Expand Down

0 comments on commit 43fc1b1

Please sign in to comment.