From 1c129307b0154db3aa31e38c75235ba4d9fa74c5 Mon Sep 17 00:00:00 2001 From: YassinEldeeb Date: Mon, 8 Jan 2024 03:22:08 +0200 Subject: [PATCH] remove useless eviction policy usage --- libs/common/src/cache.rs | 21 ++------------------- 1 file changed, 2 insertions(+), 19 deletions(-) diff --git a/libs/common/src/cache.rs b/libs/common/src/cache.rs index 49a6b803..b2bbf293 100644 --- a/libs/common/src/cache.rs +++ b/libs/common/src/cache.rs @@ -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. @@ -177,11 +177,6 @@ pub struct InMemoryConfig { #[serde(default = "in_memory_default_max_size")] pub max_size: Option, - /// 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, - /// 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")] @@ -192,19 +187,7 @@ pub struct InMemoryConfig { fn in_memory_default_max_size() -> Option { Some(1000) } -fn in_memory_default_eviction_policy() -> Option { - Some(EvictionPolicy::LRU) -} + fn in_memory_default_cache_ttl_seconds() -> Option { 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, -}