forked from EvolutionAPI/evolution-api
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcacheengine.ts
More file actions
27 lines (21 loc) · 844 Bytes
/
cacheengine.ts
File metadata and controls
27 lines (21 loc) · 844 Bytes
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
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('Redis');
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 !== '') {
this.engine = new RedisCache(configService, module);
} else if (cacheConf?.LOCAL?.ENABLED) {
this.engine = new LocalCache(configService, module);
}
logger.info(`RedisCache initialized for ${module}`);
}
public getEngine() {
return this.engine;
}
}