- /* 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. */
+ if (server.ds_enabled && cacheKeyMayExist(db,key)) {
+ if (cacheScheduleIOGetFlags(db,key) & REDIS_IO_SAVEINPROG) {
+ /* There is a save in progress for this object!
+ * Wait for it to get out. */
+ waitEmptyIOJobsQueue();
+ processAllPendingIOJobs();
+ redisAssert((cacheScheduleIOGetFlags(db,key) & REDIS_IO_SAVEINPROG) == 0);
+ }
+
+ redisLog(REDIS_DEBUG,"Force loading key %s via lookup",
+ key->ptr);
+ 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;
+ }
+ }