From: Aaron Schulz Date: Mon, 15 Aug 2016 19:21:10 +0000 (-0700) Subject: objectcache: Optimize changeTTL() for SqlBagOStuff X-Git-Tag: 1.31.0-rc.0~6022^2 X-Git-Url: https://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/comptes/ajouter.php?a=commitdiff_plain;h=ab0aaef7adc477a233066ec264de3259e3db23ed;p=lhc%2Fweb%2Fwiklou.git objectcache: Optimize changeTTL() for SqlBagOStuff Change-Id: I539dd83175a8ea922221f194e23ca47aea7539cf --- diff --git a/includes/objectcache/SqlBagOStuff.php b/includes/objectcache/SqlBagOStuff.php index c48880fe79..5556dd8923 100644 --- a/includes/objectcache/SqlBagOStuff.php +++ b/includes/objectcache/SqlBagOStuff.php @@ -471,6 +471,27 @@ class SqlBagOStuff extends BagOStuff { return $ok; } + public function changeTTL( $key, $expiry = 0 ) { + list( $serverIndex, $tableName ) = $this->getTableByKey( $key ); + try { + $db = $this->getDB( $serverIndex ); + $db->update( + $tableName, + [ 'exptime' => $db->timestamp( $this->convertExpiry( $expiry ) ) ], + [ 'keyname' => $key, 'exptime > ' . $db->addQuotes( $db->timestamp( time() ) ) ], + __METHOD__ + ); + if ( $db->affectedRows() == 0 ) { + return false; + } + } catch ( DBError $e ) { + $this->handleWriteError( $e, $serverIndex ); + return false; + } + + return true; + } + /** * @param IDatabase $db * @param string $exptime