Memory cache example
#include <iostream>
int main(int argc, char** argv)
{
int result;
if (cache.
find(
"123", result))
std::cout << "Found: " << result << std::endl;
if (cache.
find(
"456", result))
std::cout << "Found: " << result << std::endl;
if (cache.
find(
"123", result))
std::cout << "Found: " << result << std::endl;
if (cache.
find(
"456", result))
std::cout << "Found: " << result << std::endl;
return 0;
}
void watchdog(const UtcTimestamp &utc=UtcTimestamp())
Watchdog the memory cache.
bool find(const TKey &key)
Try to find the cache value by the given key.
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.
static void SleepFor(const Timespan ×pan) noexcept
Sleep the current thread for the given timespan.
int64_t milliseconds() const noexcept
Get total milliseconds of the current timespan.