0
0
mirror of https://github.com/neon-mmd/websurfx.git synced 2024-11-21 21:48:21 -05:00

🐛 fix: replace deprecated set_ex command with set_options in cache_json function (#592)

This commit is contained in:
neon_arch 2024-09-02 21:17:31 +05:30
parent 9a5f1c5f44
commit acee5d892d

View File

@ -4,7 +4,10 @@
use super::error::CacheError; use super::error::CacheError;
use error_stack::Report; use error_stack::Report;
use futures::stream::FuturesUnordered; use futures::stream::FuturesUnordered;
use redis::{aio::ConnectionManager, AsyncCommands, Client, RedisError}; use redis::{
aio::ConnectionManager, AsyncCommands, Client, ExistenceCheck, RedisError, SetExpiry,
SetOptions,
};
/// A constant holding the redis pipeline size. /// A constant holding the redis pipeline size.
const REDIS_PIPELINE_SIZE: usize = 3; const REDIS_PIPELINE_SIZE: usize = 3;
@ -139,8 +142,14 @@ impl RedisCache {
self.current_connection = Default::default(); self.current_connection = Default::default();
for (key, json_result) in keys.zip(json_results) { for (key, json_result) in keys.zip(json_results) {
self.pipeline self.pipeline.set_options(
.set_ex(key, json_result, self.cache_ttl.into()); key,
json_result,
SetOptions::default()
.conditional_set(ExistenceCheck::NX)
.get(true)
.with_expiration(SetExpiry::EX(self.cache_ttl.into())),
);
} }
let mut result: Result<(), RedisError> = self let mut result: Result<(), RedisError> = self