22 #ifndef NDN_CXX_IMS_IN_MEMORY_STORAGE_LFU_HPP
23 #define NDN_CXX_IMS_IN_MEMORY_STORAGE_LFU_HPP
27 #include <boost/multi_index_container.hpp>
28 #include <boost/multi_index/hashed_index.hpp>
29 #include <boost/multi_index/identity.hpp>
30 #include <boost/multi_index/member.hpp>
31 #include <boost/multi_index/ordered_index.hpp>
84 incrementFrequency(CleanupEntry& cleanupEntry)
86 ++cleanupEntry.frequency;
94 using CleanupIndex = boost::multi_index_container<
96 boost::multi_index::indexed_by<
98 boost::multi_index::hashed_unique<
99 boost::multi_index::tag<byEntity>,
100 boost::multi_index::member<CleanupEntry, InMemoryStorageEntry*, &CleanupEntry::entry>
103 boost::multi_index::ordered_non_unique<
104 boost::multi_index::tag<byFrequency>,
105 boost::multi_index::member<CleanupEntry, uint64_t, &CleanupEntry::frequency>,
111 CleanupIndex m_cleanupIndex;
Represents an in-memory storage entry.
Provides an in-memory storage with Least Frequently Used (LFU) replacement policy.
InMemoryStorageLfu(size_t limit=16)
void afterAccess(InMemoryStorageEntry *entry) override
Update the entry when the entry is returned by the find() function, increment the frequency according...
void beforeErase(InMemoryStorageEntry *entry) override
Update the entry or other data structures before a entry is successfully erased, erase it from the cl...
void afterInsert(InMemoryStorageEntry *entry) override
Update the entry after a entry is successfully inserted, add it to the cleanupIndex.
bool evictItem() override
Removes one Data packet from in-memory storage based on LFU, i.e.
Represents in-memory storage.
#define NDN_CXX_PUBLIC_WITH_TESTS_ELSE_PROTECTED