diff --git a/src/caching/RedisCache.ts b/src/caching/RedisCache.ts index 0f14c0f5c2..ac8b9bb288 100644 --- a/src/caching/RedisCache.ts +++ b/src/caching/RedisCache.ts @@ -1,5 +1,5 @@ import { interfaces, constants } from "@across-protocol/sdk-v2"; -import { RedisClient, objectWithBigNumberReviver, setRedisKey, winston } from "../utils"; +import { RedisClient, objectWithBigNumberReviver, setRedisKey } from "../utils"; /** * RedisCache is a caching mechanism that uses Redis as the backing store. It is used by the @@ -8,14 +8,6 @@ import { RedisClient, objectWithBigNumberReviver, setRedisKey, winston } from ". * drop-in in the SDK without the SDK needing to reason about the implementation details. */ export class RedisCache implements interfaces.CachingMechanismInterface { - /** - * The logger is optional, but if it is provided, it will be used to log debug messages - */ - private readonly logger: winston.Logger | undefined; - /** - * The redisUrl is the URL of the redis server to connect to. - */ - private readonly redisUrl: string; /** * The redisClient is the redis client that is used to communicate with the redis server. * It is instantiated lazily when the `instantiate` method is called. @@ -27,8 +19,7 @@ export class RedisCache implements interfaces.CachingMechanismInterface { * @param redisUrl The URL of the redis server to connect to. * @param logger The logger to use to log debug messages. */ - constructor(redisClient: RedisClient, logger?: winston.Logger) { - this.logger = logger; + constructor(redisClient: RedisClient) { this.redisClient = redisClient; } diff --git a/src/scripts/testUBAClient.ts b/src/scripts/testUBAClient.ts index 335f0233bd..03de459113 100644 --- a/src/scripts/testUBAClient.ts +++ b/src/scripts/testUBAClient.ts @@ -17,6 +17,7 @@ import { getBlockForTimestamp, disconnectRedisClient, REDIS_URL, + getRedisCache, } from "../utils"; import { constructSpokePoolClientsForFastDataworker, @@ -25,8 +26,8 @@ import { import { updateClients } from "../common"; import { clients as sdkClients, utils as sdkUtils } from "@across-protocol/sdk-v2"; import { createDataworker } from "../dataworker"; -import { RedisCache } from "../caching/RedisCache"; import { ConfigStoreClient } from "../clients"; +import { CachingMechanismInterface } from "../interfaces"; config(); @@ -117,10 +118,10 @@ export async function testUBAClient(_logger: winston.Logger, baseSigner: Wallet) ); // Now, simply update the UBA client: - const redisCache = new RedisCache(REDIS_URL); + let redisCache: CachingMechanismInterface | undefined; let successfullyInstantiated = false; try { - await redisCache.instantiate(); + redisCache = await getRedisCache(logger, REDIS_URL); successfullyInstantiated = true; } catch (error) { logger.warn({ @@ -136,7 +137,7 @@ export async function testUBAClient(_logger: winston.Logger, baseSigner: Wallet) clients.hubPoolClient, spokePoolClients, // Pass in no redis client for now as testing with fresh state is easier to reason about - successfullyInstantiated ? new RedisCache(REDIS_URL) : undefined + successfullyInstantiated ? redisCache : undefined ); await ubaClient.update(); } diff --git a/src/utils/RedisUtils.ts b/src/utils/RedisUtils.ts index 76efb3038b..cdcc569718 100644 --- a/src/utils/RedisUtils.ts +++ b/src/utils/RedisUtils.ts @@ -50,7 +50,7 @@ export async function getRedisCache( ): Promise { const client = await getRedis(logger, url); if (client) { - return new RedisCache(client, logger); + return new RedisCache(client); } }