Simplify part of the #5470 patch.

This commit is contained in:
antirez 2018-10-24 12:26:27 +02:00
parent 3c89fb5ffd
commit 8749fc3f67

View File

@ -1161,18 +1161,17 @@ int keyIsExpired(redisDb *db, robj *key) {
* The return value of the function is 0 if the key is still valid, * The return value of the function is 0 if the key is still valid,
* otherwise the function returns 1 if the key is expired. */ * otherwise the function returns 1 if the key is expired. */
int expireIfNeeded(redisDb *db, robj *key) { int expireIfNeeded(redisDb *db, robj *key) {
if (!keyIsExpired(db,key)) { if (!keyIsExpired(db,key)) return 0;
return 0;
} else if (server.masterhost != NULL) { /* If we are running in the context of a slave, instead of
/* If we are running in the context of a slave, return ASAP: * evicting the expired key from the database, we return ASAP:
* the slave key expiration is controlled by the master that will * the slave key expiration is controlled by the master that will
* send us synthesized DEL operations for expired keys. * send us synthesized DEL operations for expired keys.
* *
* Still we try to return the right information to the caller, * Still we try to return the right information to the caller,
* that is, 0 if we think the key should be still valid, 1 if * that is, 0 if we think the key should be still valid, 1 if
* we think the key is expired at this time. */ * we think the key is expired at this time. */
return 1; if (server.masterhost != NULL) return 1;
}
/* Delete the key */ /* Delete the key */
server.stat_expiredkeys++; server.stat_expiredkeys++;