feat: implement Redis client and plugin with basic operations

This commit is contained in:
Boris D
2025-09-22 16:50:03 +03:00
parent 5fbaca4659
commit 51f8b0d773
3 changed files with 66 additions and 0 deletions

View File

@ -9,4 +9,40 @@ export class RedisClient {
constructor(private readonly redisService: RedisService) {
this.redis = this.redisService.getOrThrow();
}
async set(
key: string,
value: string,
expireInSeconds?: number
): Promise<"OK" | null> {
if (!this.redis) {
return null;
}
if (expireInSeconds) {
return await this.redis.set(key, value, "EX", expireInSeconds);
}
return await this.redis.set(key, value);
}
async get(key: string): Promise<string | null> {
if (!this.redis) {
return null;
}
return await this.redis.get(key);
}
async del(key: string): Promise<number | null> {
if (!this.redis) {
return null;
}
return await this.redis.del(key);
}
getClient(): Redis | null {
return this.redis;
}
}