Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RedisClient library used for RedisStore #62

Open
afrancis-caregility opened this issue Jan 31, 2023 · 1 comment
Open

RedisClient library used for RedisStore #62

afrancis-caregility opened this issue Jan 31, 2023 · 1 comment
Labels
question Further information is requested

Comments

@afrancis-caregility
Copy link

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.

@darrachequesne
Copy link
Member

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.

@darrachequesne darrachequesne added the question Further information is requested label Feb 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants