xinyiZzz commented on code in PR #28940:
URL: https://github.com/apache/doris/pull/28940#discussion_r1437794509


##########
be/src/runtime/memory/lru_cache_policy.h:
##########
@@ -34,22 +36,62 @@ struct LRUCacheValueBase {
 // Base of lru cache, allow prune stale entry and prune all entry.
 class LRUCachePolicy : public CachePolicy {
 public:
-    LRUCachePolicy(CacheType type, uint32_t stale_sweep_time_s)
-            : CachePolicy(type, stale_sweep_time_s) {};
+    LRUCachePolicy(CacheType type, uint32_t stale_sweep_time_s, bool 
enable_prune = true)
+            : CachePolicy(type, stale_sweep_time_s, enable_prune) {};
     LRUCachePolicy(CacheType type, size_t capacity, LRUCacheType 
lru_cache_type,
-                   uint32_t stale_sweep_time_s, uint32_t num_shards = -1)
-            : CachePolicy(type, stale_sweep_time_s) {
-        _cache = num_shards == -1
-                         ? std::unique_ptr<Cache>(
-                                   new ShardedLRUCache(type_string(type), 
capacity, lru_cache_type))
-                         : std::unique_ptr<Cache>(new 
ShardedLRUCache(type_string(type), capacity,
-                                                                      
lru_cache_type, num_shards));
+                   uint32_t stale_sweep_time_s, uint32_t num_shards = 
DEFAULT_LRU_CACHE_NUM_SHARDS,
+                   bool enable_prune = true)
+            : CachePolicy(type, stale_sweep_time_s, enable_prune) {
+        init(capacity, lru_cache_type, num_shards);
+    }
+
+    bool prepare(size_t capacity, uint32_t num_shards) {

Review Comment:
   em。。因为把 check init 和 init = true 也加进来了,所以改叫 prepare



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to