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. */
| 602 | * into PEXPIREAT command so that we retain precision in the append only |
| 603 | * file, and the time is always absolute and not relative. */ |
| 604 | sds catAppendOnlyExpireAtCommand(sds buf, struct redisCommand *cmd, robj *key, robj *seconds) { |
| 605 | long long when; |
| 606 | robj *argv[3]; |
| 607 | |
| 608 | /* Make sure we can use strtoll */ |
| 609 | seconds = getDecodedObject(seconds); |
| 610 | when = strtoll(szFromObj(seconds),NULL,10); |
| 611 | /* Convert argument into milliseconds for EXPIRE, SETEX, EXPIREAT */ |
| 612 | if (cmd->proc == expireCommand || cmd->proc == setexCommand || |
| 613 | cmd->proc == expireatCommand) |
| 614 | { |
| 615 | when *= 1000; |
| 616 | } |
| 617 | /* Convert into absolute time for EXPIRE, PEXPIRE, SETEX, PSETEX */ |
| 618 | if (cmd->proc == expireCommand || cmd->proc == pexpireCommand || |
| 619 | cmd->proc == setexCommand || cmd->proc == psetexCommand) |
| 620 | { |
| 621 | when += mstime(); |
| 622 | } |
| 623 | decrRefCount(seconds); |
| 624 | |
| 625 | argv[0] = shared.pexpireat; |
| 626 | argv[1] = key; |
| 627 | argv[2] = createStringObjectFromLongLong(when); |
| 628 | buf = catAppendOnlyGenericCommand(buf, 3, argv); |
| 629 | decrRefCount(argv[2]); |
| 630 | return buf; |
| 631 | } |
| 632 | |
| 633 | sds catAppendOnlyExpireMemberAtCommand(sds buf, struct redisCommand *cmd, robj **argv, const size_t argc) { |
| 634 | long long when = 0; |
no test coverage detected