Skip to content

Commit

Permalink
fix: Adds usage of internal cache for getFilterChanges (#2668)
Browse files Browse the repository at this point in the history
Changes current logic of getFilterChanges, so it considers changes from internal cache as well

Signed-off-by: Konstantina Blazhukova <[email protected]>
  • Loading branch information
konstantinabl authored Jul 3, 2024
1 parent 6743a81 commit 7acb142
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ export class CacheService {
* @private
* @returns {boolean} Returns true if Redis caching is enabled, otherwise false.
*/
private isRedisEnabled(): boolean {
public isRedisEnabled(): boolean {
const redisEnabled = process.env.REDIS_ENABLED && process.env.REDIS_ENABLED === 'true';
const redisUrlValid = process.env.REDIS_URL && process.env.REDIS_URL !== '';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,9 @@ export class FilterService implements IFilterService {
FilterService.requireFiltersEnabled();

const cacheKey = `${constants.CACHE_KEY.FILTERID}_${filterId}`;
const filter = await this.cacheService.getAsync(cacheKey, this.ethGetFilterChanges, requestIdPrefix);
const filter = this.cacheService.isRedisEnabled()
? await this.cacheService.getAsync(cacheKey, this.ethGetFilterChanges, requestIdPrefix)
: await this.cacheService.get(cacheKey, this.ethGetFilterChanges, requestIdPrefix);

if (!filter) {
throw predefined.FILTER_NOT_FOUND;
Expand Down

0 comments on commit 7acb142

Please sign in to comment.