Skip to content

Commit 65757ff

Browse files
Add method to list keys (#1638)
Adds interface for the method to list keys available in the cache. Relates-To: HERESDK-8383 Signed-off-by: Mykhailo Diachenko <[email protected]>
1 parent e2da4d1 commit 65757ff

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

olp-cpp-sdk-core/include/olp/core/cache/KeyValueCache.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,20 @@ class CORE_API KeyValueCache {
244244
OLP_SDK_CORE_UNUSED(prefix);
245245
return client::ApiError(client::ErrorCode::Unknown, "Not implemented");
246246
}
247+
248+
/**
249+
* @brief Lists the keys that match the given prefix.
250+
*
251+
* @param prefix The prefix that matches the keys.
252+
*
253+
* @return The collection of matched keys or an error. Empty collection if not
254+
* keys match the prefix.
255+
*/
256+
virtual OperationOutcome<KeyListType> ListKeysWithPrefix(
257+
const std::string& prefix) {
258+
OLP_SDK_CORE_UNUSED(prefix);
259+
return client::ApiError(client::ErrorCode::Unknown, "Not implemented");
260+
}
247261
};
248262

249263
} // namespace cache

olp-cpp-sdk-core/tests/cache/DefaultCacheTest.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -749,6 +749,16 @@ TEST(DefaultCacheTest, OpenTypeCache) {
749749
}
750750
}
751751

752+
TEST(DefaultCacheTest, ListKeysWithPrefixNotImplemented) {
753+
olp::cache::DefaultCache cache;
754+
755+
const auto result = cache.ListKeysWithPrefix("prefix");
756+
757+
EXPECT_FALSE(result.IsSuccessful());
758+
EXPECT_EQ(olp::client::ErrorCode::Unknown, result.GetError().GetErrorCode());
759+
EXPECT_EQ("Not implemented", result.GetError().GetMessage());
760+
}
761+
752762
struct TestParameters {
753763
OptionalString disk_path_mutable = kTempDirMutable;
754764
OptionalString disk_path_protected = olp::porting::none;

0 commit comments

Comments
 (0)