made a mess

This commit is contained in:
Boki 2025-06-10 12:34:12 -04:00
parent 1caa2d5168
commit f52e3332df
5 changed files with 55 additions and 30 deletions

View file

@ -22,13 +22,15 @@ export class RedisCache implements CacheProvider {
hitRate: 0,
total: 0,
uptime: 0
};
constructor(options: CacheOptions = {}) {
}; constructor(options: CacheOptions = {}) {
this.defaultTTL = options.ttl ?? 3600; // 1 hour default
this.keyPrefix = options.keyPrefix ?? 'cache:';
this.enableMetrics = options.enableMetrics ?? true;
// Generate a connection name for monitoring
const baseName = options.name || this.keyPrefix.replace(':', '-').replace(/[^a-zA-Z0-9-]/g, '');
const connectionName = `${baseName}-${Date.now()}`;
const redisConfig = {
host: dragonflyConfig.DRAGONFLY_HOST,
port: dragonflyConfig.DRAGONFLY_PORT,
@ -40,6 +42,7 @@ export class RedisCache implements CacheProvider {
connectTimeout: dragonflyConfig.DRAGONFLY_CONNECT_TIMEOUT,
commandTimeout: dragonflyConfig.DRAGONFLY_COMMAND_TIMEOUT,
keepAlive: dragonflyConfig.DRAGONFLY_ENABLE_KEEPALIVE ? dragonflyConfig.DRAGONFLY_KEEPALIVE_INTERVAL * 1000 : 0,
connectionName, // Add connection name for monitoring
...(dragonflyConfig.DRAGONFLY_TLS && {
tls: {
cert: dragonflyConfig.DRAGONFLY_TLS_CERT_FILE || undefined,

View file

@ -26,6 +26,7 @@ export interface CacheOptions {
enableMetrics?: boolean;
maxMemoryItems?: number;
memoryTTL?: number;
name?: string; // Add name for connection identification
}
export interface CacheStats {