Spaces:
Running
Running
neon_arch
commited on
Commit
Β·
acee5d8
1
Parent(s):
9a5f1c5
π fix: replace deprecated `set_ex` command with `set_options` in `cache_json` function (#592)
Browse files- src/cache/redis_cacher.rs +12 -3
src/cache/redis_cacher.rs
CHANGED
@@ -4,7 +4,10 @@
|
|
4 |
use super::error::CacheError;
|
5 |
use error_stack::Report;
|
6 |
use futures::stream::FuturesUnordered;
|
7 |
-
use redis::{
|
|
|
|
|
|
|
8 |
|
9 |
/// A constant holding the redis pipeline size.
|
10 |
const REDIS_PIPELINE_SIZE: usize = 3;
|
@@ -139,8 +142,14 @@ impl RedisCache {
|
|
139 |
self.current_connection = Default::default();
|
140 |
|
141 |
for (key, json_result) in keys.zip(json_results) {
|
142 |
-
self.pipeline
|
143 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
144 |
}
|
145 |
|
146 |
let mut result: Result<(), RedisError> = self
|
|
|
4 |
use super::error::CacheError;
|
5 |
use error_stack::Report;
|
6 |
use futures::stream::FuturesUnordered;
|
7 |
+
use redis::{
|
8 |
+
aio::ConnectionManager, AsyncCommands, Client, ExistenceCheck, RedisError, SetExpiry,
|
9 |
+
SetOptions,
|
10 |
+
};
|
11 |
|
12 |
/// A constant holding the redis pipeline size.
|
13 |
const REDIS_PIPELINE_SIZE: usize = 3;
|
|
|
142 |
self.current_connection = Default::default();
|
143 |
|
144 |
for (key, json_result) in keys.zip(json_results) {
|
145 |
+
self.pipeline.set_options(
|
146 |
+
key,
|
147 |
+
json_result,
|
148 |
+
SetOptions::default()
|
149 |
+
.conditional_set(ExistenceCheck::NX)
|
150 |
+
.get(true)
|
151 |
+
.with_expiration(SetExpiry::EX(self.cache_ttl.into())),
|
152 |
+
);
|
153 |
}
|
154 |
|
155 |
let mut result: Result<(), RedisError> = self
|