Skip to content

Commit

Permalink
Reverts back to old approach of instantiating internal and shared cache
Browse files Browse the repository at this point in the history
Signed-off-by: Konstantina Blazhukova <konstantina.blajukova@gmail.com>
  • Loading branch information
konstantinabl committed Jul 31, 2024
1 parent d68e965 commit d2700ba
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions packages/relay/src/lib/services/cacheService/cacheService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,14 @@ export class CacheService {
*
* @private
*/
private readonly internalCache!: ICacheClient;
private readonly internalCache: ICacheClient;

/**
* The Redis cache used for caching items from requests.
*
* @private
*/
private readonly sharedCache!: ICacheClient;
private readonly sharedCache: ICacheClient;

/**
* The logger used for logging all output from this class.
Expand Down Expand Up @@ -77,7 +77,7 @@ export class CacheService {

private static readonly methods = {
GET: 'get',
GET_ASYNC: 'getFromSharedCache',
GET_ASYNC: 'getAsync',
SET: 'set',
DELETE: 'delete',
MSET: 'mSet',
Expand All @@ -90,13 +90,13 @@ export class CacheService {
this.logger = logger;
this.register = register;

this.internalCache = new LocalLRUCache(logger.child({ name: 'localLRUCache' }), register);
this.sharedCache = this.internalCache;
this.isSharedCacheEnabled = process.env.TEST === 'true' ? false : this.isRedisEnabled();
this.shouldMultiSet = process.env.MULTI_SET && process.env.MULTI_SET === 'true' ? true : false;

if (this.isSharedCacheEnabled) {
this.sharedCache = new RedisCache(logger.child({ name: 'redisCache' }), register);
} else {
this.internalCache = new LocalLRUCache(logger.child({ name: 'localLRUCache' }), register);
}

/**
Expand Down

0 comments on commit d2700ba

Please sign in to comment.