Release 2025-05-19

This commit is contained in:
pluja
2025-05-19 10:19:49 +00:00
parent 046c4559e5
commit 2657f936bc
267 changed files with 0 additions and 49432 deletions

View File

@@ -1,45 +0,0 @@
import { REDIS_URL } from 'astro:env/server'
import { createClient } from 'redis'
type RedisGenericManagerOptions = {
expirationTime: number
}
export abstract class RedisGenericManager {
protected redisClient
/** The expiration time of the Redis session. In seconds. */
readonly expirationTime: number
/** @deprecated Use {@link createAndConnect} instead */
constructor(options: RedisGenericManagerOptions) {
this.redisClient = createClient({
url: REDIS_URL,
})
this.expirationTime = options.expirationTime
this.redisClient.on('error', (err) => {
console.error(`[${this.constructor.name}] `, err)
})
}
/** Closes the Redis connection */
async close(): Promise<void> {
await this.redisClient.quit()
}
/** Connects to the Redis connection */
async connect(): Promise<void> {
await this.redisClient.connect()
}
static async createAndConnect<T extends RedisGenericManager>(
this: new (options: RedisGenericManagerOptions) => T,
options: RedisGenericManagerOptions
): Promise<T> {
const instance = new this(options)
await instance.connect()
return instance
}
}