objectcache: use INTERIM_KEY_TTL constant in WANObjectCache for readability
[lhc/web/wiklou.git] / includes / libs / objectcache / WANObjectCache.php
index 830200a..db27e42 100644 (file)
@@ -111,6 +111,9 @@ class WANObjectCache implements IExpiringStore, LoggerAwareInterface {
 
        /** Seconds to keep dependency purge keys around */
        const CHECK_KEY_TTL = self::TTL_YEAR;
+       /** Seconds to keep interim value keys for tombstoned keys around */
+       const INTERIM_KEY_TTL = 1;
+
        /** Seconds to keep lock keys around */
        const LOCK_TTL = 10;
        /** Default remaining TTL at which to consider pre-emptive regeneration */
@@ -914,11 +917,14 @@ class WANObjectCache implements IExpiringStore, LoggerAwareInterface {
                                        use ( $callback, $version ) {
                                                if ( is_array( $oldValue )
                                                        && array_key_exists( self::VFLD_DATA, $oldValue )
+                                                       && array_key_exists( self::VFLD_VERSION, $oldValue )
+                                                       && $oldValue[self::VFLD_VERSION] === $version
                                                ) {
                                                        $oldData = $oldValue[self::VFLD_DATA];
                                                } else {
                                                        // VFLD_DATA is not set if an old, unversioned, key is present
                                                        $oldData = false;
+                                                       $oldAsOf = null;
                                                }
 
                                                return [
@@ -1006,7 +1012,7 @@ class WANObjectCache implements IExpiringStore, LoggerAwareInterface {
                $isTombstone = ( $curTTL !== null && $value === false );
                if ( $isTombstone && $lockTSE <= 0 ) {
                        // Use the INTERIM value for tombstoned keys to reduce regeneration load
-                       $lockTSE = 1;
+                       $lockTSE = self::INTERIM_KEY_TTL;
                }
                // Assume a key is hot if requested soon after invalidation
                $isHot = ( $curTTL !== null && $curTTL <= 0 && abs( $curTTL ) <= $lockTSE );