20 #include <ripple/basics/chrono.h>
21 #include <ripple/basics/KeyCache.h>
22 #include <ripple/beast/unit_test.h>
23 #include <ripple/beast/clock/manual_clock.h>
32 using namespace std::chrono_literals;
41 Cache c (
"test", clock, 1, 2s);
43 BEAST_EXPECT(c.size () == 0);
44 BEAST_EXPECT(c.insert (
"one"));
45 BEAST_EXPECT(! c.insert (
"one"));
46 BEAST_EXPECT(c.size () == 1);
47 BEAST_EXPECT(c.exists (
"one"));
48 BEAST_EXPECT(c.touch_if_exists (
"one"));
51 BEAST_EXPECT(c.size () == 1);
52 BEAST_EXPECT(c.exists (
"one"));
55 BEAST_EXPECT(c.size () == 0);
56 BEAST_EXPECT(! c.exists (
"one"));
57 BEAST_EXPECT(! c.touch_if_exists (
"one"));
62 Cache c (
"test", clock, 2, 2s);
64 BEAST_EXPECT(c.insert (
"one"));
65 BEAST_EXPECT(c.size () == 1);
66 BEAST_EXPECT(c.insert (
"two"));
67 BEAST_EXPECT(c.size () == 2);
70 BEAST_EXPECT(c.size () == 2);
71 BEAST_EXPECT(c.touch_if_exists (
"two"));
74 BEAST_EXPECT(c.size () == 1);
75 BEAST_EXPECT(c.exists (
"two"));
80 Cache c (
"test", clock, 2, 3s);
82 BEAST_EXPECT(c.insert (
"one"));
84 BEAST_EXPECT(c.insert (
"two"));
86 BEAST_EXPECT(c.insert (
"three"));
88 BEAST_EXPECT(c.size () == 3);
90 BEAST_EXPECT(c.size () < 3);