Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions cachelib/allocator/Cache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@
namespace facebook {
namespace cachelib {

CacheBase::CacheBase(unsigned numTiers): numTiers_(numTiers) {}

unsigned CacheBase::getNumTiers() const {
return numTiers_;
}

void CacheBase::setRebalanceStrategy(
PoolId pid, std::shared_ptr<RebalanceStrategy> strategy) {
std::unique_lock<std::mutex> l(lock_);
Expand Down
9 changes: 8 additions & 1 deletion cachelib/allocator/Cache.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ enum class RemoveContext { kEviction, kNormal };
// A base class of cache exposing members and status agnostic of template type.
class CacheBase {
public:
CacheBase() = default;
CacheBase(unsigned numTiers = 1);
virtual ~CacheBase() = default;

// Movable but not copyable
Expand All @@ -65,6 +65,9 @@ class CacheBase {
CacheBase(CacheBase&&) = default;
CacheBase& operator=(CacheBase&&) = default;

// TODO: come up with some reasonable number
static constexpr unsigned kMaxTiers = 8;

// Get a string referring to the cache name for this cache
virtual const std::string getCacheName() const = 0;

Expand Down Expand Up @@ -253,6 +256,10 @@ class CacheBase {
// @return The number of slabs that were actually reclaimed (<= numSlabs)
virtual unsigned int reclaimSlabs(PoolId id, size_t numSlabs) = 0;

unsigned getNumTiers() const;

unsigned numTiers_ = 1;

// Protect 'poolRebalanceStragtegies_' and `poolResizeStrategies_`
// and `poolOptimizeStrategy_`
mutable std::mutex lock_;
Expand Down
Loading