diff --git a/olp-cpp-sdk-core/include/olp/core/cache/KeyValueCache.h b/olp-cpp-sdk-core/include/olp/core/cache/KeyValueCache.h index 742f86749..8767be6fd 100644 --- a/olp-cpp-sdk-core/include/olp/core/cache/KeyValueCache.h +++ b/olp-cpp-sdk-core/include/olp/core/cache/KeyValueCache.h @@ -244,6 +244,20 @@ class CORE_API KeyValueCache { OLP_SDK_CORE_UNUSED(prefix); return client::ApiError(client::ErrorCode::Unknown, "Not implemented"); } + + /** + * @brief Lists the keys that match the given prefix. + * + * @param prefix The prefix that matches the keys. + * + * @return The collection of matched keys or an error. Empty collection if not + * keys match the prefix. + */ + virtual OperationOutcome ListKeysWithPrefix( + const std::string& prefix) { + OLP_SDK_CORE_UNUSED(prefix); + return client::ApiError(client::ErrorCode::Unknown, "Not implemented"); + } }; } // namespace cache diff --git a/olp-cpp-sdk-core/tests/cache/DefaultCacheTest.cpp b/olp-cpp-sdk-core/tests/cache/DefaultCacheTest.cpp index f93399c72..a793e7f06 100644 --- a/olp-cpp-sdk-core/tests/cache/DefaultCacheTest.cpp +++ b/olp-cpp-sdk-core/tests/cache/DefaultCacheTest.cpp @@ -749,6 +749,16 @@ TEST(DefaultCacheTest, OpenTypeCache) { } } +TEST(DefaultCacheTest, ListKeysWithPrefixNotImplemented) { + olp::cache::DefaultCache cache; + + const auto result = cache.ListKeysWithPrefix("prefix"); + + EXPECT_FALSE(result.IsSuccessful()); + EXPECT_EQ(olp::client::ErrorCode::Unknown, result.GetError().GetErrorCode()); + EXPECT_EQ("Not implemented", result.GetError().GetMessage()); +} + struct TestParameters { OptionalString disk_path_mutable = kTempDirMutable; OptionalString disk_path_protected = olp::porting::none;