File size: 924 Bytes
80f4e3d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
import { ICache } from '@api/abstract/abstract.cache';
import { CacheConf, ConfigService } from '@config/env.config';
import { Logger } from '@config/logger.config';
import { LocalCache } from './localcache';
import { RedisCache } from './rediscache';
const logger = new Logger('CacheEngine');
export class CacheEngine {
private engine: ICache;
constructor(
private readonly configService: ConfigService,
module: string,
) {
const cacheConf = configService.get<CacheConf>('CACHE');
if (cacheConf?.REDIS?.ENABLED && cacheConf?.REDIS?.URI !== '') {
logger.verbose(`RedisCache initialized for ${module}`);
this.engine = new RedisCache(configService, module);
} else if (cacheConf?.LOCAL?.ENABLED) {
logger.verbose(`LocalCache initialized for ${module}`);
this.engine = new LocalCache(configService, module);
}
}
public getEngine() {
return this.engine;
}
}
|