Update access LFU/LRU access times when overwriting key
Former-commit-id: f11fdf671700fd5445599c473d69e015eb6618e8
This commit is contained in:
parent
012228bd51
commit
5bdcb8fefb
22
src/db.cpp
22
src/db.cpp
@ -65,13 +65,8 @@ void updateExpire(redisDb *db, sds key, robj *valOld, robj *valNew)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void updateDbValAccess(dictEntry *de, int flags)
|
||||||
/* 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);
|
robj *val = (robj*)dictGetVal(de);
|
||||||
|
|
||||||
/* Update the access time for the ageing algorithm.
|
/* 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();
|
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) {
|
if (flags & LOOKUP_UPDATEMVCC) {
|
||||||
val->mvcc_tstamp = getMvccTstamp();
|
val->mvcc_tstamp = getMvccTstamp();
|
||||||
@ -312,6 +319,7 @@ void genericSetKey(redisDb *db, robj *key, robj *val, int keepttl) {
|
|||||||
if (de == NULL) {
|
if (de == NULL) {
|
||||||
dbAdd(db,key,val);
|
dbAdd(db,key,val);
|
||||||
} else {
|
} else {
|
||||||
|
updateDbValAccess(de, LOOKUP_NONE);
|
||||||
dbOverwriteCore(db,de,key,val,!!g_pserver->fActiveReplica,!keepttl);
|
dbOverwriteCore(db,de,key,val,!!g_pserver->fActiveReplica,!keepttl);
|
||||||
}
|
}
|
||||||
incrRefCount(val);
|
incrRefCount(val);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user