Update access LFU/LRU access times when overwriting key

Former-commit-id: f11fdf671700fd5445599c473d69e015eb6618e8
This commit is contained in:
John Sully 2020-05-11 00:42:46 -04:00
parent 4477a8b145
commit 87a9f79e20

View File

@ -65,13 +65,8 @@ void updateExpire(redisDb *db, sds key, robj *valOld, robj *valNew)
return;
}
/* Low level key lookup API, not actually called directly from commands
* implementations that should instead rely on lookupKeyRead(),
* lookupKeyWrite() and lookupKeyReadWithFlags(). */
static robj *lookupKey(redisDb *db, robj *key, int flags) {
dictEntry *de = dictFind(db->pdict,ptrFromObj(key));
if (de) {
void updateDbValAccess(dictEntry *de, int flags)
{
robj *val = (robj*)dictGetVal(de);
/* Update the access time for the ageing algorithm.
@ -84,6 +79,18 @@ static robj *lookupKey(redisDb *db, robj *key, int flags) {
val->lru = LRU_CLOCK();
}
}
}
/* Low level key lookup API, not actually called directly from commands
* implementations that should instead rely on lookupKeyRead(),
* lookupKeyWrite() and lookupKeyReadWithFlags(). */
static robj *lookupKey(redisDb *db, robj *key, int flags) {
dictEntry *de = dictFind(db->pdict,ptrFromObj(key));
if (de) {
robj *val = (robj*)dictGetVal(de);
updateDbValAccess(de, flags);
if (flags & LOOKUP_UPDATEMVCC) {
val->mvcc_tstamp = getMvccTstamp();
@ -312,6 +319,7 @@ void genericSetKey(redisDb *db, robj *key, robj *val, int keepttl) {
if (de == NULL) {
dbAdd(db,key,val);
} else {
updateDbValAccess(de, LOOKUP_NONE);
dbOverwriteCore(db,de,key,val,!!g_pserver->fActiveReplica,!keepttl);
}
incrRefCount(val);