|
ndn-embeds 0.1.0
Lightweight NDN protocol stack for embedded systems
|
Content Store. More...
#include <ndn/cs.hpp>
Classes | |
| struct | Stats |
| CS statistics. More... | |
Public Member Functions | |
| ContentStore ()=default | |
| Default constructor. | |
| ~ContentStore () | |
| Destructor. | |
| ContentStore (const ContentStore &)=delete | |
| ContentStore & | operator= (const ContentStore &)=delete |
| ContentStore (ContentStore &&)=delete | |
| ContentStore & | operator= (ContentStore &&)=delete |
| Error | init (size_t maxEntries=CS_DEFAULT_ENTRIES) |
| Initialize the Content Store. | |
Data management | |
| Error | insert (const Data &data, TimeMs now) |
| Insert Data into the cache. | |
| const CsEntry * | find (const Name &name, bool mustBeFresh=false, TimeMs now=0) const |
| Search the cache by Name. | |
| void | remove (const Name &name) |
| Remove the entry with the specified Name. | |
| void | evictStale (TimeMs now) |
| Remove stale entries. | |
Statistics | |
| size_t | size () const |
| Get the current number of entries. | |
| size_t | capacity () const |
| Get the maximum number of entries. | |
| const Stats & | stats () const |
| Get statistics. | |
Content Store.
One of the core components of the forwarder. Caches received Data and can respond to subsequent Interests without forwarding to the network.
Uses an LRU (Least Recently Used) replacement policy.
| ndn::ContentStore::~ContentStore | ( | ) |
|
inline |
| void ndn::ContentStore::evictStale | ( | TimeMs | now | ) |
Remove stale entries.
Removes all entries that have exceeded their staleTime.
| now | Current time (milliseconds) |
Definition at line 144 of file cs.cpp.
References ndn::ContentStore::Stats::evictions.
Referenced by ndn::Forwarder::processEvents().
| Error ndn::ContentStore::init | ( | size_t | maxEntries = CS_DEFAULT_ENTRIES | ) |
Initialize the Content Store.
Allocates the entry array on PSRAM. This function must be called exactly once.
| maxEntries | Maximum number of entries (default: CS_DEFAULT_ENTRIES) |
Definition at line 33 of file cs.cpp.
Referenced by ndn::Forwarder::init().
Insert Data into the cache.
Overwrites if an entry with the same Name exists. If the cache is full, the oldest entry is evicted using the LRU policy.
| data | Data to cache |
| now | Current time (milliseconds) |
Definition at line 61 of file cs.cpp.
References ndn::ContentStore::Stats::evictions, ndn::Data::freshnessPeriod(), ndn::ContentStore::Stats::insertions, and ndn::Data::name().
Referenced by ndn::Forwarder::putData().
| void ndn::ContentStore::remove | ( | const Name & | name | ) |
|
inline |
|
inline |