From 61697bab1efd325e204b808e87afcff91396d370 Mon Sep 17 00:00:00 2001 From: Aaron Schulz Date: Tue, 27 Jan 2015 02:15:03 -0800 Subject: [PATCH] Made BagOStuff::cas protected, which is just one merge() implementation Change-Id: I3ef82226231f7e03f7493ae042cad22339f4c869 --- includes/objectcache/APCBagOStuff.php | 2 +- includes/objectcache/BagOStuff.php | 20 +++++++++---------- includes/objectcache/EmptyBagOStuff.php | 8 ++++---- includes/objectcache/HashBagOStuff.php | 6 +++--- includes/objectcache/MemcachedBagOStuff.php | 2 +- .../objectcache/MemcachedPeclBagOStuff.php | 2 +- includes/objectcache/MultiWriteBagOStuff.php | 2 +- includes/objectcache/RedisBagOStuff.php | 2 +- includes/objectcache/SqlBagOStuff.php | 2 +- includes/objectcache/WinCacheBagOStuff.php | 2 +- includes/objectcache/XCacheBagOStuff.php | 2 +- 11 files changed, 25 insertions(+), 25 deletions(-) diff --git a/includes/objectcache/APCBagOStuff.php b/includes/objectcache/APCBagOStuff.php index 598692efdb..ae5dce0f3c 100644 --- a/includes/objectcache/APCBagOStuff.php +++ b/includes/objectcache/APCBagOStuff.php @@ -72,7 +72,7 @@ class APCBagOStuff extends BagOStuff { * @return bool * @throws MWException */ - public function cas( $casToken, $key, $value, $exptime = 0 ) { + protected function cas( $casToken, $key, $value, $exptime = 0 ) { // APC's CAS functions only work on integers throw new MWException( "CAS is not implemented in " . __CLASS__ ); } diff --git a/includes/objectcache/BagOStuff.php b/includes/objectcache/BagOStuff.php index c8c3497dbc..0758aef14d 100644 --- a/includes/objectcache/BagOStuff.php +++ b/includes/objectcache/BagOStuff.php @@ -100,16 +100,6 @@ abstract class BagOStuff implements LoggerAwareInterface { */ abstract public function set( $key, $value, $exptime = 0 ); - /** - * Check and set an item. - * @param mixed $casToken - * @param string $key - * @param mixed $value - * @param int $exptime Either an interval in seconds or a unix timestamp for expiry - * @return bool Success - */ - abstract public function cas( $casToken, $key, $value, $exptime = 0 ); - /** * Delete an item. * @param string $key @@ -161,6 +151,16 @@ abstract class BagOStuff implements LoggerAwareInterface { return $success; } + /** + * Check and set an item. + * @param mixed $casToken + * @param string $key + * @param mixed $value + * @param int $exptime Either an interval in seconds or a unix timestamp for expiry + * @return bool Success + */ + abstract protected function cas( $casToken, $key, $value, $exptime = 0 ); + /** * @see BagOStuff::merge() * diff --git a/includes/objectcache/EmptyBagOStuff.php b/includes/objectcache/EmptyBagOStuff.php index dbc57b98f8..05a3d3fe17 100644 --- a/includes/objectcache/EmptyBagOStuff.php +++ b/includes/objectcache/EmptyBagOStuff.php @@ -33,7 +33,7 @@ class EmptyBagOStuff extends BagOStuff { * @param mixed $casToken [optional] * @return bool */ - function get( $key, &$casToken = null ) { + public function get( $key, &$casToken = null ) { return false; } @@ -43,7 +43,7 @@ class EmptyBagOStuff extends BagOStuff { * @param int $exp * @return bool */ - function set( $key, $value, $exp = 0 ) { + public function set( $key, $value, $exp = 0 ) { return true; } @@ -54,7 +54,7 @@ class EmptyBagOStuff extends BagOStuff { * @param int $exp * @return bool */ - function cas( $casToken, $key, $value, $exp = 0 ) { + protected function cas( $casToken, $key, $value, $exp = 0 ) { return true; } @@ -62,7 +62,7 @@ class EmptyBagOStuff extends BagOStuff { * @param string $key * @return bool */ - function delete( $key ) { + public function delete( $key ) { return true; } diff --git a/includes/objectcache/HashBagOStuff.php b/includes/objectcache/HashBagOStuff.php index a46628228e..278a74e865 100644 --- a/includes/objectcache/HashBagOStuff.php +++ b/includes/objectcache/HashBagOStuff.php @@ -57,7 +57,7 @@ class HashBagOStuff extends BagOStuff { * @param mixed $casToken [optional] * @return bool|mixed */ - function get( $key, &$casToken = null ) { + public function get( $key, &$casToken = null ) { if ( !isset( $this->bag[$key] ) ) { return false; } @@ -77,7 +77,7 @@ class HashBagOStuff extends BagOStuff { * @param int $exptime * @return bool */ - function set( $key, $value, $exptime = 0 ) { + public function set( $key, $value, $exptime = 0 ) { $this->bag[$key] = array( $value, $this->convertExpiry( $exptime ) ); return true; } @@ -89,7 +89,7 @@ class HashBagOStuff extends BagOStuff { * @param int $exptime * @return bool */ - function cas( $casToken, $key, $value, $exptime = 0 ) { + protected function cas( $casToken, $key, $value, $exptime = 0 ) { if ( $this->get( $key ) === $casToken ) { return $this->set( $key, $value, $exptime ); } diff --git a/includes/objectcache/MemcachedBagOStuff.php b/includes/objectcache/MemcachedBagOStuff.php index 2b0efa9ef2..ac34570136 100644 --- a/includes/objectcache/MemcachedBagOStuff.php +++ b/includes/objectcache/MemcachedBagOStuff.php @@ -84,7 +84,7 @@ class MemcachedBagOStuff extends BagOStuff { * @param int $exptime * @return bool */ - public function cas( $casToken, $key, $value, $exptime = 0 ) { + protected function cas( $casToken, $key, $value, $exptime = 0 ) { return $this->client->cas( $casToken, $this->encodeKey( $key ), $value, $this->fixExpiry( $exptime ) ); } diff --git a/includes/objectcache/MemcachedPeclBagOStuff.php b/includes/objectcache/MemcachedPeclBagOStuff.php index 339a536a78..f2c49281ba 100644 --- a/includes/objectcache/MemcachedPeclBagOStuff.php +++ b/includes/objectcache/MemcachedPeclBagOStuff.php @@ -145,7 +145,7 @@ class MemcachedPeclBagOStuff extends MemcachedBagOStuff { * @param int $exptime * @return bool */ - public function cas( $casToken, $key, $value, $exptime = 0 ) { + protected function cas( $casToken, $key, $value, $exptime = 0 ) { $this->debugLog( "cas($key)" ); return $this->checkResult( $key, parent::cas( $casToken, $key, $value, $exptime ) ); } diff --git a/includes/objectcache/MultiWriteBagOStuff.php b/includes/objectcache/MultiWriteBagOStuff.php index b5333fdb57..9a32a27013 100644 --- a/includes/objectcache/MultiWriteBagOStuff.php +++ b/includes/objectcache/MultiWriteBagOStuff.php @@ -84,7 +84,7 @@ class MultiWriteBagOStuff extends BagOStuff { * @return bool * @throws MWException */ - public function cas( $casToken, $key, $value, $exptime = 0 ) { + protected function cas( $casToken, $key, $value, $exptime = 0 ) { throw new MWException( "CAS is not implemented in " . __CLASS__ ); } diff --git a/includes/objectcache/RedisBagOStuff.php b/includes/objectcache/RedisBagOStuff.php index 93cdae32ac..b1be9d83d0 100644 --- a/includes/objectcache/RedisBagOStuff.php +++ b/includes/objectcache/RedisBagOStuff.php @@ -115,7 +115,7 @@ class RedisBagOStuff extends BagOStuff { return $result; } - public function cas( $casToken, $key, $value, $expiry = 0 ) { + protected function cas( $casToken, $key, $value, $expiry = 0 ) { list( $server, $conn ) = $this->getConnection( $key ); if ( !$conn ) { diff --git a/includes/objectcache/SqlBagOStuff.php b/includes/objectcache/SqlBagOStuff.php index 03b0166b6a..b9a99853de 100644 --- a/includes/objectcache/SqlBagOStuff.php +++ b/includes/objectcache/SqlBagOStuff.php @@ -405,7 +405,7 @@ class SqlBagOStuff extends BagOStuff { * @param int $exptime * @return bool */ - public function cas( $casToken, $key, $value, $exptime = 0 ) { + protected function cas( $casToken, $key, $value, $exptime = 0 ) { list( $serverIndex, $tableName ) = $this->getTableByKey( $key ); try { $db = $this->getDB( $serverIndex ); diff --git a/includes/objectcache/WinCacheBagOStuff.php b/includes/objectcache/WinCacheBagOStuff.php index 8a71b884a1..f59ed4ea61 100644 --- a/includes/objectcache/WinCacheBagOStuff.php +++ b/includes/objectcache/WinCacheBagOStuff.php @@ -73,7 +73,7 @@ class WinCacheBagOStuff extends BagOStuff { * @param int $exptime Expiration time * @return bool */ - public function cas( $casToken, $key, $value, $exptime = 0 ) { + protected function cas( $casToken, $key, $value, $exptime = 0 ) { return wincache_ucache_cas( $key, $casToken, serialize( $value ) ); } diff --git a/includes/objectcache/XCacheBagOStuff.php b/includes/objectcache/XCacheBagOStuff.php index 10baee0b1d..a15e5c88b3 100644 --- a/includes/objectcache/XCacheBagOStuff.php +++ b/includes/objectcache/XCacheBagOStuff.php @@ -76,7 +76,7 @@ class XCacheBagOStuff extends BagOStuff { * @return bool * @throws MWException */ - public function cas( $casToken, $key, $value, $exptime = 0 ) { + protected function cas( $casToken, $key, $value, $exptime = 0 ) { // Can't find any documentation on xcache cas throw new MWException( "CAS is not implemented in " . __CLASS__ ); } -- 2.20.1