Files
calendar/packages/features/redis/RedisService.ts
T
b4a51d3560 feat: auto lock (#18630)
* add delete to redis service

* auto lock + tests

* changes to autolock in api/book call

* remove log clutter

* add detection in api v1

* tpye changes

* throw error and add tests for API

* add response logic on locked + tests

* type response properly i hope?

* type fix

* add tests for counter not existing + redis errors

* remove IP - add sentry to track

* rename symbol

* fix type error

* fix tests

* remove sentry call spy

* fix type on sentry setUser call

---------

Co-authored-by: Alex van Andel <me@alexvanandel.com>
2025-01-18 16:21:12 -03:00

38 lines
1.0 KiB
TypeScript

import { Redis } from "@upstash/redis";
import type { IRedisService } from "./IRedisService";
export class RedisService implements IRedisService {
private redis: Redis;
constructor() {
this.redis = Redis.fromEnv();
}
async get<TData>(key: string): Promise<TData | null> {
return this.redis.get(key);
}
async del(key: string): Promise<number> {
return this.redis.del(key);
}
async set<TData>(key: string, value: TData): Promise<"OK" | TData | null> {
// Implementation for setting value in Redis
return this.redis.set(key, value);
}
async expire(key: string, seconds: number): Promise<0 | 1> {
// Implementation for setting expiration time for key in Redis
return this.redis.expire(key, seconds);
}
async lrange<TResult = string>(key: string, start: number, end: number): Promise<TResult[]> {
return this.redis.lrange(key, start, end);
}
async lpush<TData>(key: string, ...elements: TData[]): Promise<number> {
return this.redis.lpush(key, elements);
}
}