objectcache: add IExpiringStore::TTL_SECOND constant
authorAaron Schulz <aschulz@wikimedia.org>
Fri, 16 Feb 2018 22:23:49 +0000 (14:23 -0800)
committerAaron Schulz <aschulz@wikimedia.org>
Fri, 16 Feb 2018 22:23:49 +0000 (14:23 -0800)
Change-Id: Iec59ce72f3dbb0de68c8f6704d86f1522f86827e

includes/libs/objectcache/IExpiringStore.php
includes/libs/objectcache/WANObjectCache.php

index 0e09f16..7bab20a 100644 (file)
@@ -30,6 +30,7 @@
  */
 interface IExpiringStore {
        // Constants for TTL values, in seconds
+       const TTL_SECOND = 1;
        const TTL_MINUTE = 60;
        const TTL_HOUR = 3600;
        const TTL_DAY = 86400; // 24 * 3600
index 58d359c..bcd95c1 100644 (file)
@@ -1581,7 +1581,7 @@ class WANObjectCache implements IExpiringStore, LoggerAwareInterface {
                if ( $purge && $purge[self::FLD_TIME] < $purgeTimestamp ) {
                        $isStale = true;
                        $this->logger->warning( "Reaping stale check key '$key'." );
-                       $ok = $this->cache->changeTTL( self::TIME_KEY_PREFIX . $key, 1 );
+                       $ok = $this->cache->changeTTL( self::TIME_KEY_PREFIX . $key, self::TTL_SECOND );
                        if ( !$ok ) {
                                $this->logger->error( "Could not complete reap of check key '$key'." );
                        }
@@ -1824,7 +1824,7 @@ class WANObjectCache implements IExpiringStore, LoggerAwareInterface {
                                'cmd' => 'set',
                                'key' => $key,
                                'val' => 'PURGED:$UNIXTIME$:' . (int)$holdoff,
-                               'ttl' => max( $ttl, 1 ),
+                               'ttl' => max( $ttl, self::TTL_SECOND ),
                                'sbt' => true, // substitute $UNIXTIME$ with actual microtime
                        ] );