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

Function lookupKey

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

Low level key lookup API, not actually called directly from commands * implementations that should instead rely on lookupKeyRead(), * lookupKeyWrite() and lookupKeyReadWithFlags(). */

Source from the content-addressed store, hash-verified

61 * implementations that should instead rely on lookupKeyRead(),
62 * lookupKeyWrite() and lookupKeyReadWithFlags(). */
63robj *lookupKey(redisDb *db, robj *key, int flags) {
64 dictEntry *de = dictFind(db->dict,key->ptr);
65 if (de) {
66 robj *val = dictGetVal(de);
67
68 /* Update the access time for the ageing algorithm.
69 * Don't do it if we have a saving child, as this will trigger
70 * a copy on write madness. */
71 if (!hasActiveChildProcess() && !(flags & LOOKUP_NOTOUCH)){
72 if (server.maxmemory_policy & MAXMEMORY_FLAG_LFU) {
73 updateLFU(val);
74 } else {
75 val->lru = LRU_CLOCK();
76 }
77 }
78 return val;
79 } else {
80 return NULL;
81 }
82}
83
84/* Lookup a key for read operations, or return NULL if the key is not found
85 * in the specified DB.

Callers 3

lookupKeyReadWithFlagsFunction · 0.85
lookupKeyWriteWithFlagsFunction · 0.85

Calls 4

hasActiveChildProcessFunction · 0.85
updateLFUFunction · 0.85
LRU_CLOCKFunction · 0.85
dictFindFunction · 0.70

Tested by

no test coverage detected