removed some old code
This commit is contained in:
parent
bd26ecf3bc
commit
c5f6b37022
11 changed files with 1 additions and 767 deletions
|
|
@ -1,47 +0,0 @@
|
|||
import type { AwilixContainer } from 'awilix';
|
||||
import { NamespacedCache, type CacheProvider } from '@stock-bot/cache';
|
||||
import type { ServiceDefinitions } from '../container/types';
|
||||
|
||||
export class CacheFactory {
|
||||
static createNamespacedCache(baseCache: CacheProvider, namespace: string): NamespacedCache {
|
||||
return new NamespacedCache(baseCache, namespace);
|
||||
}
|
||||
|
||||
static createCacheForService(
|
||||
container: AwilixContainer<ServiceDefinitions>,
|
||||
serviceName: string
|
||||
): CacheProvider | null {
|
||||
const baseCache = container.cradle.cache;
|
||||
if (!baseCache) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return this.createNamespacedCache(baseCache, serviceName);
|
||||
}
|
||||
|
||||
static createCacheForHandler(
|
||||
container: AwilixContainer<ServiceDefinitions>,
|
||||
handlerName: string
|
||||
): CacheProvider | null {
|
||||
const baseCache = container.cradle.cache;
|
||||
if (!baseCache) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return this.createNamespacedCache(baseCache, `handler:${handlerName}`);
|
||||
}
|
||||
|
||||
static createCacheWithPrefix(
|
||||
container: AwilixContainer<ServiceDefinitions>,
|
||||
prefix: string
|
||||
): CacheProvider | null {
|
||||
const baseCache = container.cradle.cache;
|
||||
if (!baseCache) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// Remove 'cache:' prefix if already included
|
||||
const cleanPrefix = prefix.replace(/^cache:/, '');
|
||||
return this.createNamespacedCache(baseCache, cleanPrefix);
|
||||
}
|
||||
}
|
||||
|
|
@ -1 +1 @@
|
|||
export { CacheFactory } from './cache.factory';
|
||||
// This directory is reserved for future factory implementations
|
||||
|
|
@ -18,5 +18,3 @@ export {
|
|||
queueConfigSchema
|
||||
} from './config/schemas';
|
||||
|
||||
// Export factories
|
||||
export { CacheFactory } from './factories';
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue