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