-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
27 lines (25 loc) · 831 Bytes
/
main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#include <iomanip>
#include <iostream>
#include <chrono>
#include <thread>
#include "cachehandler.h"
int main()
{
CacheHandler<std::time_t, int, int> cacheHandler([](int a, int b) ->std::time_t {
std::chrono::system_clock::time_point t = std::chrono::system_clock::now();
std::time_t c = std::chrono::system_clock::to_time_t(t);
return c;
}, 5000);
auto result = [&]() {
const auto c = cacheHandler.value(0, 1);
std::cout << "Cache time: " << std::put_time(std::localtime(&c), "%F %T") << std::endl;
};
result();
std::this_thread::sleep_for(std::chrono::milliseconds(1000));
result();
std::this_thread::sleep_for(std::chrono::milliseconds(1000));
result();
std::this_thread::sleep_for(std::chrono::milliseconds(5000));
result();
return 0;
}