Create the sds representation of a PEXPIREAT command, using * 'seconds' as time to live and 'cmd' to understand what command * we are translating into a PEXPIREAT. * * This command is used in order to translate EXPIRE and PEXPIRE commands * into PEXPIREAT command so that we retain precision in the append only * file, and the time is always absolute and not relative. */
| 582 | * into PEXPIREAT command so that we retain precision in the append only |
| 583 | * file, and the time is always absolute and not relative. */ |
| 584 | sds catAppendOnlyExpireAtCommand(sds buf, struct redisCommand *cmd, robj *key, robj *seconds) { |
| 585 | long long when; |
| 586 | robj *argv[3]; |
| 587 | |
| 588 | /* Make sure we can use strtoll */ |
| 589 | seconds = getDecodedObject(seconds); |
| 590 | when = strtoll(seconds->ptr,NULL,10); |
| 591 | /* Convert argument into milliseconds for EXPIRE, SETEX, EXPIREAT */ |
| 592 | if (cmd->proc == expireCommand || cmd->proc == setexCommand || |
| 593 | cmd->proc == expireatCommand) |
| 594 | { |
| 595 | when *= 1000; |
| 596 | } |
| 597 | /* Convert into absolute time for EXPIRE, PEXPIRE, SETEX, PSETEX */ |
| 598 | if (cmd->proc == expireCommand || cmd->proc == pexpireCommand || |
| 599 | cmd->proc == setexCommand || cmd->proc == psetexCommand) |
| 600 | { |
| 601 | when += mstime(); |
| 602 | } |
| 603 | decrRefCount(seconds); |
| 604 | |
| 605 | argv[0] = shared.pexpireat; |
| 606 | argv[1] = key; |
| 607 | argv[2] = createStringObjectFromLongLong(when); |
| 608 | buf = catAppendOnlyGenericCommand(buf, 3, argv); |
| 609 | decrRefCount(argv[2]); |
| 610 | return buf; |
| 611 | } |
| 612 | |
| 613 | void feedAppendOnlyFile(struct redisCommand *cmd, int dictid, robj **argv, int argc) { |
| 614 | sds buf = sdsempty(); |
no test coverage detected