feat: enhance API and query handling with Redis caching; add QueryGuard for query validation; refactor services to utilize RedisClient for improved performance
This commit is contained in:
@ -12,7 +12,7 @@ export class RedisClient {
|
||||
|
||||
async set(
|
||||
key: string,
|
||||
value: string,
|
||||
value: any,
|
||||
expireInSeconds?: number
|
||||
): Promise<"OK" | null> {
|
||||
if (!this.redis) {
|
||||
@ -20,18 +20,23 @@ export class RedisClient {
|
||||
}
|
||||
|
||||
if (expireInSeconds) {
|
||||
return await this.redis.set(key, value, "EX", expireInSeconds);
|
||||
return await this.redis.set(
|
||||
key,
|
||||
JSON.stringify(value),
|
||||
"EX",
|
||||
expireInSeconds
|
||||
);
|
||||
}
|
||||
|
||||
return await this.redis.set(key, value);
|
||||
return await this.redis.set(key, JSON.stringify(value));
|
||||
}
|
||||
|
||||
async get(key: string): Promise<string | null> {
|
||||
async get(key: string): Promise<any | null> {
|
||||
if (!this.redis) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return await this.redis.get(key);
|
||||
return JSON.parse(await this.redis.get(key));
|
||||
}
|
||||
|
||||
async del(key: string): Promise<number | null> {
|
||||
|
||||
Reference in New Issue
Block a user