Represents in-memory storage. More...
#include <in-memory-storage.hpp>
Data Structures | |
class | const_iterator |
Represents a self-defined const_iterator for the in-memory storage. More... | |
class | Error |
Represents an error might be thrown during reduce the current capacity of the in-memory storage through function setCapacity(size_t nMaxPackets). More... | |
Public Types | |
typedef boost::multi_index_container< InMemoryStorageEntry *, boost::multi_index::indexed_by< boost::multi_index::ordered_unique< boost::multi_index::tag< byFullName >, boost::multi_index::const_mem_fun< InMemoryStorageEntry, const Name &,&InMemoryStorageEntry::getFullName >, std::less< Name > > > > | Cache |
Public Member Functions | |
InMemoryStorage (size_t limit=std::numeric_limits< size_t >::max()) | |
Create a InMemoryStorage with up to limit entries The InMemoryStorage created through this method will ignore MustBeFresh in interest processing. More... | |
InMemoryStorage (boost::asio::io_service &ioService, size_t limit=std::numeric_limits< size_t >::max()) | |
Create a InMemoryStorage with up to limit entries The InMemoryStorage created through this method will handle MustBeFresh in interest processing. More... | |
virtual | ~InMemoryStorage () |
void | insert (const Data &data, const time::milliseconds &mustBeFreshProcessingWindow=INFINITE_WINDOW) |
Inserts a Data packet. More... | |
shared_ptr< const Data > | find (const Interest &interest) |
Finds the best match Data for an Interest. More... | |
shared_ptr< const Data > | find (const Name &name) |
Finds the best match Data for a Name with or without the implicit digest. More... | |
void | erase (const Name &prefix, const bool isPrefix=true) |
Deletes in-memory storage entry by prefix by default. More... | |
size_t | getLimit () const |
size_t | size () const |
InMemoryStorage::const_iterator | begin () const |
Returns begin iterator of the in-memory storage ordering by name with digest. More... | |
InMemoryStorage::const_iterator | end () const |
Returns end iterator of the in-memory storage ordering by name with digest. More... | |
Static Public Attributes | |
static const time::milliseconds | INFINITE_WINDOW |
Protected Member Functions | |
virtual void | afterAccess (InMemoryStorageEntry *entry) |
Update the entry when the entry is returned by the find() function according to derived class implemented replacement policy. More... | |
virtual void | afterInsert (InMemoryStorageEntry *entry) |
Update the entry or other data structures after a entry is successfully inserted according to derived class implemented replacement policy. More... | |
virtual void | beforeErase (InMemoryStorageEntry *entry) |
Update the entry or other data structures before a entry is successfully erased according to derived class implemented replacement policy. More... | |
virtual bool | evictItem ()=0 |
Removes one Data packet from in-memory storage based on derived class implemented replacement policy. More... | |
void | setCapacity (size_t nMaxPackets) |
sets current capacity of in-memory storage (in packets) More... | |
size_t | getCapacity () const |
returns current capacity of in-memory storage (in packets) More... | |
bool | isFull () const |
returns true if the in-memory storage uses up the current capacity, false otherwise More... | |
void | eraseImpl (const Name &name) |
deletes in-memory storage entries by the Name with implicit digest. More... | |
void | printCache (std::ostream &os) const |
Prints contents of the in-memory storage. More... | |
Represents in-memory storage.
Definition at line 46 of file in-memory-storage.hpp.
typedef boost::multi_index_container< InMemoryStorageEntry*, boost::multi_index::indexed_by< boost::multi_index::ordered_unique< boost::multi_index::tag<byFullName>, boost::multi_index::const_mem_fun<InMemoryStorageEntry, const Name&, &InMemoryStorageEntry::getFullName>, std::less<Name> > > > ndn::util::InMemoryStorage::Cache |
Definition at line 50 of file in-memory-storage.hpp.
|
explicit |
Create a InMemoryStorage with up to limit
entries The InMemoryStorage created through this method will ignore MustBeFresh in interest processing.
Definition at line 89 of file in-memory-storage.cpp.
|
explicit |
Create a InMemoryStorage with up to limit
entries The InMemoryStorage created through this method will handle MustBeFresh in interest processing.
Definition at line 96 of file in-memory-storage.cpp.
|
virtual |
Definition at line 119 of file in-memory-storage.cpp.
|
protectedvirtual |
Update the entry when the entry is returned by the find() function according to derived class implemented replacement policy.
Reimplemented in ndn::util::InMemoryStorageLfu, and ndn::util::InMemoryStorageLru.
Definition at line 442 of file in-memory-storage.cpp.
|
protectedvirtual |
Update the entry or other data structures after a entry is successfully inserted according to derived class implemented replacement policy.
Reimplemented in ndn::util::InMemoryStorageLfu, ndn::util::InMemoryStorageLru, and ndn::util::InMemoryStorageFifo.
Definition at line 432 of file in-memory-storage.cpp.
|
protectedvirtual |
Update the entry or other data structures before a entry is successfully erased according to derived class implemented replacement policy.
Reimplemented in ndn::util::InMemoryStorageLfu, ndn::util::InMemoryStorageLru, and ndn::util::InMemoryStorageFifo.
Definition at line 437 of file in-memory-storage.cpp.
InMemoryStorage::const_iterator ndn::util::InMemoryStorage::begin | ( | ) | const |
Returns begin iterator of the in-memory storage ordering by name with digest.
Definition at line 414 of file in-memory-storage.cpp.
InMemoryStorage::const_iterator ndn::util::InMemoryStorage::end | ( | ) | const |
Returns end iterator of the in-memory storage ordering by name with digest.
Definition at line 422 of file in-memory-storage.cpp.
void ndn::util::InMemoryStorage::erase | ( | const Name & | prefix, |
const bool | isPrefix = true |
||
) |
Deletes in-memory storage entry by prefix by default.
prefix | Exact name of a prefix of the data to remove |
isPrefix | If false, the function will only delete the entry completely matched with the prefix according to canonical ordering. For this case, user should substitute the prefix with full name. |
Definition at line 376 of file in-memory-storage.cpp.
|
protected |
deletes in-memory storage entries by the Name with implicit digest.
This is the function one should use to erase entry in the cache in derived class. It won't invoke beforeErase(shared_ptr<Entry>).
Definition at line 403 of file in-memory-storage.cpp.
|
protectedpure virtual |
Removes one Data packet from in-memory storage based on derived class implemented replacement policy.
Please do not use this function directly in any derived class to erase entry in the cache, use eraseHelper instead.
Implemented in ndn::util::InMemoryStorageLfu, ndn::util::InMemoryStorageLru, ndn::util::InMemoryStorageFifo, and ndn::util::InMemoryStoragePersistent.
Finds the best match Data for an Interest.
Definition at line 225 of file in-memory-storage.cpp.
Finds the best match Data for a Name with or without the implicit digest.
If packets with the same name but different digests exist and the Name supplied is the one without implicit digest, a packet will be arbitrarily chosen to return.
Definition at line 206 of file in-memory-storage.cpp.
|
inlineprotected |
returns current capacity of in-memory storage (in packets)
Definition at line 259 of file in-memory-storage.hpp.
|
inline |
Definition at line 189 of file in-memory-storage.hpp.
void ndn::util::InMemoryStorage::insert | ( | const Data & | data, |
const time::milliseconds & | mustBeFreshProcessingWindow = INFINITE_WINDOW |
||
) |
Inserts a Data packet.
data | the packet to insert |
mustBeFreshProcessingWindow | Beyond this time period after the data is inserted, the data can only be used to answer interest without MustBeFresh selector. |
Definition at line 166 of file in-memory-storage.cpp.
|
inlineprotected |
returns true if the in-memory storage uses up the current capacity, false otherwise
Definition at line 267 of file in-memory-storage.hpp.
|
protected |
Prints contents of the in-memory storage.
Definition at line 447 of file in-memory-storage.cpp.
|
protected |
sets current capacity of in-memory storage (in packets)
Definition at line 136 of file in-memory-storage.cpp.
|
inline |
Definition at line 197 of file in-memory-storage.hpp.
|
static |
Definition at line 324 of file in-memory-storage.hpp.