Populate the specified array of objects with keys in the specified slot. * New objects are returned to represent keys, it's up to the caller to * decrement the reference count to release the keys names. */
| 2527 | * New objects are returned to represent keys, it's up to the caller to |
| 2528 | * decrement the reference count to release the keys names. */ |
| 2529 | unsigned int getKeysInSlot(unsigned int hashslot, robj **keys, unsigned int count) { |
| 2530 | if (g_pserver->m_pstorageFactory != nullptr) { |
| 2531 | int j = 0; |
| 2532 | g_pserver->db[0]->getStorageCache()->enumerate_hashslot([&](const char *key, size_t cchKey, const void *, size_t )->bool { |
| 2533 | keys[j++] = createStringObject(key, cchKey); |
| 2534 | return --count; |
| 2535 | }, hashslot); |
| 2536 | return j; |
| 2537 | } else { |
| 2538 | raxIterator iter; |
| 2539 | int j = 0; |
| 2540 | unsigned char indexed[2]; |
| 2541 | |
| 2542 | indexed[0] = (hashslot >> 8) & 0xff; |
| 2543 | indexed[1] = hashslot & 0xff; |
| 2544 | raxStart(&iter,g_pserver->cluster->slots_to_keys); |
| 2545 | raxSeek(&iter,">=",indexed,2); |
| 2546 | while(count-- && raxNext(&iter)) { |
| 2547 | if (iter.key[0] != indexed[0] || iter.key[1] != indexed[1]) break; |
| 2548 | keys[j++] = createStringObject((char*)iter.key+2,iter.key_len-2); |
| 2549 | } |
| 2550 | raxStop(&iter); |
| 2551 | return j; |
| 2552 | } |
| 2553 | } |
| 2554 | |
| 2555 | /* Remove all the keys in the specified hash slot. |
| 2556 | * The number of removed items is returned. */ |
no test coverage detected