X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=src%2Fredis%2Fasyncredisstorage.cpp;h=6f74020e302fac059d68d96ae6b6ce91879fcc8b;hb=63869e10ac4d8572238989e1b582c0314da91f9c;hp=482d6d7456df497a50efaaa9f8e3685986482a4c;hpb=69b0a71f5fe8825fa45ee9502a41fd8b465c44e0;p=ric-plt%2Fsdl.git diff --git a/src/redis/asyncredisstorage.cpp b/src/redis/asyncredisstorage.cpp index 482d6d7..6f74020 100644 --- a/src/redis/asyncredisstorage.cpp +++ b/src/redis/asyncredisstorage.cpp @@ -512,9 +512,9 @@ void AsyncRedisStorage::removeAsync(const Namespace& ns, contentsBuilder->build("DEL", ns, keys)); } -void AsyncRedisStorage::findKeysAsync(const Namespace& ns, - const std::string& keyPrefix, - const FindKeysAck& findKeysAck) +void AsyncRedisStorage::findKeys(const Namespace& ns, + const std::string& keyPattern, + const FindKeysAck& findKeysAck) { //TODO: update to more optimal solution than current KEYS-based one. std::error_code ec; @@ -533,7 +533,23 @@ void AsyncRedisStorage::findKeysAsync(const Namespace& ns, findKeysAck(std::error_code(), getKeys(*reply.getArray())); }, ns, - contentsBuilder->build("KEYS", buildKeyPrefixSearchPattern(ns, keyPrefix))); + contentsBuilder->build("KEYS", keyPattern)); +} + +void AsyncRedisStorage::findKeysAsync(const Namespace& ns, + const std::string& keyPrefix, + const FindKeysAck& findKeysAck) +{ + auto keyPattern(buildKeyPrefixSearchPattern(ns, keyPrefix)); + findKeys(ns, keyPattern, findKeysAck); +} + +void AsyncRedisStorage::listKeys(const Namespace& ns, + const std::string& pattern, + const FindKeysAck& findKeysAck) +{ + auto keyPattern(buildNamespaceKeySearchPattern(ns, pattern)); + findKeys(ns, keyPattern, findKeysAck); } void AsyncRedisStorage::removeAllAsync(const Namespace& ns, @@ -574,3 +590,11 @@ std::string AsyncRedisStorage::buildKeyPrefixSearchPattern(const Namespace& ns, oss << '{' << ns << '}' << SEPARATOR << escapedKeyPrefix << "*"; return oss.str(); } + +std::string AsyncRedisStorage::buildNamespaceKeySearchPattern(const Namespace& ns, + const std::string& pattern) const +{ + std::ostringstream oss; + oss << '{' << ns << '}' << SEPARATOR << pattern; + return oss.str(); +}