fixed build libs
This commit is contained in:
parent
b03231b849
commit
42baadae38
26 changed files with 981 additions and 541 deletions
18
libs/core/cache/src/cache-factory.ts
vendored
18
libs/core/cache/src/cache-factory.ts
vendored
|
|
@ -1,4 +1,4 @@
|
|||
import { NamespacedCache } from './namespaced-cache';
|
||||
import { NamespacedCache, CacheAdapter } from './namespaced-cache';
|
||||
import { RedisCache } from './redis-cache';
|
||||
import type { CacheProvider, ICache } from './types';
|
||||
|
||||
|
|
@ -27,18 +27,18 @@ export class CacheFactory {
|
|||
export function createNamespacedCache(
|
||||
cache: CacheProvider | ICache | null | undefined,
|
||||
namespace: string
|
||||
): ICache {
|
||||
): CacheProvider {
|
||||
if (!cache) {
|
||||
return createNullCache();
|
||||
return new CacheAdapter(createNullCache());
|
||||
}
|
||||
|
||||
// Check if it's already an ICache
|
||||
if ('type' in cache) {
|
||||
return new NamespacedCache(cache as ICache, namespace);
|
||||
// Check if it's already a CacheProvider
|
||||
if ('getStats' in cache && 'health' in cache) {
|
||||
return new NamespacedCache(cache as CacheProvider, namespace);
|
||||
}
|
||||
|
||||
// Legacy CacheProvider support
|
||||
return createNullCache();
|
||||
// It's an ICache, wrap it first
|
||||
return new NamespacedCache(new CacheAdapter(cache as ICache), namespace);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -70,4 +70,4 @@ function createNullCache(): ICache {
|
|||
disconnect: async () => {},
|
||||
isConnected: () => true,
|
||||
};
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue