MCPcopy Create free account
hub / github.com/F-Stack/f-stack / delKeysInSlot

Function delKeysInSlot

app/redis-6.2.6/src/db.c:1986–2005  ·  view source on GitHub ↗

Remove all the keys in the specified hash slot. * The number of removed items is returned. */

Source from the content-addressed store, hash-verified

1984/* Remove all the keys in the specified hash slot.
1985 * The number of removed items is returned. */
1986unsigned int delKeysInSlot(unsigned int hashslot) {
1987 raxIterator iter;
1988 int j = 0;
1989 unsigned char indexed[2];
1990
1991 indexed[0] = (hashslot >> 8) & 0xff;
1992 indexed[1] = hashslot & 0xff;
1993 raxStart(&iter,server.cluster->slots_to_keys);
1994 while(server.cluster->slots_keys_count[hashslot]) {
1995 raxSeek(&iter,">=",indexed,2);
1996 raxNext(&iter);
1997
1998 robj *key = createStringObject((char*)iter.key+2,iter.key_len-2);
1999 dbDelete(&server.db[0],key);
2000 decrRefCount(key);
2001 j++;
2002 }
2003 raxStop(&iter);
2004 return j;
2005}
2006
2007unsigned int countKeysInSlot(unsigned int hashslot) {
2008 return server.cluster->slots_keys_count[hashslot];

Callers 1

Calls 7

raxStartFunction · 0.85
raxSeekFunction · 0.85
raxNextFunction · 0.85
dbDeleteFunction · 0.85
decrRefCountFunction · 0.85
raxStopFunction · 0.85
createStringObjectFunction · 0.70

Tested by

no test coverage detected