NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.0: NDN, CCN, CCNx, content centric networks
API Documentation
in-memory-storage-lru.cpp
Go to the documentation of this file.
1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
22
#include "
in-memory-storage-lru.hpp
"
23
24
namespace
ndn
{
25
namespace
util {
26
27
InMemoryStorageLru::InMemoryStorageLru
(
size_t
limit)
28
:
InMemoryStorage
(limit)
29
{
30
}
31
32
InMemoryStorageLru::InMemoryStorageLru
(boost::asio::io_service& ioService,
33
size_t
limit)
34
:
InMemoryStorage
(ioService, limit)
35
{
36
}
37
38
InMemoryStorageLru::~InMemoryStorageLru
()
39
{
40
}
41
42
void
43
InMemoryStorageLru::afterInsert
(
InMemoryStorageEntry
* entry)
44
{
45
BOOST_ASSERT(m_cleanupIndex.size() <=
size
());
46
InMemoryStorageEntry
* ptr = entry;
47
m_cleanupIndex.insert(ptr);
48
}
49
50
bool
51
InMemoryStorageLru::evictItem
()
52
{
53
if
(!m_cleanupIndex.get<byUsedTime>().empty()) {
54
CleanupIndex::index<byUsedTime>::type::iterator
it = m_cleanupIndex.get<byUsedTime>().
begin
();
55
eraseImpl
((*it)->getFullName());
56
m_cleanupIndex.get<byUsedTime>().
erase
(it);
57
return
true
;
58
}
59
60
return
false
;
61
}
62
63
void
64
InMemoryStorageLru::beforeErase
(
InMemoryStorageEntry
* entry)
65
{
66
CleanupIndex::index<byEntity>::type::iterator
it = m_cleanupIndex.get<byEntity>().
find
(entry);
67
if
(it != m_cleanupIndex.get<byEntity>().end())
68
m_cleanupIndex.get<byEntity>().erase(it);
69
}
70
71
void
72
InMemoryStorageLru::afterAccess
(
InMemoryStorageEntry
* entry)
73
{
74
beforeErase
(entry);
75
afterInsert
(entry);
76
}
77
78
}
// namespace util
79
}
// namespace ndn
ndn
Copyright (c) 2011-2015 Regents of the University of California.
Definition:
ndn-strategy-choice-helper.hpp:34
ndn::util::InMemoryStorage::find
shared_ptr< const Data > find(const Interest &interest)
Finds the best match Data for an Interest.
Definition:
in-memory-storage.cpp:226
ndn::util::InMemoryStorage::size
size_t size() const
Definition:
in-memory-storage.hpp:197
in-memory-storage-lru.hpp
ndn::util::InMemoryStorageLru::beforeErase
virtual void beforeErase(InMemoryStorageEntry *entry)
Update the entry or other data structures before a entry is successfully erased, erase it from the cl...
Definition:
in-memory-storage-lru.cpp:64
ndn::util::InMemoryStorageLru::afterAccess
virtual void afterAccess(InMemoryStorageEntry *entry)
Update the entry when the entry is returned by the find() function, update the last used time accordi...
Definition:
in-memory-storage-lru.cpp:72
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::InMemoryStorage::eraseImpl
void eraseImpl(const Name &name)
deletes in-memory storage entries by the Name with implicit digest.
Definition:
in-memory-storage.cpp:404
nfd::cs::iterator
Table::const_iterator iterator
Definition:
cs-internal.hpp:41
ndn::util::InMemoryStorage::begin
InMemoryStorage::const_iterator begin() const
Returns begin iterator of the in-memory storage ordering by name with digest.
Definition:
in-memory-storage.cpp:415
ndn::util::InMemoryStorage
Represents in-memory storage.
Definition:
in-memory-storage.hpp:46
ndn::util::InMemoryStorageLru::afterInsert
virtual void afterInsert(InMemoryStorageEntry *entry)
Update the entry after a entry is successfully inserted, add it to the cleanupIndex.
Definition:
in-memory-storage-lru.cpp:43
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::util::InMemoryStorageLru::~InMemoryStorageLru
virtual ~InMemoryStorageLru()
Definition:
in-memory-storage-lru.cpp:38
ndn::util::InMemoryStorage::erase
void erase(const Name &prefix, const bool isPrefix=true)
Deletes in-memory storage entry by prefix by default.
Definition:
in-memory-storage.cpp:377
ndnSIM
ndn-cxx
src
util
in-memory-storage-lru.cpp
Generated on Sat Nov 12 2016 16:02:53 for ndnSIM by
1.8.12