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


##########
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:
   prepare 和 init 实际是相同的意思。
   这个函数,你实现的实际就是check。



-- 
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: commits-unsubscr...@doris.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org

Reply via email to