See Public API for a list of names and headers that are part of the public HPX API.

namespace hpx
namespace util
namespace cache
namespace entries
template<typename Value>
class lfu_entry : public hpx::util::cache::entries::entry<Value, lfu_entry<Value>>
#include <hpx/cache/entries/lfu_entry.hpp>

The lfu_entry type can be used to store arbitrary values in a cache. Using this type as the cache’s entry type makes sure that the least frequently used entries are discarded from the cache first.


The lfu_entry conforms to the CacheEntry concept.


This type can be used to model a ‘most frequently used’ cache policy if it is used with a std::greater as the caches’ UpdatePolicy (instead of the default std::less).

Template Parameters
  • Value: The data type to be stored in a cache. It has to be default constructible, copy constructible and less_than_comparable.

Public Functions


Any cache entry has to be default constructible.

lfu_entry(Value const &val)

Construct a new instance of a cache entry holding the given value.

lfu_entry(Value &&val)

Construct a new instance of a cache entry holding the given value.

bool touch()

The function touch is called by a cache holding this instance whenever it has been requested (touched).

In the case of the LFU entry we store the reference count tracking the number of times this entry has been requested. This which will be used to compare the age of an entry during the invocation of the operator<().


This function should return true if the cache needs to update it’s internal heap. Usually this is needed if the entry has been changed by touch() in a way influencing the sort order as mandated by the cache’s UpdatePolicy

constexpr unsigned long const &get_access_count() const

Private Types

using base_type = entry<Value, lfu_entry<Value>>

Private Members

unsigned long ref_count_ = 0


bool operator<(lfu_entry const &lhs, lfu_entry const &rhs)

Compare the ‘age’ of two entries. An entry is ‘older’ than another entry if it has been accessed less frequently (LFU).