Set an expire to the specified key. If the expire is set in the context * of an user calling a command 'c' is the client, otherwise 'c' is set * to NULL. The 'when' parameter is the absolute unix time in milliseconds * after which the key will no longer be considered valid. */
| 1410 | * to NULL. The 'when' parameter is the absolute unix time in milliseconds |
| 1411 | * after which the key will no longer be considered valid. */ |
| 1412 | void setExpire(client *c, redisDb *db, robj *key, long long when) { |
| 1413 | dictEntry *kde, *de; |
| 1414 | |
| 1415 | /* Reuse the sds from the main dict in the expire dict */ |
| 1416 | kde = dictFind(db->dict,key->ptr); |
| 1417 | serverAssertWithInfo(NULL,key,kde != NULL); |
| 1418 | de = dictAddOrFind(db->expires,dictGetKey(kde)); |
| 1419 | dictSetSignedIntegerVal(de,when); |
| 1420 | |
| 1421 | int writable_slave = server.masterhost && server.repl_slave_ro == 0; |
| 1422 | if (c && writable_slave && !(c->flags & CLIENT_MASTER)) |
| 1423 | rememberSlaveKeyWithExpire(db,key); |
| 1424 | } |
| 1425 | |
| 1426 | /* Return the expire time of the specified key, or -1 if no expire |
| 1427 | * is associated with this key (i.e. the key is non volatile) */ |
no test coverage detected