Skip to content

Commit

Permalink
change getExpire position
Browse files Browse the repository at this point in the history
  • Loading branch information
charsyam committed Nov 14, 2012
1 parent aa9b065 commit fa9481c
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/aof.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand All @@ -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 */
Expand Down
1 change: 0 additions & 1 deletion src/db.c
Original file line number Diff line number Diff line change
Expand Up @@ -520,7 +520,6 @@ int expireIfNeeded(redisDb *db, robj *key) {
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.
Expand Down
2 changes: 1 addition & 1 deletion src/debug.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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);
Expand Down

1 comment on commit fa9481c

@charsyam
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Please sign in to comment.