From 745ce13f4644d45437214137d3fd898c24f57394 Mon Sep 17 00:00:00 2001 From: jinhai Date: Tue, 5 Nov 2019 02:28:53 +0800 Subject: [PATCH] Update Cache code format --- core/src/cache/Cache.h | 13 +++++++++++-- core/src/cache/CacheMgr.h | 7 ++++++- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/core/src/cache/Cache.h b/core/src/cache/Cache.h index 62a7f13ca8..d3513032b9 100644 --- a/core/src/cache/Cache.h +++ b/core/src/cache/Cache.h @@ -40,12 +40,15 @@ class Cache { return usage_; } + // unit: BYTE int64_t capacity() const { return capacity_; - } // unit: BYTE + } + + // unit: BYTE void - set_capacity(int64_t capacity); // unit: BYTE + set_capacity(int64_t capacity); double freemem_percent() const { @@ -59,16 +62,22 @@ class Cache { size_t size() const; + bool exists(const std::string& key); + ItemObj get(const std::string& key); + void insert(const std::string& key, const ItemObj& item); + void erase(const std::string& key); + void print(); + void clear(); diff --git a/core/src/cache/CacheMgr.h b/core/src/cache/CacheMgr.h index f5e04f6509..a085bcfb87 100644 --- a/core/src/cache/CacheMgr.h +++ b/core/src/cache/CacheMgr.h @@ -53,14 +53,19 @@ class CacheMgr { int64_t CacheUsage() const; + int64_t CacheCapacity() const; + void SetCapacity(int64_t capacity); protected: + CacheMgr(); - virtual ~CacheMgr(); + + virtual + ~CacheMgr(); protected: using CachePtr = std::shared_ptr>;