Skip to content

Commit 9b007a6

Browse files
haowu14facebook-github-bot
authored andcommitted
Use CounterVisitor for object cache
Summary: As title. We want to kill the isRate check in ServiceDataExporter Reviewed By: jiayuebao Differential Revision: D41112361 fbshipit-source-id: fb5c80631fe970d2d05de4ef860db5f5432c1fa7
1 parent 21674e4 commit 9b007a6

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

cachelib/allocator/Cache.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#include "cachelib/allocator/ICompactCache.h"
2727
#include "cachelib/allocator/memory/MemoryAllocator.h"
2828
#include "cachelib/common/Hash.h"
29+
#include "cachelib/common/Utils.h"
2930

3031
namespace facebook {
3132
namespace cachelib {
@@ -194,8 +195,7 @@ class CacheBase {
194195
virtual const ICompactCache& getCompactCache(PoolId pid) const = 0;
195196

196197
// return object cache stats
197-
virtual void getObjectCacheCounters(
198-
std::function<void(folly::StringPiece, uint64_t)>) const {}
198+
virtual void getObjectCacheCounters(const util::CounterVisitor&) const {}
199199

200200
protected:
201201
// move bytes from one pool to another. The source pool should be at least

cachelib/experimental/objcache2/ObjectCache-inl.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ void ObjectCache<AllocatorT>::remove(folly::StringPiece key) {
313313

314314
template <typename AllocatorT>
315315
void ObjectCache<AllocatorT>::getObjectCacheCounters(
316-
std::function<void(folly::StringPiece, uint64_t)> visitor) const {
316+
const util::CounterVisitor& visitor) const {
317317
visitor("objcache.lookups", lookups_.get());
318318
visitor("objcache.lookups.l1_hits", succL1Lookups_.get());
319319
visitor("objcache.inserts", inserts_.get());

cachelib/experimental/objcache2/ObjectCache.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ class ObjectCache : public ObjectCacheBase<AllocatorT> {
206206
// @param visitor callback that will be invoked with
207207
// {stat-name, value} for each stat
208208
void getObjectCacheCounters(
209-
std::function<void(folly::StringPiece, uint64_t)> visitor) const override;
209+
const util::CounterVisitor& visitor) const override;
210210

211211
// Return the number of objects in cache
212212
uint64_t getNumEntries() const {

0 commit comments

Comments
 (0)