]> git.saurik.com Git - redis.git/blobdiff - src/dscache.c
propagate key eviction to slaves and AOF, like for expires, so that replicas and...
[redis.git] / src / dscache.c
index 1c419c6a77fb582ae4586286f9e212c06d9eaefc..8243e794827ae1f9160ee58d94dee5396b71e503 100644 (file)
@@ -185,8 +185,7 @@ int cacheFreeOneEntry(void) {
          * are swappable objects */
         int maxtries = 100;
 
-        if (dictSize(db->dict) == 0) continue;
-        for (i = 0; i < 5; i++) {
+        for (i = 0; i < 5 && dictSize(db->dict); i++) {
             dictEntry *de;
             double swappability;
             robj keyobj;
@@ -732,6 +731,9 @@ int cacheScheduleIOPushJobs(int flags) {
     listNode *ln;
     int jobs, topush = 0, pushed = 0;
 
+    /* Don't push new jobs if there is a threaded BGSAVE in progress. */
+    if (server.bgsavethread != (pthread_t) -1) return 0;
+
     /* Sync stuff on disk, but only if we have less
      * than MAX_IO_JOBS_QUEUE IO jobs. */
     lockThreadedIO();
@@ -753,7 +755,8 @@ int cacheScheduleIOPushJobs(int flags) {
 
         if (op->type != REDIS_IO_LOAD && flags & REDIS_IO_ONLYLOADS) break;
 
-        if (!(flags & REDIS_IO_ASAP) &&
+        /* Don't execute SAVE before the scheduled time for completion */
+        if (op->type == REDIS_IO_SAVE && !(flags & REDIS_IO_ASAP) &&
               (now - op->ctime) < server.cache_flush_delay) break;
 
         /* Don't add a SAVE job in the IO thread queue if there is already