@@ -990,6 +990,44 @@ TEST_F(DefaultCacheImplTest, LruCacheEvictionWithProtected) {
990990 }
991991}
992992
993+ TEST_F (DefaultCacheImplTest, InternalKeysBypassLru) {
994+ {
995+ SCOPED_TRACE (" Protect and release keys, which suppose to be evicted" );
996+
997+ const auto internal_key{" internal::protected::protected_data" };
998+ const auto data_string{" this is key's data" };
999+ cache::CacheSettings settings;
1000+ settings.disk_path_mutable = cache_path_;
1001+ {
1002+ settings.eviction_policy = cache::EvictionPolicy::kNone ;
1003+ DefaultCacheImplHelper cache (settings);
1004+ ASSERT_EQ (olp::cache::DefaultCache::Success, cache.Open ());
1005+ cache.Clear ();
1006+
1007+ constexpr auto expiry = 2 ;
1008+ EXPECT_TRUE (cache.Put (internal_key, data_string,
1009+ [data_string]() { return data_string; }, expiry));
1010+ }
1011+
1012+ settings.disk_path_mutable = cache_path_;
1013+ settings.disk_path_protected .reset ();
1014+ settings.eviction_policy = cache::EvictionPolicy::kLeastRecentlyUsed ;
1015+
1016+ DefaultCacheImplHelper cache (settings);
1017+ ASSERT_EQ (olp::cache::DefaultCache::Success, cache.Open ());
1018+
1019+ auto stored_dats = cache.Get (internal_key);
1020+ ASSERT_TRUE (stored_dats);
1021+
1022+ std::string stored_string (
1023+ reinterpret_cast <const char *>(stored_dats->data ()),
1024+ stored_dats->size ());
1025+ EXPECT_EQ (stored_string, data_string);
1026+
1027+ cache.Clear ();
1028+ }
1029+ }
1030+
9931031TEST_F (DefaultCacheImplTest, ReadOnlyPartitionForProtectedCache) {
9941032 SCOPED_TRACE (" Read only partition protected cache" );
9951033 const std::string key{" somekey" };
0 commit comments