X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Flibs%2Fobjectcache%2FMemcachedBagOStuff.php;h=dc409315f842704c41cd6a84fdc444c004cbfcb2;hb=41355718e137b2ed88160ad5ddb4db50336d54d9;hp=f75e780c808cb6d2424e5d4b4145342d72bf8580;hpb=7bdfadde3fe1b14ff633ff740f77d74585b8e00a;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/libs/objectcache/MemcachedBagOStuff.php b/includes/libs/objectcache/MemcachedBagOStuff.php index f75e780c80..dc409315f8 100644 --- a/includes/libs/objectcache/MemcachedBagOStuff.php +++ b/includes/libs/objectcache/MemcachedBagOStuff.php @@ -26,7 +26,7 @@ * * @ingroup Cache */ -abstract class MemcachedBagOStuff extends BagOStuff { +abstract class MemcachedBagOStuff extends MediumSpecificBagOStuff { function __construct( array $params ) { parent::__construct( $params ); @@ -96,18 +96,24 @@ abstract class MemcachedBagOStuff extends BagOStuff { } /** - * TTLs higher than 30 days will be detected as absolute TTLs - * (UNIX timestamps), and will result in the cache entry being - * discarded immediately because the expiry is in the past. - * Clamp expires >30d at 30d, unless they're >=1e9 in which - * case they are likely to really be absolute (1e9 = 2011-09-09) - * @param int $expiry + * @param int|float $exptime * @return int */ - function fixExpiry( $expiry ) { - if ( $expiry > 2592000 && $expiry < 1000000000 ) { - $expiry = 2592000; + protected function fixExpiry( $exptime ) { + if ( $exptime < 0 ) { + // The PECL driver does not seem to like negative relative values + $expiresAt = $this->getCurrentTime() + $exptime; + } elseif ( $this->isRelativeExpiration( $exptime ) ) { + // TTLs higher than 30 days will be detected as absolute TTLs + // (UNIX timestamps), and will result in the cache entry being + // discarded immediately because the expiry is in the past. + // Clamp expires >30d at 30d, unless they're >=1e9 in which + // case they are likely to really be absolute (1e9 = 2011-09-09) + $expiresAt = min( $exptime, self::TTL_MONTH ); + } else { + $expiresAt = $exptime; } - return (int)$expiry; + + return (int)$expiresAt; } }