socketio / socket.io-admin-ui

Admin UI for Socket.IO

Home Page:https://admin.socket.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

RedisClient library used for RedisStore

afrancis-caregility opened this issue · comments

I am trying to use the RedisStore for sessionId storage and I am not seeing any entry in RedisDB for this. So, I want to know which RedisClient is being used to insert key in RedisDB.
I use "ioredis": "^5.2.5" in my nodejs application. The admin UI is working correctly. I was expecting an entry in Redis but not seeing one. So, I want to understand this a little better.

Hi! We use redis@3:

"redis": "^3.0.2",

Not sure the ioredis package supports the syntax here:

export class RedisStore extends Store {
private options: RedisStoreOptions;
constructor(readonly redisClient: any, options?: Partial<RedisStoreOptions>) {
super();
this.options = Object.assign(
{
prefix: "socket.io-admin",
sessionDuration: 86400,
},
options
);
}
private computeKey(sessionId: string) {
return `${this.options.prefix}#${sessionId}`;
}
doesSessionExist(sessionId: string): Promise<boolean> {
return new Promise((resolve, reject) => {
this.redisClient.exists(
this.computeKey(sessionId),
(err: Error | null, result: any) => {
if (err) {
reject(err);
} else {
resolve(result === 1);
}
}
);
});
}
saveSession(sessionId: string) {
const key = this.computeKey(sessionId);
this.redisClient
.multi()
.set(key, true)
.expire(key, this.options.sessionDuration)
.exec();
}
}

But you should be able to write your own store by extending the Store class.