MCPcopy Create free account
hub / github.com/Snapchat/KeyDB / catAppendOnlyExpireAtCommand

Function catAppendOnlyExpireAtCommand

src/aof.cpp:604–631  ·  view source on GitHub ↗

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. */

Source from the content-addressed store, hash-verified

602 * into PEXPIREAT command so that we retain precision in the append only
603 * file, and the time is always absolute and not relative. */
604sds 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
633sds catAppendOnlyExpireMemberAtCommand(sds buf, struct redisCommand *cmd, robj **argv, const size_t argc) {
634 long long when = 0;

Callers 1

Calls 6

getDecodedObjectFunction · 0.85
szFromObjFunction · 0.85
decrRefCountFunction · 0.85
mstimeFunction · 0.70

Tested by

no test coverage detected