MCPcopy Create free account
hub / github.com/F-Stack/f-stack / ttlGenericCommand

Function ttlGenericCommand

app/redis-6.2.6/src/expire.c:557–577  ·  view source on GitHub ↗

Implements TTL and PTTL */

Source from the content-addressed store, hash-verified

555
556/* Implements TTL and PTTL */
557void ttlGenericCommand(client *c, int output_ms) {
558 long long expire, ttl = -1;
559
560 /* If the key does not exist at all, return -2 */
561 if (lookupKeyReadWithFlags(c->db,c->argv[1],LOOKUP_NOTOUCH) == NULL) {
562 addReplyLongLong(c,-2);
563 return;
564 }
565 /* The key exists. Return -1 if it has no expire, or the actual
566 * TTL value otherwise. */
567 expire = getExpire(c->db,c->argv[1]);
568 if (expire != -1) {
569 ttl = expire-mstime();
570 if (ttl < 0) ttl = 0;
571 }
572 if (ttl == -1) {
573 addReplyLongLong(c,-1);
574 } else {
575 addReplyLongLong(c,output_ms ? ttl : ((ttl+500)/1000));
576 }
577}
578
579/* TTL key */
580void ttlCommand(client *c) {

Callers 2

ttlCommandFunction · 0.85
pttlCommandFunction · 0.85

Calls 4

lookupKeyReadWithFlagsFunction · 0.85
addReplyLongLongFunction · 0.85
getExpireFunction · 0.85
mstimeFunction · 0.70

Tested by

no test coverage detected