Skip to content

Commit

Permalink
chore: fix nightly warning
Browse files Browse the repository at this point in the history
  • Loading branch information
robjtede committed Jun 20, 2024
1 parent 52e5861 commit 032aeb6
Showing 1 changed file with 16 additions and 9 deletions.
25 changes: 16 additions & 9 deletions actix-session/src/storage/redis_rs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,13 +159,18 @@ impl SessionStore for RedisSessionStore {
let session_key = generate_session_key();
let cache_key = (self.configuration.cache_keygen)(session_key.as_ref());

self.execute_command(redis::cmd("SET").arg(&[
&cache_key,
&body,
"NX", // NX: only set the key if it does not already exist
"EX", // EX: set expiry
&format!("{}", ttl.whole_seconds()),
]))
self.execute_command::<()>(
redis::cmd("SET")
.arg(&[
&cache_key, // key
&body, // value
"NX", // only set the key if it does not already exist
"EX", // set expiry / TTL
])
.arg(
ttl.whole_seconds(), // EXpiry in seconds
),
)
.await
.map_err(Into::into)
.map_err(SaveError::Other)?;
Expand Down Expand Up @@ -223,14 +228,16 @@ impl SessionStore for RedisSessionStore {

self.client
.clone()
.expire(&cache_key, ttl.whole_seconds())
.expire::<_, ()>(&cache_key, ttl.whole_seconds())
.await?;

Ok(())
}

async fn delete(&self, session_key: &SessionKey) -> Result<(), anyhow::Error> {
let cache_key = (self.configuration.cache_keygen)(session_key.as_ref());
self.execute_command(redis::cmd("DEL").arg(&[&cache_key]))

self.execute_command::<()>(redis::cmd("DEL").arg(&[&cache_key]))
.await
.map_err(Into::into)
.map_err(UpdateError::Other)?;
Expand Down

0 comments on commit 032aeb6

Please sign in to comment.