From 7a0795f57c7efffe510b0eddfc8cc36564e9be0a Mon Sep 17 00:00:00 2001 From: james-a-morris Date: Fri, 15 Sep 2023 16:08:14 -0400 Subject: [PATCH 1/2] improve: leverage default TTL --- package.json | 2 +- src/caching/RedisCache.ts | 4 ++-- yarn.lock | 8 ++++---- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/package.json b/package.json index 4f7456d2d..335b64d76 100644 --- a/package.json +++ b/package.json @@ -11,7 +11,7 @@ }, "dependencies": { "@across-protocol/contracts-v2": "2.4.3", - "@across-protocol/sdk-v2": "0.15.21", + "@across-protocol/sdk-v2": "0.15.22", "@arbitrum/sdk": "^3.1.3", "@defi-wonderland/smock": "^2.3.5", "@eth-optimism/sdk": "^3.1.0", diff --git a/src/caching/RedisCache.ts b/src/caching/RedisCache.ts index fc7767143..af3b55c78 100644 --- a/src/caching/RedisCache.ts +++ b/src/caching/RedisCache.ts @@ -1,4 +1,4 @@ -import { interfaces } from "@across-protocol/sdk-v2"; +import { interfaces, constants } from "@across-protocol/sdk-v2"; import { RedisClient, getRedis, objectWithBigNumberReviver, setRedisKey, winston } from "../utils"; /** @@ -67,7 +67,7 @@ export class RedisCache implements interfaces.CachingMechanismInterface { await this.instantiate(); } // Call the setRedisKey function to set the value in redis. - await setRedisKey(key, JSON.stringify(value), this.redisClient, ttl); + await setRedisKey(key, JSON.stringify(value), this.redisClient, ttl ?? constants.DEFAULT_CACHING_TTL); // Return key to indicate that the value was set successfully. return key; } diff --git a/yarn.lock b/yarn.lock index b798b53ce..8223f94da 100644 --- a/yarn.lock +++ b/yarn.lock @@ -37,10 +37,10 @@ "@openzeppelin/contracts" "4.1.0" "@uma/core" "^2.18.0" -"@across-protocol/sdk-v2@0.15.21": - version "0.15.21" - resolved "https://registry.yarnpkg.com/@across-protocol/sdk-v2/-/sdk-v2-0.15.21.tgz#da6de385c36c947a724ea2e02fed455ba21c7605" - integrity sha512-+3cudHaDaPryjXIO/fRZ9J+VUE9pzS57ySMbxso0uxUYgNHX/rncaxza6KA/MPxr9yVraPbxgQGdxT38ZAmdcA== +"@across-protocol/sdk-v2@0.15.22": + version "0.15.22" + resolved "https://registry.yarnpkg.com/@across-protocol/sdk-v2/-/sdk-v2-0.15.22.tgz#a33c772005a781e1bf4492a32b7f41dae23d4051" + integrity sha512-EniItgtgTRvnjP/tWQze71F9+/uOqdg7IUugmaBhrJQ3heeySFDMgooJZGAgjmVJMrTfZXWKMaarDpy5nQAifg== dependencies: "@across-protocol/across-token" "^1.0.0" "@across-protocol/contracts-v2" "^2.4.3" From eced5d24520171167a45c1d832593fcdb5aafd1c Mon Sep 17 00:00:00 2001 From: james-a-morris Date: Fri, 15 Sep 2023 17:24:59 -0400 Subject: [PATCH 2/2] improve: set fn signature to default --- src/caching/RedisCache.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/caching/RedisCache.ts b/src/caching/RedisCache.ts index af3b55c78..28670dcaf 100644 --- a/src/caching/RedisCache.ts +++ b/src/caching/RedisCache.ts @@ -61,13 +61,13 @@ export class RedisCache implements interfaces.CachingMechanismInterface { } } - public async set(key: string, value: T, ttl?: number): Promise { + public async set(key: string, value: T, ttl: number = constants.DEFAULT_CACHING_TTL): Promise { // Instantiate the redis client if it has not been instantiated yet. if (!this.redisClient) { await this.instantiate(); } // Call the setRedisKey function to set the value in redis. - await setRedisKey(key, JSON.stringify(value), this.redisClient, ttl ?? constants.DEFAULT_CACHING_TTL); + await setRedisKey(key, JSON.stringify(value), this.redisClient, ttl); // Return key to indicate that the value was set successfully. return key; }