Commit c6bf4a00 authored by Premysl Hruby's avatar Premysl Hruby Committed by antirez
Browse files

for (p)expireat use absolute time, without double recomputation

parent d48d1309
...@@ -527,7 +527,7 @@ void expireGenericCommand(redisClient *c, long long offset, int unit) { ...@@ -527,7 +527,7 @@ void expireGenericCommand(redisClient *c, long long offset, int unit) {
return; return;
if (unit == UNIT_SECONDS) milliseconds *= 1000; if (unit == UNIT_SECONDS) milliseconds *= 1000;
milliseconds -= offset; milliseconds += offset;
de = dictFind(c->db->dict,key->ptr); de = dictFind(c->db->dict,key->ptr);
if (de == NULL) { if (de == NULL) {
...@@ -554,8 +554,7 @@ void expireGenericCommand(redisClient *c, long long offset, int unit) { ...@@ -554,8 +554,7 @@ void expireGenericCommand(redisClient *c, long long offset, int unit) {
addReply(c, shared.cone); addReply(c, shared.cone);
return; return;
} else { } else {
long long when = mstime()+milliseconds; setExpire(c->db,key,milliseconds);
setExpire(c->db,key,when);
addReply(c,shared.cone); addReply(c,shared.cone);
signalModifiedKey(c->db,key); signalModifiedKey(c->db,key);
server.dirty++; server.dirty++;
...@@ -564,19 +563,19 @@ void expireGenericCommand(redisClient *c, long long offset, int unit) { ...@@ -564,19 +563,19 @@ void expireGenericCommand(redisClient *c, long long offset, int unit) {
} }
void expireCommand(redisClient *c) { void expireCommand(redisClient *c) {
expireGenericCommand(c,0,UNIT_SECONDS); expireGenericCommand(c,mstime(),UNIT_SECONDS);
} }
void expireatCommand(redisClient *c) { void expireatCommand(redisClient *c) {
expireGenericCommand(c,mstime(),UNIT_SECONDS); expireGenericCommand(c,0,UNIT_SECONDS);
} }
void pexpireCommand(redisClient *c) { void pexpireCommand(redisClient *c) {
expireGenericCommand(c,0,UNIT_MILLISECONDS); expireGenericCommand(c,mstime(),UNIT_MILLISECONDS);
} }
void pexpireatCommand(redisClient *c) { void pexpireatCommand(redisClient *c) {
expireGenericCommand(c,mstime(),UNIT_MILLISECONDS); expireGenericCommand(c,0,UNIT_MILLISECONDS);
} }
void ttlGenericCommand(redisClient *c, int output_ms) { void ttlGenericCommand(redisClient *c, int output_ms) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment