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


##########
be/src/runtime/memory/lru_cache_policy.h:
##########
@@ -72,7 +81,54 @@ class LRUCachePolicy : public CachePolicy {
         return true;
     }
 
-    ~LRUCachePolicy() override = default;
+    static std::string lru_cache_type_string(LRUCacheType type) {
+        switch (type) {
+        case LRUCacheType::SIZE:
+            return "size";
+        case LRUCacheType::NUMBER:
+            return "number";
+        default:
+            LOG(FATAL) << "not match type of lru cache:" << 
static_cast<int>(type);
+        }
+    }
+
+    std::shared_ptr<MemTrackerLimiter> mem_tracker() { return _mem_tracker; }
+
+    Cache::Handle* insert(const CacheKey& key, void* value, size_t charge, 
size_t tracking_bytes,
+                          CachePriority priority = CachePriority::NORMAL) {
+        size_t bytes_with_handle = _get_bytes_with_handle(key, charge, 
tracking_bytes);
+        if (tracking_bytes > 0) {
+            _mem_tracker->cache_consume(bytes_with_handle);
+        }
+        
DorisMetrics::instance()->lru_cache_memory_bytes->increment(bytes_with_handle);
+        if (value != nullptr) {
+            ((LRUCacheValueBase*)value)
+                    ->bind_memory_tracking(bytes_with_handle,
+                                           tracking_bytes > 0 ? 
_mem_tracker.get() : nullptr);

Review Comment:
   merge this tracking_bytes > 0 logic with line 101



-- 
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