NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.3: NDN, CCN, CCNx, content centric networks
API Documentation
in-memory-storage-lru.hpp
Go to the documentation of this file.
1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
22
#ifndef NDN_UTIL_IN_MEMORY_STORAGE_LRU_HPP
23
#define NDN_UTIL_IN_MEMORY_STORAGE_LRU_HPP
24
25
#include "
in-memory-storage.hpp
"
26
27
#include <boost/multi_index/member.hpp>
28
#include <boost/multi_index_container.hpp>
29
#include <boost/multi_index/sequenced_index.hpp>
30
#include <boost/multi_index/hashed_index.hpp>
31
#include <boost/multi_index/identity.hpp>
32
33
namespace
ndn
{
34
namespace
util {
35
39
class
InMemoryStorageLru
:
public
InMemoryStorage
40
{
41
public
:
42
explicit
43
InMemoryStorageLru
(
size_t
limit = 10);
44
45
InMemoryStorageLru
(boost::asio::io_service& ioService,
size_t
limit = 10);
46
47
NDN_CXX_PUBLIC_WITH_TESTS_ELSE_PROTECTED
:
52
virtual
bool
53
evictItem
()
override
;
54
58
virtual
void
59
afterAccess
(
InMemoryStorageEntry
* entry)
override
;
60
63
virtual
void
64
afterInsert
(
InMemoryStorageEntry
* entry)
override
;
65
69
virtual
void
70
beforeErase
(
InMemoryStorageEntry
* entry)
override
;
71
72
private
:
73
//multi_index_container to implement LRU
74
class
byUsedTime;
75
class
byEntity;
76
77
typedef
boost::multi_index_container<
78
InMemoryStorageEntry
*,
79
boost::multi_index::indexed_by<
80
81
// by Entry itself
82
boost::multi_index::hashed_unique<
83
boost::multi_index::tag<byEntity>,
84
boost::multi_index::identity<InMemoryStorageEntry*>
85
>,
86
87
// by last used time (LRU)
88
boost::multi_index::sequenced<
89
boost::multi_index::tag<byUsedTime>
90
>
91
92
>
93
> CleanupIndex;
94
95
CleanupIndex m_cleanupIndex;
96
};
97
98
}
// namespace util
99
}
// namespace ndn
100
101
#endif // NDN_UTIL_IN_MEMORY_STORAGE_LRU_HPP
ndn
Copyright (c) 2011-2015 Regents of the University of California.
Definition:
ndn-strategy-choice-helper.hpp:34
in-memory-storage.hpp
ndn::util::InMemoryStorageLru::afterAccess
virtual void afterAccess(InMemoryStorageEntry *entry) override
Update the entry when the entry is returned by the find() function, update the last used time accordi...
Definition:
in-memory-storage-lru.cpp:68
ndn::util::InMemoryStorage::evictItem
virtual bool evictItem()=0
Removes one Data packet from in-memory storage based on derived class implemented replacement policy...
ndn::util::InMemoryStorageLru::afterInsert
virtual void afterInsert(InMemoryStorageEntry *entry) override
Update the entry after a entry is successfully inserted, add it to the cleanupIndex.
Definition:
in-memory-storage-lru.cpp:39
ndn::util::InMemoryStorage
Represents in-memory storage.
Definition:
in-memory-storage.hpp:46
ndn::util::InMemoryStorageLru::beforeErase
virtual void beforeErase(InMemoryStorageEntry *entry) override
Update the entry or other data structures before a entry is successfully erased, erase it from the cl...
Definition:
in-memory-storage-lru.cpp:60
ndn::util::InMemoryStorageLru::InMemoryStorageLru
InMemoryStorageLru(size_t limit=10)
Definition:
in-memory-storage-lru.cpp:27
ndn::util::InMemoryStorageEntry
Represents an in-memory storage entry.
Definition:
in-memory-storage-entry.hpp:35
NDN_CXX_PUBLIC_WITH_TESTS_ELSE_PROTECTED
#define NDN_CXX_PUBLIC_WITH_TESTS_ELSE_PROTECTED
Definition:
common.hpp:42
ndn::util::InMemoryStorageLru
Provides in-memory storage employing LRU replacement policy, of which the least recently used entry w...
Definition:
in-memory-storage-lru.hpp:39
ndnSIM
ndn-cxx
src
util
in-memory-storage-lru.hpp
Generated on Wed Jan 11 2017 18:17:14 for ndnSIM by
1.8.13