ndn::util::InMemoryStorageFifo Class Reference

Provides in-memory storage employing FIFO replacement policy, which is first in first out. More...

#include <in-memory-storage-fifo.hpp>

Inheritance diagram for ndn::util::InMemoryStorageFifo:
[legend]
Collaboration diagram for ndn::util::InMemoryStorageFifo:
[legend]

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

 InMemoryStorageFifo (size_t limit=10)
 
 InMemoryStorageFifo (boost::asio::io_service &ioService, size_t limit=10)
 
void insert (const Data &data, const time::milliseconds &mustBeFreshProcessingWindow=INFINITE_WINDOW)
 Inserts a Data packet. More...
 
shared_ptr< const Datafind (const Interest &interest)
 Finds the best match Data for an Interest. More...
 
shared_ptr< const Datafind (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

bool evictItem () override
 Removes one Data packet from in-memory storage based on FIFO. More...
 
void afterInsert (InMemoryStorageEntry *entry) override
 Update the entry after a entry is successfully inserted, add it to the cleanupIndex. More...
 
void beforeErase (InMemoryStorageEntry *entry) override
 Update the entry or other data structures before a entry is successfully erased, erase it from the cleanupIndex. More...
 
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...
 
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...
 

Detailed Description

Provides in-memory storage employing FIFO replacement policy, which is first in first out.

Definition at line 37 of file in-memory-storage-fifo.hpp.

Member Typedef Documentation

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
inherited

Definition at line 50 of file in-memory-storage.hpp.

Constructor & Destructor Documentation

ndn::util::InMemoryStorageFifo::InMemoryStorageFifo ( size_t  limit = 10)
explicit

Definition at line 27 of file in-memory-storage-fifo.cpp.

ndn::util::InMemoryStorageFifo::InMemoryStorageFifo ( boost::asio::io_service &  ioService,
size_t  limit = 10 
)
explicit

Definition at line 32 of file in-memory-storage-fifo.cpp.

Member Function Documentation

void ndn::util::InMemoryStorage::afterAccess ( InMemoryStorageEntry entry)
protectedvirtualinherited

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.

void ndn::util::InMemoryStorageFifo::afterInsert ( InMemoryStorageEntry entry)
overrideprotectedvirtual

Update the entry after a entry is successfully inserted, add it to the cleanupIndex.

Reimplemented from ndn::util::InMemoryStorage.

Definition at line 38 of file in-memory-storage-fifo.cpp.

void ndn::util::InMemoryStorageFifo::beforeErase ( InMemoryStorageEntry entry)
overrideprotectedvirtual

Update the entry or other data structures before a entry is successfully erased, erase it from the cleanupIndex.

Reimplemented from ndn::util::InMemoryStorage.

Definition at line 58 of file in-memory-storage-fifo.cpp.

InMemoryStorage::const_iterator ndn::util::InMemoryStorage::begin ( ) const
inherited

Returns begin iterator of the in-memory storage ordering by name with digest.

Returns
{ const_iterator pointing to the beginning of the m_cache }

Definition at line 414 of file in-memory-storage.cpp.

InMemoryStorage::const_iterator ndn::util::InMemoryStorage::end ( ) const
inherited

Returns end iterator of the in-memory storage ordering by name with digest.

Returns
{ const_iterator pointing to the end of the m_cache }

Definition at line 422 of file in-memory-storage.cpp.

void ndn::util::InMemoryStorage::erase ( const Name prefix,
const bool  isPrefix = true 
)
inherited

Deletes in-memory storage entry by prefix by default.

Parameters
prefixExact name of a prefix of the data to remove
isPrefixIf 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.
Note
Please do not use this function directly in any derived class to erase entry in the cache, use eraseHelper instead.
It will invoke beforeErase(shared_ptr<InMemoryStorageEntry>).

Definition at line 376 of file in-memory-storage.cpp.

void ndn::util::InMemoryStorage::eraseImpl ( const Name name)
protectedinherited

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.

bool ndn::util::InMemoryStorageFifo::evictItem ( )
overrideprotectedvirtual

Removes one Data packet from in-memory storage based on FIFO.

Returns
{ whether the Data was removed }

Implements ndn::util::InMemoryStorage.

Definition at line 45 of file in-memory-storage-fifo.cpp.

shared_ptr< const Data > ndn::util::InMemoryStorage::find ( const Interest interest)
inherited

Finds the best match Data for an Interest.

Note
It will invoke afterAccess(shared_ptr<InMemoryStorageEntry>). As currently it is impossible to determine whether a Name contains implicit digest or not, therefore this find function is not able to locate a packet according to an interest( including implicit digest) whose name is not the full name of the data matching the implicit digest.
Returns
{ the best match, if any; otherwise a null shared_ptr }

Definition at line 225 of file in-memory-storage.cpp.

shared_ptr< const Data > ndn::util::InMemoryStorage::find ( const Name name)
inherited

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.

Note
It will invoke afterAccess(shared_ptr<InMemoryStorageEntry>).
Returns
{ the one matched the Name; otherwise a null shared_ptr }

Definition at line 206 of file in-memory-storage.cpp.

size_t ndn::util::InMemoryStorage::getCapacity ( ) const
inlineprotectedinherited

returns current capacity of in-memory storage (in packets)

Returns
{ number of packets that can be stored in application cache }

Definition at line 259 of file in-memory-storage.hpp.

size_t ndn::util::InMemoryStorage::getLimit ( ) const
inlineinherited
Returns
{ maximum number of packets that can be allowed to store in in-memory storage }

Definition at line 189 of file in-memory-storage.hpp.

void ndn::util::InMemoryStorage::insert ( const Data data,
const time::milliseconds &  mustBeFreshProcessingWindow = INFINITE_WINDOW 
)
inherited

Inserts a Data packet.

Parameters
datathe packet to insert
mustBeFreshProcessingWindowBeyond this time period after the data is inserted, the data can only be used to answer interest without MustBeFresh selector.
Note
Packets are considered duplicate if the name with implicit digest matches. The new Data packet with the identical name, but a different payload will be placed in the in-memory storage.
It will invoke afterInsert(shared_ptr<InMemoryStorageEntry>).

Definition at line 166 of file in-memory-storage.cpp.

bool ndn::util::InMemoryStorage::isFull ( ) const
inlineprotectedinherited

returns true if the in-memory storage uses up the current capacity, false otherwise

Definition at line 267 of file in-memory-storage.hpp.

void ndn::util::InMemoryStorage::printCache ( std::ostream &  os) const
protectedinherited

Prints contents of the in-memory storage.

Definition at line 447 of file in-memory-storage.cpp.

void ndn::util::InMemoryStorage::setCapacity ( size_t  nMaxPackets)
protectedinherited

sets current capacity of in-memory storage (in packets)

Definition at line 136 of file in-memory-storage.cpp.

size_t ndn::util::InMemoryStorage::size ( ) const
inlineinherited
Returns
{ number of packets stored in in-memory storage }

Definition at line 197 of file in-memory-storage.hpp.

Field Documentation

const time::milliseconds ndn::util::InMemoryStorage::INFINITE_WINDOW
staticinherited

Definition at line 324 of file in-memory-storage.hpp.