Remove all the keys in the specified hash slot. * The number of removed items is returned. */
| 2555 | /* Remove all the keys in the specified hash slot. |
| 2556 | * The number of removed items is returned. */ |
| 2557 | unsigned int delKeysInSlot(unsigned int hashslot) { |
| 2558 | serverAssert(GlobalLocksAcquired()); |
| 2559 | if (g_pserver->m_pstorageFactory != nullptr) { |
| 2560 | int j = 0; |
| 2561 | g_pserver->db[0]->getStorageCache()->enumerate_hashslot([&](const char *key, size_t cchKey, const void *, size_t )->bool { |
| 2562 | robj *keyobj = createStringObject(key, cchKey); |
| 2563 | dbDelete(g_pserver->db[0], keyobj); |
| 2564 | decrRefCount(keyobj); |
| 2565 | j++; |
| 2566 | return true; |
| 2567 | }, hashslot); |
| 2568 | return j; |
| 2569 | } else { |
| 2570 | raxIterator iter; |
| 2571 | int j = 0; |
| 2572 | unsigned char indexed[2]; |
| 2573 | |
| 2574 | indexed[0] = (hashslot >> 8) & 0xff; |
| 2575 | indexed[1] = hashslot & 0xff; |
| 2576 | raxStart(&iter,g_pserver->cluster->slots_to_keys); |
| 2577 | while(g_pserver->cluster->slots_keys_count[hashslot]) { |
| 2578 | raxSeek(&iter,">=",indexed,2); |
| 2579 | raxNext(&iter); |
| 2580 | |
| 2581 | auto count = g_pserver->cluster->slots_keys_count[hashslot]; |
| 2582 | robj *key = createStringObject((char*)iter.key+2,iter.key_len-2); |
| 2583 | dbDelete(g_pserver->db[0],key); |
| 2584 | serverAssert(count > g_pserver->cluster->slots_keys_count[hashslot]); // we should have deleted something or we will be in an infinite loop |
| 2585 | decrRefCount(key); |
| 2586 | j++; |
| 2587 | } |
| 2588 | raxStop(&iter); |
| 2589 | return j; |
| 2590 | } |
| 2591 | } |
| 2592 | |
| 2593 | unsigned int countKeysInSlot(unsigned int hashslot) { |
| 2594 | return g_pserver->cluster->slots_keys_count[hashslot]; |
no test coverage detected