Low level key lookup API, not actually called directly from commands * implementations that should instead rely on lookupKeyRead(), * lookupKeyWrite() and lookupKeyReadWithFlags(). */
| 61 | * implementations that should instead rely on lookupKeyRead(), |
| 62 | * lookupKeyWrite() and lookupKeyReadWithFlags(). */ |
| 63 | robj *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. |
no test coverage detected