Browse Source

fix(imperative): fix redis fastrun cache server

GitOrigin-RevId: 252a0afdc3
master
Megvii Engine Team 2 years ago
parent
commit
485f0a1f83
1 changed files with 5 additions and 4 deletions
  1. +5
    -4
      imperative/src/impl/persistent_cache.cpp

+ 5
- 4
imperative/src/impl/persistent_cache.cpp View File

@@ -93,19 +93,20 @@ public:
}

std::optional<size_t> clear() override {
size_t cursor = 0, nr_deleted = 0;
std::string pattern = m_prefix + "@*";
long long cursor = 0;
size_t nr_deleted = 0;
std::string pattern = m_prefix + "*";
do {
auto reply = m_client.scan(cursor, pattern).share();
sync();
auto keys = reply.get().as_array();
std::vector<std::string> string_keys;
for (auto&& key : keys) {
for (auto&& key : keys[1].as_array()) {
string_keys.push_back(key.as_string());
}
m_client.del(string_keys);
nr_deleted += string_keys.size();
cursor = reply.get().as_array()[0].as_integer();
cursor = std::stoll(keys[0].as_string());
} while (cursor != 0);
return nr_deleted;
}


Loading…
Cancel
Save