made a mess
This commit is contained in:
parent
1caa2d5168
commit
f52e3332df
5 changed files with 55 additions and 30 deletions
9
libs/cache/src/providers/redis-cache.ts
vendored
9
libs/cache/src/providers/redis-cache.ts
vendored
|
|
@ -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,
|
||||
|
|
|
|||
1
libs/cache/src/types.ts
vendored
1
libs/cache/src/types.ts
vendored
|
|
@ -26,6 +26,7 @@ export interface CacheOptions {
|
|||
enableMetrics?: boolean;
|
||||
maxMemoryItems?: number;
|
||||
memoryTTL?: number;
|
||||
name?: string; // Add name for connection identification
|
||||
}
|
||||
|
||||
export interface CacheStats {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue