19 lines
538 B
TypeScript
19 lines
538 B
TypeScript
import type { CacheService } from "@trigger.dev/integration-sdk";
|
|
import { redis } from "./redis.server";
|
|
|
|
export class RedisCacheService implements CacheService {
|
|
constructor(private readonly namespace: string) {}
|
|
|
|
async get(key: string) {
|
|
return redis.get(`${this.namespace}:${key}`);
|
|
}
|
|
|
|
async set(key: string, value: string, ttl?: number): Promise<void> {
|
|
if (ttl) {
|
|
await redis.set(`${this.namespace}:${key}`, value, "EX", ttl);
|
|
} else {
|
|
await redis.set(`${this.namespace}:${key}`, value);
|
|
}
|
|
}
|
|
}
|