Skip to content

Commit

Permalink
remove useless eviction policy usage
Browse files Browse the repository at this point in the history
  • Loading branch information
YassinEldeeb committed Jan 8, 2024
1 parent f0350b1 commit 1c12930
Showing 1 changed file with 2 additions and 19 deletions.
21 changes: 2 additions & 19 deletions libs/common/src/cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ pub struct CloudflareKVConfig {
pub namespace_identifier: String,
}

/// Configuration for In-Memory caching.
/// Configuration for In-Memory caching, it internally works using an LRU (Least Recently Used) eviction policy
#[derive(Deserialize, Serialize, Debug, Clone, JsonSchema)]
pub struct InMemoryConfig {
/// The maximum number of cache entries. Default is 1000 entries.
Expand All @@ -177,11 +177,6 @@ pub struct InMemoryConfig {
#[serde(default = "in_memory_default_max_size")]
pub max_size: Option<usize>,

/// Eviction policy for the cache. Default is LRU (Least Recently Used).
/// LRU evicts the least recently accessed items first.
#[serde(default = "in_memory_default_eviction_policy")]
pub eviction_policy: Option<EvictionPolicy>,

/// Time-to-live for cache entries in seconds. Default is 600 seconds (10 minutes).
/// This is the duration after which a cache entry will be automatically removed.
#[serde(default = "in_memory_default_cache_ttl_seconds")]
Expand All @@ -192,19 +187,7 @@ pub struct InMemoryConfig {
fn in_memory_default_max_size() -> Option<usize> {
Some(1000)
}
fn in_memory_default_eviction_policy() -> Option<EvictionPolicy> {
Some(EvictionPolicy::LRU)
}

fn in_memory_default_cache_ttl_seconds() -> Option<u64> {
Some(600)
}

/// Eviction policies available for the In-Memory cache.
#[derive(Deserialize, Serialize, Debug, Clone, JsonSchema, PartialEq)]
#[serde(rename_all = "lowercase")]
pub enum EvictionPolicy {
/// Least Recently Used: Evicts the least recently accessed items first.
LRU,
/// First In, First Out: Evicts the oldest items in the cache first.
FIFO,
}

0 comments on commit 1c12930

Please sign in to comment.