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
| 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. */ |
| 2466 | int 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, |
nothing calls this directly
no test coverage detected