refactor of data-service
This commit is contained in:
parent
3097686849
commit
54314a0cde
49 changed files with 2394 additions and 112 deletions
13
libs/cache/src/redis-cache.ts
vendored
13
libs/cache/src/redis-cache.ts
vendored
|
|
@ -289,6 +289,19 @@ export class RedisCache implements CacheProvider {
|
|||
);
|
||||
}
|
||||
|
||||
async keys(pattern: string): Promise<string[]> {
|
||||
return this.safeExecute(
|
||||
async () => {
|
||||
const fullPattern = `${this.keyPrefix}${pattern}`;
|
||||
const keys = await this.redis.keys(fullPattern);
|
||||
// Remove the prefix from returned keys to match the interface expectation
|
||||
return keys.map(key => key.replace(this.keyPrefix, ''));
|
||||
},
|
||||
[],
|
||||
'keys'
|
||||
);
|
||||
}
|
||||
|
||||
async health(): Promise<boolean> {
|
||||
try {
|
||||
const pong = await this.redis.ping();
|
||||
|
|
|
|||
1
libs/cache/src/types.ts
vendored
1
libs/cache/src/types.ts
vendored
|
|
@ -16,6 +16,7 @@ export interface CacheProvider {
|
|||
del(key: string): Promise<void>;
|
||||
exists(key: string): Promise<boolean>;
|
||||
clear(): Promise<void>;
|
||||
keys(pattern: string): Promise<string[]>;
|
||||
getStats(): CacheStats;
|
||||
health(): Promise<boolean>;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue