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

Function RM_SetExpire

app/redis-6.2.6/src/module.c:2378–2388  ·  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

2376 * The function returns REDISMODULE_OK on success or REDISMODULE_ERR if
2377 * the key was not open for writing or is an empty key. */
2378int RM_SetExpire(RedisModuleKey *key, mstime_t expire) {
2379 if (!(key->mode & REDISMODULE_WRITE) || key->value == NULL || (expire < 0 && expire != REDISMODULE_NO_EXPIRE))
2380 return REDISMODULE_ERR;
2381 if (expire != REDISMODULE_NO_EXPIRE) {
2382 expire += mstime();
2383 setExpire(key->ctx->client,key->db,key->key,expire);
2384 } else {
2385 removeExpire(key->db,key->key);
2386 }
2387 return REDISMODULE_OK;
2388}
2389
2390/* Return the key expire value, as absolute Unix timestamp.
2391 * 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