Helper function for the activeExpireCycle() function. * This function will try to expire the key that is stored in the hash table * entry 'de' of the 'expires' hash table of a Redis database. * * If the key is found to be expired, it is removed from the database and * 1 is returned. Otherwise no operation is performed and 0 is returned. * * When a key is expired, server.stat_expiredkeys is
| 52 | * The parameter 'now' is the current time in milliseconds as is passed |
| 53 | * to the function to avoid too many gettimeofday() syscalls. */ |
| 54 | int activeExpireCycleTryExpire(redisDb *db, dictEntry *de, long long now) { |
| 55 | long long t = dictGetSignedIntegerVal(de); |
| 56 | if (now > t) { |
| 57 | sds key = dictGetKey(de); |
| 58 | robj *keyobj = createStringObject(key,sdslen(key)); |
| 59 | deleteExpiredKeyAndPropagate(db,keyobj); |
| 60 | decrRefCount(keyobj); |
| 61 | return 1; |
| 62 | } else { |
| 63 | return 0; |
| 64 | } |
| 65 | } |
| 66 | |
| 67 | /* Try to expire a few timed out keys. The algorithm used is adaptive and |
| 68 | * will use few CPU cycles if there are few expiring keys, otherwise |
no test coverage detected