Skip to content

Commit

Permalink
make the cache ttl configurable
Browse files Browse the repository at this point in the history
also increase the jwt validaity
  • Loading branch information
muhamadazmy committed Feb 7, 2024
1 parent d869bec commit fca45a3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
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

0 comments on commit fca45a3

Please sign in to comment.