From e20cf4f2fe19ebc118e09fba848756d2119db499 Mon Sep 17 00:00:00 2001 From: td-zhangshun Date: Thu, 24 Apr 2025 10:25:39 +0800 Subject: [PATCH] refactor: Optimize cache cleaning policy configuration flow Move the common cleaning policy setting outside the conditional block to ensure it's always set first, regardless of the policy type. This change maintains the specific parameter settings for 'acp' and 'alru' policies while improving code structure and execution flow. --- utils/opencas.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/utils/opencas.py b/utils/opencas.py index aa73fad..0093bbe 100644 --- a/utils/opencas.py +++ b/utils/opencas.py @@ -635,15 +635,13 @@ def start_cache(cache, load, force=False): def configure_cache(cache): if "cleaning_policy" in cache.params: + casadm.set_param( + "cleaning", cache_id=cache.cache_id, policy=cache.params["cleaning_policy"] + ) if cache.params["cleaning_policy"] == "acp" or cache.params["cleaning_policy"] == "alru": casadm.set_param_cleaning_policy( policy=cache.params["cleaning_policy"], cache_id=cache.cache_id, wake_up=cache.params["wake_up"], flush_max_buffers=cache.params["flush_max_buffers"] ) - else: - casadm.set_param( - "cleaning", cache_id=cache.cache_id, policy=cache.params["cleaning_policy"] - ) - if "promotion_policy" in cache.params: casadm.set_param( -- 2.45.2