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

make the cache ttl configurable #190

Merged
merged 1 commit into from
Feb 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
6 changes: 5 additions & 1 deletion src/bins/rmb-relay.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ struct Args {
/// failures that occurred outside this specified period will be disregarded.
#[clap(short = 'p', long, default_value_t = 3600)]
ranker_period: u64,

/// how long to cache twin information in redis in minutes
#[clap(long, default_value_t = 10*60)]
cache: u64,
}

fn set_limits() -> Result<()> {
Expand Down Expand Up @@ -142,7 +146,7 @@ async fn app(args: Args) -> Result<()> {
// and we only need twin public key for validation only.
let twins = SubstrateTwinDB::<RedisCache>::new(
args.substrate,
RedisCache::new(pool.clone(), "twin", Duration::from_secs(60)),
RedisCache::new(pool.clone(), "twin", Duration::from_secs(args.cache * 60)),
)
.await
.context("cannot create substrate twin db object")?;
Expand Down
2 changes: 1 addition & 1 deletion src/peer/socket.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ async fn retainer<S: Signer>(
down_tx: mpsc::Sender<Message>,
) {
loop {
let token = b.token(60).context("failed to create jwt token").unwrap();
let token = b.token(300).context("failed to create jwt token").unwrap();

u.set_query(Some(token.as_str()));

Expand Down
Loading