diff options
author | dinmukhammed <dinmukhammed@yandex-team.ru> | 2022-02-14 19:28:07 +0300 |
---|---|---|
committer | dinmukhammed <dinmukhammed@yandex-team.ru> | 2022-02-14 19:28:07 +0300 |
commit | 0cc79cc258de4e974b67e969795d843fa16ee29f (patch) | |
tree | 63a853094df42458e8cd80f9b4871ab554f7aac4 | |
parent | c05a3101b2209fff1587bf4d0df33f28d94d76bd (diff) | |
download | ydb-0cc79cc258de4e974b67e969795d843fa16ee29f.tar.gz |
TtlCache ut for getting only fresh values from cache
Added ut
ref:94e5399dde31cc83d59871751ddf8983473f3050
-rw-r--r-- | ydb/core/yq/libs/common/cache_ut.cpp | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/ydb/core/yq/libs/common/cache_ut.cpp b/ydb/core/yq/libs/common/cache_ut.cpp index 4e5ace033d..7ffdd548c3 100644 --- a/ydb/core/yq/libs/common/cache_ut.cpp +++ b/ydb/core/yq/libs/common/cache_ut.cpp @@ -55,4 +55,14 @@ Y_UNIT_TEST_SUITE(Cache) { cache.Put(102, TMaybe<int>()); UNIT_ASSERT_VALUES_EQUAL(cache.Size(), 2); } + + Y_UNIT_TEST(Test5) { + TCache cache(TTtlCacheSettings().SetTtl(TDuration::Seconds(1)).SetMaxSize(3)); + cache.Put(100, 10); + UNIT_ASSERT_VALUES_EQUAL(cache.Size(), 1); + Sleep(TDuration::Seconds(1)); + TMaybe<int> t; + UNIT_ASSERT_VALUES_EQUAL(cache.Get(100, &t), false); + UNIT_ASSERT_VALUES_EQUAL(cache.Size(), 0); + } } |