Team Ai
Apppublic

oex2003/evolution-api

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