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

Function RM_SetExpire

src/module.cpp:2466–2476  ·  view source on GitHub ↗

Set a new expire for the key. If the special expire * REDISMODULE_NO_EXPIRE is set, the expire is cancelled if there was * one (the same as the PERSIST command). * * Note that the expire must be provided as a positive integer representing * the number of milliseconds of TTL the key should have. * * The function returns REDISMODULE_OK on success or REDISMODULE_ERR if * the key was not open

Source from the content-addressed store, hash-verified

2464 * The function returns REDISMODULE_OK on success or REDISMODULE_ERR if
2465 * the key was not open for writing or is an empty key. */
2466int RM_SetExpire(RedisModuleKey *key, mstime_t expire) {
2467 if (!(key->mode & REDISMODULE_WRITE) || key->value == NULL || (expire < 0 && expire != REDISMODULE_NO_EXPIRE))
2468 return REDISMODULE_ERR;
2469 if (expire != REDISMODULE_NO_EXPIRE) {
2470 expire += mstime();
2471 setExpire(key->ctx->client,key->db,key->key,nullptr,expire);
2472 } else {
2473 removeExpire(key->db,key->key);
2474 }
2475 return REDISMODULE_OK;
2476}
2477
2478/* Return the key expire value, as absolute Unix timestamp.
2479 * If no TTL is associated with the key or if the key is empty,

Callers

nothing calls this directly

Calls 3

setExpireFunction · 0.85
removeExpireFunction · 0.85
mstimeFunction · 0.70

Tested by

no test coverage detected