Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

improve: leverage default TTL & leverage caching #938

Merged
merged 2 commits into from
Sep 16, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
4 changes: 2 additions & 2 deletions src/caching/RedisCache.ts
Original file line number Diff line number Diff line change
@@ -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";

/**
Expand Down Expand Up @@ -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);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not set ttl = constants.DEFAULT_CACHING_TTL in the function declaration?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not super opinionated on this. I wanted to keep the function signatures as close to the interface as possible. However, I like this approach because if we ever decide to expand on the logic we only need to define the default once.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Resolved

// Return key to indicate that the value was set successfully.
return key;
}
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@
"@openzeppelin/contracts" "4.1.0"
"@uma/core" "^2.18.0"

"@across-protocol/[email protected].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/[email protected].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"
Expand Down