From ab0aaef7adc477a233066ec264de3259e3db23ed Mon Sep 17 00:00:00 2001 From: Aaron Schulz Date: Mon, 15 Aug 2016 12:21:10 -0700 Subject: [PATCH] objectcache: Optimize changeTTL() for SqlBagOStuff Change-Id: I539dd83175a8ea922221f194e23ca47aea7539cf --- includes/objectcache/SqlBagOStuff.php | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) 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 -- 2.20.1