From: Premysl Hruby Date: Wed, 28 Mar 2012 09:48:36 +0000 (+0200) Subject: for (p)expireat use absolute time, without double recomputation X-Git-Url: https://git.saurik.com/redis.git/commitdiff_plain/81a28fe131adbffb96563c89ba67a50f1b352722?hp=b518a83525e7407d38c413f73a338996bdac6b64 for (p)expireat use absolute time, without double recomputation --- diff --git a/src/db.c b/src/db.c index b8c87b4f..2cc70d2c 100644 --- a/src/db.c +++ b/src/db.c @@ -516,7 +516,7 @@ void expireGenericCommand(redisClient *c, long long offset, int unit) { return; if (unit == UNIT_SECONDS) milliseconds *= 1000; - milliseconds -= offset; + milliseconds += offset; de = dictFind(c->db->dict,key->ptr); if (de == NULL) { @@ -543,8 +543,7 @@ void expireGenericCommand(redisClient *c, long long offset, int unit) { addReply(c, shared.cone); return; } else { - long long when = mstime()+milliseconds; - setExpire(c->db,key,when); + setExpire(c->db,key,milliseconds); addReply(c,shared.cone); signalModifiedKey(c->db,key); server.dirty++; @@ -553,19 +552,19 @@ void expireGenericCommand(redisClient *c, long long offset, int unit) { } void expireCommand(redisClient *c) { - expireGenericCommand(c,0,UNIT_SECONDS); + expireGenericCommand(c,mstime(),UNIT_SECONDS); } void expireatCommand(redisClient *c) { - expireGenericCommand(c,mstime(),UNIT_SECONDS); + expireGenericCommand(c,0,UNIT_SECONDS); } void pexpireCommand(redisClient *c) { - expireGenericCommand(c,0,UNIT_MILLISECONDS); + expireGenericCommand(c,mstime(),UNIT_MILLISECONDS); } void pexpireatCommand(redisClient *c) { - expireGenericCommand(c,mstime(),UNIT_MILLISECONDS); + expireGenericCommand(c,0,UNIT_MILLISECONDS); } void ttlGenericCommand(redisClient *c, int output_ms) {