From: Aaron Schulz Date: Thu, 25 Sep 2014 19:04:09 +0000 (-0700) Subject: Improved timestamp precision in ProcessCacheLRU X-Git-Tag: 1.31.0-rc.0~13717^2 X-Git-Url: http://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/exercices/supprimer.php?a=commitdiff_plain;h=149e397fbeb47faff84f6b0ee928fa975671356b;p=lhc%2Fweb%2Fwiklou.git Improved timestamp precision in ProcessCacheLRU Change-Id: I42f27df4ec9f944bd308e13eb832d84f1d9492a9 --- diff --git a/includes/libs/ProcessCacheLRU.php b/includes/libs/ProcessCacheLRU.php index f988207a89..ce97142d77 100644 --- a/includes/libs/ProcessCacheLRU.php +++ b/includes/libs/ProcessCacheLRU.php @@ -61,7 +61,7 @@ class ProcessCacheLRU { unset( $this->cacheTimes[$evictKey] ); } $this->cache[$key][$prop] = $value; - $this->cacheTimes[$key][$prop] = time(); + $this->cacheTimes[$key][$prop] = microtime( true ); } /** @@ -69,12 +69,13 @@ class ProcessCacheLRU { * * @param $key string * @param $prop string - * @param $maxAge integer Ignore items older than this many seconds (since 1.21) + * @param $maxAge float Ignore items older than this many seconds (since 1.21) * @return bool */ - public function has( $key, $prop, $maxAge = 0 ) { + public function has( $key, $prop, $maxAge = 0.0 ) { if ( isset( $this->cache[$key][$prop] ) ) { - return ( $maxAge <= 0 || ( time() - $this->cacheTimes[$key][$prop] ) <= $maxAge ); + return ( $maxAge <= 0 || + ( microtime( true ) - $this->cacheTimes[$key][$prop] ) <= $maxAge ); } return false; @@ -121,6 +122,7 @@ class ProcessCacheLRU { * * @param $maxKeys integer * @return void + * @throws UnexpectedValueException */ public function resize( $maxKeys ) { if ( !is_int( $maxKeys ) || $maxKeys < 1 ) {