Skip to content

Commit

Permalink
cargo update
Browse files Browse the repository at this point in the history
  • Loading branch information
tazz4843 committed Nov 17, 2024
1 parent 680b9de commit 145b629
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 26 deletions.
46 changes: 23 additions & 23 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 6 additions & 3 deletions scripty_data_storage/src/cache/text.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@ pub async fn change_text_state(user_id: u64, state: bool) -> Result<(), sqlx::Er
.await?;

// set cache value
let _ = scripty_redis::run_transaction::<Option<String>>("SET", |con| {
let _ = scripty_redis::run_transaction::<Option<String>>("SETEX", |con| {
con.arg(format!("user:{{{}}}:store_msgs", hex::encode(user_id)))
.arg(60 * 60 * 24)
.arg(state);
})
.await;
Expand Down Expand Up @@ -61,23 +62,25 @@ pub async fn get_text_state(raw_user_id: u64) -> bool {
match state {
Ok(Some(state)) => {
// cache value
let _ = scripty_redis::run_transaction::<Option<String>>("SET", |con| {
let _ = scripty_redis::run_transaction::<Option<String>>("SETEX", |con| {
con.arg(format!(
"user:{{{}}}:store_msgs",
hex::encode(user_id.clone())
))
.arg(60 * 60 * 24)
.arg(state.store_msgs);
})
.await;
state.store_msgs
}
Ok(None) => {
// user not found, cache false
let _ = scripty_redis::run_transaction::<Option<String>>("SET", |con| {
let _ = scripty_redis::run_transaction::<Option<String>>("SETEX", |con| {
con.arg(format!(
"user:{{{}}}:store_msgs",
hex::encode(user_id.clone())
))
.arg(60 * 60 * 24)
.arg(false);
})
.await;
Expand Down

0 comments on commit 145b629

Please sign in to comment.