commit 2 refactor
This commit is contained in:
parent
588f666943
commit
32e43c9243
310 changed files with 33318 additions and 31189 deletions
12
libs/core/cache/src/redis-cache.ts
vendored
12
libs/core/cache/src/redis-cache.ts
vendored
|
|
@ -8,18 +8,10 @@ import type { CacheOptions, CacheProvider, CacheStats } from './types';
|
|||
*/
|
||||
export class RedisCache implements CacheProvider {
|
||||
private redis: Redis;
|
||||
private logger: { info?: (...args: unknown[]) => void; error?: (...args: unknown[]) => void } =
|
||||
console;
|
||||
private logger: NonNullable<CacheOptions['logger']>;
|
||||
private defaultTTL: number;
|
||||
private keyPrefix: string;
|
||||
private stats: CacheStats = {
|
||||
hits: 0,
|
||||
misses: 0,
|
||||
errors: 0,
|
||||
hitRate: 0,
|
||||
total: 0,
|
||||
uptime: 0,
|
||||
};
|
||||
private stats: CacheStats = { hits: 0, misses: 0, errors: 0, hitRate: 0, total: 0, uptime: 0 };
|
||||
private startTime = Date.now();
|
||||
|
||||
constructor(options: CacheOptions) {
|
||||
|
|
|
|||
9
libs/core/cache/src/types.ts
vendored
9
libs/core/cache/src/types.ts
vendored
|
|
@ -1,3 +1,5 @@
|
|||
import type { LoggerLike } from '@stock-bot/logger';
|
||||
|
||||
export interface RedisConfig {
|
||||
host: string;
|
||||
port: number;
|
||||
|
|
@ -113,12 +115,7 @@ export interface CacheOptions {
|
|||
name?: string; // Name for connection identification
|
||||
shared?: boolean; // Whether to use shared connection
|
||||
redisConfig: RedisConfig;
|
||||
logger?: {
|
||||
info?: (...args: unknown[]) => void;
|
||||
error?: (...args: unknown[]) => void;
|
||||
warn?: (...args: unknown[]) => void;
|
||||
debug?: (...args: unknown[]) => void;
|
||||
};
|
||||
logger?: Partial<LoggerLike>;
|
||||
}
|
||||
|
||||
export interface CacheStats {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue