New listKeys() API to support glob-style key search patterns
[ric-plt/sdl.git] / include / sdl / asyncstorage.hpp
index c20c7b1..ae1f959 100644 (file)
    limitations under the License.
 */
 
+/*
+ * This source code is part of the near-RT RIC (RAN Intelligent Controller)
+ * platform project (RICP).
+*/
+
 #ifndef SHAREDDATALAYER_ASYNCSTORAGE_HPP_
 #define SHAREDDATALAYER_ASYNCSTORAGE_HPP_
 
@@ -287,7 +292,7 @@ namespace shareddatalayer
         using FindKeysAck = std::function<void(const std::error_code& error, const Keys& keys)>;
 
         /**
-         * Find all keys matching search pattern under the namespace. No prior knowledge about the keys in the given
+         * Find all keys matching search key prefix under the namespace. No prior knowledge about the keys in the given
          * namespace exists, thus operation is not guaranteed to be atomic or isolated.
          *
          * @param ns Namespace under which this operation is targeted.
@@ -296,10 +301,34 @@ namespace shareddatalayer
          * @param findKeysAck The acknowledgement to be called once the request has been handled.
          *                    The given function is called in the context of handleEvents() function.
          */
+        [[deprecated("Use listKeys() instead.")]]
         virtual void findKeysAsync(const Namespace& ns,
                                    const std::string& keyPrefix,
                                    const FindKeysAck& findKeysAck) = 0;
 
+        /**
+         * List all keys matching search glob-style pattern under the namespace.
+         *
+         * Supported glob-style patterns:
+         *   h?llo matches hello, hallo and hxllo
+         *   h*llo matches hllo and heeeello
+         *   h[ae]llo matches hello and hallo, but not hillo
+         *   h[^e]llo matches hallo, hbllo, ... but not hello
+         *   h[a-b]llo matches hallo and hbllo
+         *
+         * The \ escapes character(s) in key search pattern and those will be treated as a normal
+         * character(s):
+         *   h\[?llo\* matches h[ello* and h[allo*
+         *
+         * @param ns Namespace under which this operation is targeted.
+         * @param pattern Find keys matching a given glob-style pattern.
+         * @param findKeysAck The acknowledgement to be called once the request has been handled.
+         *                    The given function is called in the context of handleEvents() function.
+         */
+        virtual void listKeys(const Namespace& ns,
+                              const std::string& pattern,
+                              const FindKeysAck& findKeysAck) = 0;
+
         /**
          * Remove all keys under the namespace. Found keys are removed atomically, i.e.
          * either all succeeds or all fails.