hit_times_(0),
stats_(nullptr) {}
- virtual ~SimCacheImpl() {}
- virtual void SetCapacity(size_t capacity) override {
- cache_->SetCapacity(capacity);
- }
+ ~SimCacheImpl() override {}
+ void SetCapacity(size_t capacity) override { cache_->SetCapacity(capacity); }
- virtual void SetStrictCapacityLimit(bool strict_capacity_limit) override {
+ void SetStrictCapacityLimit(bool strict_capacity_limit) override {
cache_->SetStrictCapacityLimit(strict_capacity_limit);
}
- virtual Status Insert(const Slice& key, void* value, size_t charge,
- void (*deleter)(const Slice& key, void* value),
- Handle** handle, Priority priority) override {
+ Status Insert(const Slice& key, void* value, size_t charge,
+ void (*deleter)(const Slice& key, void* value), Handle** handle,
+ Priority priority) override {
// The handle and value passed in are for real cache, so we pass nullptr
// to key_only_cache_ for both instead. Also, the deleter function pointer
// will be called by user to perform some external operation which should
return cache_->Insert(key, value, charge, deleter, handle, priority);
}
- virtual Handle* Lookup(const Slice& key, Statistics* stats) override {
+ Handle* Lookup(const Slice& key, Statistics* stats) override {
Handle* h = key_only_cache_->Lookup(key);
if (h != nullptr) {
key_only_cache_->Release(h);
return cache_->Lookup(key, stats);
}
- virtual bool Ref(Handle* handle) override { return cache_->Ref(handle); }
+ bool Ref(Handle* handle) override { return cache_->Ref(handle); }
- virtual bool Release(Handle* handle, bool force_erase = false) override {
+ bool Release(Handle* handle, bool force_erase = false) override {
return cache_->Release(handle, force_erase);
}
- virtual void Erase(const Slice& key) override {
+ void Erase(const Slice& key) override {
cache_->Erase(key);
key_only_cache_->Erase(key);
}
- virtual void* Value(Handle* handle) override { return cache_->Value(handle); }
+ void* Value(Handle* handle) override { return cache_->Value(handle); }
- virtual uint64_t NewId() override { return cache_->NewId(); }
+ uint64_t NewId() override { return cache_->NewId(); }
- virtual size_t GetCapacity() const override { return cache_->GetCapacity(); }
+ size_t GetCapacity() const override { return cache_->GetCapacity(); }
- virtual bool HasStrictCapacityLimit() const override {
+ bool HasStrictCapacityLimit() const override {
return cache_->HasStrictCapacityLimit();
}
- virtual size_t GetUsage() const override { return cache_->GetUsage(); }
+ size_t GetUsage() const override { return cache_->GetUsage(); }
- virtual size_t GetUsage(Handle* handle) const override {
+ size_t GetUsage(Handle* handle) const override {
return cache_->GetUsage(handle);
}
- virtual size_t GetPinnedUsage() const override {
- return cache_->GetPinnedUsage();
- }
+ size_t GetPinnedUsage() const override { return cache_->GetPinnedUsage(); }
- virtual void DisownData() override {
+ void DisownData() override {
cache_->DisownData();
key_only_cache_->DisownData();
}
- virtual void ApplyToAllCacheEntries(void (*callback)(void*, size_t),
- bool thread_safe) override {
+ void ApplyToAllCacheEntries(void (*callback)(void*, size_t),
+ bool thread_safe) override {
// only apply to _cache since key_only_cache doesn't hold value
cache_->ApplyToAllCacheEntries(callback, thread_safe);
}
- virtual void EraseUnRefEntries() override {
+ void EraseUnRefEntries() override {
cache_->EraseUnRefEntries();
key_only_cache_->EraseUnRefEntries();
}
- virtual size_t GetSimCapacity() const override {
+ size_t GetSimCapacity() const override {
return key_only_cache_->GetCapacity();
}
- virtual size_t GetSimUsage() const override {
- return key_only_cache_->GetUsage();
- }
- virtual void SetSimCapacity(size_t capacity) override {
+ size_t GetSimUsage() const override { return key_only_cache_->GetUsage(); }
+ void SetSimCapacity(size_t capacity) override {
key_only_cache_->SetCapacity(capacity);
}
- virtual uint64_t get_miss_counter() const override {
+ uint64_t get_miss_counter() const override {
return miss_times_.load(std::memory_order_relaxed);
}
- virtual uint64_t get_hit_counter() const override {
+ uint64_t get_hit_counter() const override {
return hit_times_.load(std::memory_order_relaxed);
}
- virtual void reset_counter() override {
+ void reset_counter() override {
miss_times_.store(0, std::memory_order_relaxed);
hit_times_.store(0, std::memory_order_relaxed);
SetTickerCount(stats_, SIM_BLOCK_CACHE_HIT, 0);
SetTickerCount(stats_, SIM_BLOCK_CACHE_MISS, 0);
}
- virtual std::string ToString() const override {
+ std::string ToString() const override {
std::string res;
res.append("SimCache MISSes: " + std::to_string(get_miss_counter()) + "\n");
res.append("SimCache HITs: " + std::to_string(get_hit_counter()) + "\n");
return res;
}
- virtual std::string GetPrintableOptions() const override {
+ std::string GetPrintableOptions() const override {
std::string ret;
ret.reserve(20000);
ret.append(" cache_options:\n");
return ret;
}
- virtual Status StartActivityLogging(const std::string& activity_log_file,
- Env* env,
- uint64_t max_logging_size = 0) override {
+ Status StartActivityLogging(const std::string& activity_log_file, Env* env,
+ uint64_t max_logging_size = 0) override {
return cache_activity_logger_.StartLogging(activity_log_file, env,
max_logging_size);
}
- virtual void StopActivityLogging() override {
- cache_activity_logger_.StopLogging();
- }
+ void StopActivityLogging() override { cache_activity_logger_.StopLogging(); }
- virtual Status GetActivityLoggingStatus() override {
+ Status GetActivityLoggingStatus() override {
return cache_activity_logger_.bg_status();
}