Commit 55cf8433 authored by antirez's avatar antirez
Browse files

load key from swap on key lookup

parent a35ddf12
...@@ -488,6 +488,7 @@ static void unblockClient(redisClient *c); ...@@ -488,6 +488,7 @@ static void unblockClient(redisClient *c);
static int handleClientsWaitingListPush(redisClient *c, robj *key, robj *ele); static int handleClientsWaitingListPush(redisClient *c, robj *key, robj *ele);
static void vmInit(void); static void vmInit(void);
static void vmMarkPagesFree(off_t page, off_t count); static void vmMarkPagesFree(off_t page, off_t count);
static robj *vmLoadObject(robj *key);
static void authCommand(redisClient *c); static void authCommand(redisClient *c);
static void pingCommand(redisClient *c); static void pingCommand(redisClient *c);
...@@ -2359,11 +2360,21 @@ static void decrRefCount(void *obj) { ...@@ -2359,11 +2360,21 @@ static void decrRefCount(void *obj) {
static robj *lookupKey(redisDb *db, robj *key) { static robj *lookupKey(redisDb *db, robj *key) {
dictEntry *de = dictFind(db->dict,key); dictEntry *de = dictFind(db->dict,key);
if (de) { if (de) {
robj *o = dictGetEntryVal(de); robj *key = dictGetEntryKey(de);
robj *val = dictGetEntryVal(de);
/* Update the access time of the key for the aging algorithm. */ if (server.vm_enabled) {
if (server.vm_enabled) o->vm.atime = server.unixtime; if (key->storage == REDIS_VM_MEMORY) {
return o; /* Update the access time of the key for the aging algorithm. */
key->vm.atime = server.unixtime;
} else {
/* Our value was swapped on disk. Bring it at home. */
assert(val == NULL);
val = vmLoadObject(key);
dictGetEntryVal(de) = val;
}
}
return val;
} else { } else {
return NULL; return NULL;
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment