NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.0: 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 
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  virtual
49 
55  virtual bool
57 
61  virtual void
63 
66  virtual void
68 
72  virtual void
74 
75 private:
76  //multi_index_container to implement LRU
77  class byUsedTime;
78  class byEntity;
79 
80  typedef boost::multi_index_container<
82  boost::multi_index::indexed_by<
83 
84  // by Entry itself
85  boost::multi_index::hashed_unique<
86  boost::multi_index::tag<byEntity>,
87  boost::multi_index::identity<InMemoryStorageEntry*>
88  >,
89 
90  // by last used time (LRU)
91  boost::multi_index::sequenced<
92  boost::multi_index::tag<byUsedTime>
93  >
94 
95  >
96  > CleanupIndex;
97 
98  CleanupIndex m_cleanupIndex;
99 };
100 
101 } // namespace util
102 } // namespace ndn
103 
104 #endif // NDN_UTIL_IN_MEMORY_STORAGE_LRU_HPP
Copyright (c) 2011-2015 Regents of the University of California.
virtual void beforeErase(InMemoryStorageEntry *entry)
Update the entry or other data structures before a entry is successfully erased, erase it from the cl...
virtual void afterAccess(InMemoryStorageEntry *entry)
Update the entry when the entry is returned by the find() function, update the last used time accordi...
virtual bool evictItem()=0
Removes one Data packet from in-memory storage based on derived class implemented replacement policy...
Represents in-memory storage.
virtual void afterInsert(InMemoryStorageEntry *entry)
Update the entry after a entry is successfully inserted, add it to the cleanupIndex.
Represents an in-memory storage entry.
#define NDN_CXX_PUBLIC_WITH_TESTS_ELSE_PROTECTED
Definition: common.hpp:42
Provides in-memory storage employing LRU replacement policy, of which the least recently used entry w...