Skip to content

Commit

Permalink
[refactor] More accurate naming to the cache of counters
Browse files Browse the repository at this point in the history
  • Loading branch information
didierofrivia committed Apr 22, 2024
1 parent 62908ca commit 1edd4c4
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions limitador/src/storage/redis/redis_cached.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ use std::str::FromStr;
use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::{Arc, Mutex};
use std::time::{Duration, Instant, SystemTime};
use tracing::{error, trace_span, warn, Instrument};
use tracing::{debug_span, error, warn, Instrument};

// This is just a first version.
//
Expand Down Expand Up @@ -233,9 +233,7 @@ impl CachedRedisStorage {
.ttl_ratio_cached_counter(ttl_ratio_cached_counters)
.build();

let cacher = Arc::new(cached_counters);
let cacher_clone = cacher.clone();

let counters_cache = Arc::new(cached_counters);
let partitioned = Arc::new(AtomicBool::new(false));
let async_redis_storage =
AsyncRedisStorage::new_with_conn_manager(redis_conn_manager.clone());
Expand All @@ -244,6 +242,7 @@ impl CachedRedisStorage {

{
let storage = async_redis_storage.clone();
let counters_cache_clone = counters_cache.clone();
let conn = redis_conn_manager.clone();
let p = Arc::clone(&partitioned);
let batcher_flusher = batcher.clone();
Expand All @@ -254,7 +253,7 @@ impl CachedRedisStorage {
conn.clone(),
batcher_flusher.clone(),
storage.is_alive(),
cacher_clone.clone(),
counters_cache_clone.clone(),
p.clone(),
)
.await;
Expand All @@ -264,7 +263,7 @@ impl CachedRedisStorage {
}

Ok(Self {
cached_counters: cacher,
cached_counters: counters_cache,
batcher_counter_updates: batcher,
redis_conn_manager,
async_redis_storage,
Expand Down Expand Up @@ -409,7 +408,7 @@ async fn update_counters<C: ConnectionLike>(
}
}

let span = trace_span!("datastore");
let span = debug_span!("datastore");
// The redis crate is not working with tables, thus the response will be a Vec of counter values
let script_res: Vec<i64> = script_invocation
.invoke_async(redis_conn)
Expand Down

0 comments on commit 1edd4c4

Please sign in to comment.