CppCommon
1.0.4.1
C++ Common Library
|
#include <memcache.h>
Public Member Functions | |
MemCache ()=default | |
MemCache (const MemCache &)=delete | |
MemCache (MemCache &&)=delete | |
~MemCache ()=default | |
MemCache & | operator= (const MemCache &)=delete |
MemCache & | operator= (MemCache &&)=delete |
operator bool () const | |
Check if the memory cache is not empty. More... | |
bool | empty () const |
Is the memory cache empty? More... | |
size_t | size () const |
Get the memory cache size. More... | |
bool | emplace (TKey &&key, TValue &&value, const Timespan &timeout=Timespan(0)) |
Emplace a new cache value with the given timeout into the memory cache. More... | |
bool | insert (const TKey &key, const TValue &value, const Timespan &timeout=Timespan(0)) |
Insert a new cache value with the given timeout into the memory cache. More... | |
bool | find (const TKey &key) |
Try to find the cache value by the given key. More... | |
bool | find (const TKey &key, TValue &value) |
Try to find the cache value by the given key. More... | |
bool | find (const TKey &key, TValue &value, Timestamp &timeout) |
Try to find the cache value with timeout by the given key. More... | |
bool | remove (const TKey &key) |
Remove the cache value with the given key from the memory cache. More... | |
void | clear () |
Clear the memory cache. More... | |
void | watchdog (const UtcTimestamp &utc=UtcTimestamp()) |
Watchdog the memory cache. More... | |
void | swap (MemCache &cache) noexcept |
Swap two instances. More... | |
Friends | |
template<typename UKey , typename UValue > | |
void | swap (MemCache< UKey, UValue > &cache1, MemCache< UKey, UValue > &cache2) noexcept |
Memory cache.
Memory cache is used to cache data in memory with optional timeouts.
Thread-safe.
Definition at line 29 of file memcache.h.
|
default |
|
delete |
|
delete |
|
default |
|
inline |
Clear the memory cache.
Definition at line 138 of file memcache.inl.
|
inline |
Emplace a new cache value with the given timeout into the memory cache.
key | - Key to emplace |
value | - Value to emplace |
timeout | - Cache timeout (default is 0 - no timeout) |
Definition at line 26 of file memcache.inl.
|
inline |
Is the memory cache empty?
Definition at line 12 of file memcache.inl.
|
inline |
Try to find the cache value by the given key.
key | - Key to find |
Definition at line 70 of file memcache.inl.
|
inline |
Try to find the cache value by the given key.
key | - Key to find |
value | - Value to find |
Definition at line 83 of file memcache.inl.
|
inline |
Try to find the cache value with timeout by the given key.
key | - Key to find |
value | - Value to find |
timeout | - Cache timeout value |
Definition at line 97 of file memcache.inl.
|
inline |
Insert a new cache value with the given timeout into the memory cache.
key | - Key to insert |
value | - Value to insert |
timeout | - Cache timeout (default is 0 - no timeout) |
Definition at line 48 of file memcache.inl.
|
inlineexplicit |
Check if the memory cache is not empty.
Definition at line 41 of file memcache.h.
|
delete |
|
delete |
|
inline |
Remove the cache value with the given key from the memory cache.
key | - Key to remove |
Definition at line 112 of file memcache.inl.
|
inline |
Get the memory cache size.
Definition at line 19 of file memcache.inl.
|
inlinenoexcept |
Swap two instances.
Definition at line 172 of file memcache.inl.
|
inline |
|
friend |