File tree Expand file tree Collapse file tree 3 files changed +50
-8
lines changed
Expand file tree Collapse file tree 3 files changed +50
-8
lines changed Original file line number Diff line number Diff line change 1+ export class CacheError extends Error {
2+ constructor ( message : string , public readonly code ?: string ) {
3+ super ( message ) ;
4+ this . name = 'CacheError' ;
5+ }
6+ }
7+
8+ export class CacheConnectionError extends CacheError {
9+ constructor ( message : string ) {
10+ super ( message , 'CONNECTION_ERROR' ) ;
11+ this . name = 'CacheConnectionError' ;
12+ }
13+ }
14+
15+ export class CacheOperationError extends CacheError {
16+ constructor ( message : string , operation : string ) {
17+ super ( message , `OPERATION_ERROR_${ operation . toUpperCase ( ) } ` ) ;
18+ this . name = 'CacheOperationError' ;
19+ }
20+ }
Original file line number Diff line number Diff line change 1+ export interface CacheConfig {
2+ host : string ;
3+ port : number ;
4+ password ?: string ;
5+ db ?: number ;
6+ keyPrefix ?: string ;
7+ maxSize ?: number ;
8+ defaultTTL ?: number ;
9+ strategy ?: 'lru' | 'ttl' | 'combined' ;
10+ }
11+
12+ export interface CacheMetadata {
13+ key : string ;
14+ size : number ;
15+ createdAt : number ;
16+ lastAccessed : number ;
17+ accessCount : number ;
18+ ttl ?: number ;
19+ expiresAt ?: number ;
20+ }
21+
22+ export interface ICache {
23+ get < T > ( key : string ) : Promise < T | null > ;
24+ set < T > ( key : string , value : T , ttlSeconds ?: number ) : Promise < void > ;
25+ delete ( key : string ) : Promise < boolean > ;
26+ exists ( key : string ) : Promise < boolean > ;
27+ clear ( pattern ?: string ) : Promise < void > ;
28+ size ( ) : Promise < number > ;
29+ }
30+
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments