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]>
Signed-off-by: ebadiere <[email protected]>
  • Loading branch information
konstantinabl authored and ebadiere committed Jul 9, 2024
1 parent e992efe commit 0c4306c
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 0c4306c

Please sign in to comment.