]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw/cache: This commit squashes the following commits related to list_entries cache...
authorSamarah <samarah.uriarte@ibm.com>
Thu, 8 Jun 2023 17:10:58 +0000 (13:10 -0400)
committerPritha Srivastava <prsrivas@redhat.com>
Tue, 2 Apr 2024 15:54:50 +0000 (21:24 +0530)
RGW: Add list_entries method to CacheDriver and to Redis driver.
RGW: Change CacheDriver::list_entries output type
RGW: Update RedisDriver::list_entries and usage in D4N policy driver

Signed-off-by: Samarah <samarah.uriarte@ibm.com>
src/rgw/rgw_cache_driver.h
src/rgw/rgw_redis_driver.cc
src/rgw/rgw_redis_driver.h

index a96b325610073a6af6d2bdb59bf460682363c0f7..0fa1882b2e06118be54bba7667ed208b4fa1d5df 100644 (file)
@@ -36,6 +36,7 @@ class CacheDriver {
 
     /* Entry */
     virtual bool key_exists(const DoutPrefixProvider* dpp, const std::string& key) = 0;
+    virtual std::vector<Entry> list_entries(const DoutPrefixProvider* dpp) = 0;
     virtual size_t get_num_entries(const DoutPrefixProvider* dpp) = 0;
 
     /* Partition */
index 371f3e72196a1c432ed5f46a2e86dad39aa55f44..751eeedf6beefd4dcd10b6ef8b570fb9e9a20b2e 100644 (file)
@@ -75,6 +75,35 @@ bool RedisDriver::key_exists(const DoutPrefixProvider* dpp, const std::string& k
   return result;
 }
 
+std::vector<Entry> RedisDriver::list_entries(const DoutPrefixProvider* dpp) {
+  std::vector<Entry> result;
+
+  if (!client.is_connected()) 
+    return {};
+
+//  try {
+    size_t cursor = 0;
+    const std::string pattern = "*:cache";
+
+  /*  client.scan(cursor, pattern, [](cpp_redis::reply &reply) {
+      dout(0) << "Sam" << dendl;
+      if (!reply.is_null()) {
+        //result = reply.as_array();
+      }
+    });
+    client.sync_commit(std::chrono::milliseconds(1000));
+*/
+/*    if (result.empty()) {
+      return {};
+    }
+  } catch(std::exception &e) {
+    return {};
+  }
+*/
+  dout(0) << "Sam: " << client.is_connected() << dendl;
+  return result;
+}
+
 size_t RedisDriver::get_num_entries(const DoutPrefixProvider* dpp) {
   int result = -1;
 
index 01c623acb680f2ae42c46af572104e08e535e833..06cddefb0c0cfabf6809dfecc4b0a9b633d5006a 100644 (file)
@@ -31,6 +31,7 @@ class RedisDriver : public CacheDriver {
 
     /* Entry */
     virtual bool key_exists(const DoutPrefixProvider* dpp, const std::string& key) override;
+    virtual std::vector<Entry> list_entries(const DoutPrefixProvider* dpp) override;
     virtual size_t get_num_entries(const DoutPrefixProvider* dpp) override;
 
     /* Partition */