SWC-DB  v0.5.12 C++ documentations
SWC-DB© (Super Wide Column Database) - High Performance Scalable Database (https://github.com/kashirin-alex/swc-db)
Cache.h
Go to the documentation of this file.
1 /*
2  * SWC-DB© Copyright since 2019 Alex Kashirin <kashirin.alex@gmail.com>
3  * License details at <https://github.com/kashirin-alex/swc-db/#license>
4  */
5 
6 #ifndef swcdb_db_client_rgr_Cache_h
7 #define swcdb_db_client_rgr_Cache_h
8 
9 
13 
15 
16 
17 namespace SWC { namespace client {
18 
19 
20 struct RangeEndPoints final {
21  int64_t ts;
24  RangeEndPoints() noexcept: ts(), endpoints() { }
26  RangeEndPoints(RangeEndPoints&& other) noexcept
27  : ts(other.ts), endpoints(std::move(other.endpoints)) {
28  }
31  ts = other.ts;
32  endpoints = std::move(other.endpoints);
33  return *this;
34  }
36  ~RangeEndPoints() noexcept { }
37 };
38 
39 
40 class CachedRangers final
41  : private std::unordered_map<
42  cid_t, std::unordered_map<rid_t, RangeEndPoints>> {
43 
44  typedef std::unordered_map<
45  cid_t, std::unordered_map<rid_t, RangeEndPoints>> Map;
46 
47  public:
48 
51  : m_mutex(), m_expiry_ms(expiry_ms) {
52  }
53 
54  CachedRangers(const CachedRangers&) = delete;
55 
57 
59  ~CachedRangers() noexcept { }
60 
61  void clear();
62 
63  void clear_expired();
64 
65  void remove(const cid_t cid, const rid_t rid);
66 
67  bool get(const cid_t cid, const rid_t rid, Comm::EndPoints& endpoints);
68 
69  void set(const cid_t cid, const rid_t rid,
70  const Comm::EndPoints& endpoints);
71 
72  private:
73 
76 
77 };
78 
79 
80 
81 }}
82 
83 #ifdef SWC_IMPL_SOURCE
85 #endif
86 
87 #endif // swcdb_db_client_rgr_Cache_h
SWC::client::CachedRangers::operator=
CachedRangers & operator=(const CachedRangers &)=delete
SWC::client::RangeEndPoints::endpoints
Comm::EndPoints endpoints
Definition: Cache.h:22
SWC::client::RangeEndPoints::~RangeEndPoints
SWC_CAN_INLINE ~RangeEndPoints() noexcept
Definition: Cache.h:36
SWC::client::CachedRangers::m_mutex
Core::MutexSptd m_mutex
Definition: Cache.h:74
SWC::client::RangeEndPoints
Definition: Cache.h:20
SWC::client::CachedRangers::CachedRangers
CachedRangers(const CachedRangers &)=delete
SWC::client::CachedRangers
Definition: Cache.h:42
Settings.h
SWC::client::CachedRangers::remove
void remove(const cid_t cid, const rid_t rid)
Definition: Cache.cc:38
SWC::client::CachedRangers::set
void set(const cid_t cid, const rid_t rid, const Comm::EndPoints &endpoints)
Definition: Cache.cc:67
SWC::client::RangeEndPoints::operator=
SWC_CAN_INLINE RangeEndPoints & operator=(RangeEndPoints &&other) noexcept
Definition: Cache.h:30
SWC::client::CachedRangers::Map
std::unordered_map< cid_t, std::unordered_map< rid_t, RangeEndPoints > > Map
Definition: Cache.h:45
Resolver.h
SWC::client::RangeEndPoints::RangeEndPoints
SWC_CAN_INLINE RangeEndPoints(RangeEndPoints &&other) noexcept
Definition: Cache.h:26
SWC_CAN_INLINE
#define SWC_CAN_INLINE
Definition: Compat.h:102
Cache.cc
SWC
The SWC-DB C++ namespace 'SWC'.
Definition: main.cc:12
ContextRanger.h
SWC::client::CachedRangers::m_expiry_ms
Config::Property::Value_int32_g::Ptr m_expiry_ms
Definition: Cache.h:75
SWC::client::CachedRangers::clear
void clear()
Definition: Cache.cc:14
SWC::client::RangeEndPoints::RangeEndPoints
SWC_CAN_INLINE RangeEndPoints() noexcept
Definition: Cache.h:24
SWC::client::CachedRangers::~CachedRangers
SWC_CAN_INLINE ~CachedRangers() noexcept
Definition: Cache.h:59
SWC::client::CachedRangers::clear_expired
void clear_expired()
Definition: Cache.cc:19
Identifiers.h
SWC::cid_t
uint64_t cid_t
Definition: Identifiers.h:16
SWC::Core::Vector< EndPoint >
SWC::rid_t
uint64_t rid_t
Definition: Identifiers.h:17
SWC::Core::MutexSptd
Definition: MutexSptd.h:16
SWC::client::CachedRangers::CachedRangers
SWC_CAN_INLINE CachedRangers(const Config::Property::Value_int32_g::Ptr expiry_ms) noexcept
Definition: Cache.h:50
SWC::client::CachedRangers::get
bool get(const cid_t cid, const rid_t rid, Comm::EndPoints &endpoints)
Definition: Cache.cc:52
SWC::Config::Property::Value_int32_g
Definition: Property.h:586
SWC::client::RangeEndPoints::ts
int64_t ts
Definition: Cache.h:21