mirror of
https://github.com/fluencelabs/redis
synced 2025-06-19 20:21:21 +00:00
blocking load of keys on lookup -- nor tested, nor finished
This commit is contained in:
24
src/db.c
24
src/db.c
@ -27,10 +27,26 @@ robj *lookupKey(redisDb *db, robj *key) {
|
||||
server.stat_keyspace_hits++;
|
||||
return val;
|
||||
} else {
|
||||
/* FIXME: Check if the object is on disk, if it is, load it
|
||||
* in a blocking way now. If we are sure there are no collisions
|
||||
* it would be cool to load this directly here without IO thread
|
||||
* help. */
|
||||
time_t expire;
|
||||
robj *val;
|
||||
|
||||
/* Key not found in the in memory hash table, but if disk store is
|
||||
* enabled we may have this key on disk. If so load it in memory
|
||||
* in a blocking way.
|
||||
*
|
||||
* FIXME: race condition here. If there was an already scheduled
|
||||
* async loading of this key, what may happen is that the old
|
||||
* key is loaded in memory if this gets deleted in the meantime. */
|
||||
if (server.ds_enabled && cacheKeyMayExist(db,key)) {
|
||||
val = dsGet(db,key,&expire);
|
||||
if (val) {
|
||||
int retval = dbAdd(db,key,val);
|
||||
redisAssert(retval == REDIS_OK);
|
||||
if (expire != -1) setExpire(db,key,expire);
|
||||
server.stat_keyspace_hits++;
|
||||
return val;
|
||||
}
|
||||
}
|
||||
server.stat_keyspace_misses++;
|
||||
return NULL;
|
||||
}
|
||||
|
Reference in New Issue
Block a user