Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Simple Condition Change - expireIfNeeded #762

Closed
wants to merge 2 commits into from

2 participants

charsyam openbaas
charsyam

redis doesn't need to call getExpire before check server.loading.
so moving call getExpire after server.loading check statement.

charsyam and others added some commits
charsyam charsyam Simple Condition Change - expireIfNeeded
redis doesn't need to call getExpire before check server.loading.
so moving call getExpire after server.loading check statement.
aa9b065
openbaas openbaas change getExpire position fa9481c
charsyam

getExpire calls dictFind twice, so it is expensive if it just returns, so this will give better performance.

charsyam charsyam closed this
charsyam charsyam deleted the branch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Nov 13, 2012
  1. charsyam

    Simple Condition Change - expireIfNeeded

    charsyam authored
    redis doesn't need to call getExpire before check server.loading.
    so moving call getExpire after server.loading check statement.
Commits on Nov 14, 2012
  1. openbaas

    change getExpire position

    openbaas authored
This page is out of date. Refresh to see the latest.
Showing with 7 additions and 6 deletions.
  1. +2 −2 src/aof.c
  2. +4 −3 src/db.c
  3. +1 −1  src/debug.c
4 src/aof.c
View
@@ -879,8 +879,6 @@ int rewriteAppendOnlyFile(char *filename) {
o = dictGetVal(de);
initStaticStringObject(key,keystr);
- expiretime = getExpire(db,&key);
-
/* Save the key and associated value */
if (o->type == REDIS_STRING) {
/* Emit a SET command */
@@ -900,7 +898,9 @@ int rewriteAppendOnlyFile(char *filename) {
} else {
redisPanic("Unknown object type");
}
+
/* Save the expire time */
+ expiretime = getExpire(db,&key);
if (expiretime != -1) {
char cmd[]="*3\r\n$9\r\nPEXPIREAT\r\n";
/* If this key is already expired skip it */
7 src/db.c
View
@@ -512,13 +512,14 @@ void propagateExpire(redisDb *db, robj *key) {
}
int expireIfNeeded(redisDb *db, robj *key) {
- long long when = getExpire(db,key);
-
- if (when < 0) return 0; /* No expire for this key */
+ long long when;
/* Don't expire anything while loading. It will be done later. */
if (server.loading) return 0;
+ when = getExpire(db,key);
+ if (when < 0) return 0; /* No expire for this key */
+
/* If we are running in the context of a slave, return ASAP:
* the slave key expiration is controlled by the master that will
* send us synthesized DEL operations for expired keys.
2  src/debug.c
View
@@ -139,7 +139,6 @@ void computeDatasetDigest(unsigned char *final) {
aux = htonl(o->type);
mixDigest(digest,&aux,sizeof(aux));
- expiretime = getExpire(db,keyobj);
/* Save the key and associated value */
if (o->type == REDIS_STRING) {
@@ -235,6 +234,7 @@ void computeDatasetDigest(unsigned char *final) {
redisPanic("Unknown object type");
}
/* If the key has an expire, add it to the mix */
+ expiretime = getExpire(db,keyobj);
if (expiretime != -1) xorDigest(digest,"!!expire!!",10);
/* We can finally xor the key-val digest to the final digest */
xorDigest(final,digest,20);
Something went wrong with that request. Please try again.