diff --git a/src/pika_slot_command.cc b/src/pika_slot_command.cc index 179b7c4d17..2242d34749 100644 --- a/src/pika_slot_command.cc +++ b/src/pika_slot_command.cc @@ -772,12 +772,12 @@ std::string GetSlotsTagKey(uint32_t crc) { return SlotTagPrefix + std::to_string(crc); } -// delete key from db +// delete key from db && cache int DeleteKey(const std::string& key, const char key_type, const std::shared_ptr& db) { int32_t res = 0; std::string slotKey = GetSlotKey(GetSlotID(g_pika_conf->default_slot_num(), key)); - // delete key from slot + // delete slotkey std::vector members; members.emplace_back(key_type + key); rocksdb::Status s = db->storage()->SRem(slotKey, members, &res); @@ -791,6 +791,12 @@ int DeleteKey(const std::string& key, const char key_type, const std::shared_ptr } } + // delete from cache + if (PIKA_CACHE_NONE != g_pika_conf->cache_model() + && PIKA_CACHE_STATUS_OK == db->cache()->CacheStatus()) { + db->cache()->Del(members); + } + // delete key from db members.clear(); members.emplace_back(key); @@ -800,7 +806,6 @@ int DeleteKey(const std::string& key, const char key_type, const std::shared_ptr LOG(WARNING) << "Del key: " << key << " at slot " << GetSlotID(g_pika_conf->default_slot_num(), key) << " error"; return -1; } - WriteDelKeyToBinlog(key, db); return 1; }