Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simple Condition Change - expireIfNeeded #762

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/aof.c
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
7 changes: 4 additions & 3 deletions src/db.c
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion src/debug.c
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