aboutsummaryrefslogtreecommitdiffstats
path: root/includes/libs/objectcache
diff options
context:
space:
mode:
Diffstat (limited to 'includes/libs/objectcache')
-rw-r--r--includes/libs/objectcache/APCUBagOStuff.php5
-rw-r--r--includes/libs/objectcache/BagOStuff.php49
-rw-r--r--includes/libs/objectcache/CachedBagOStuff.php6
-rw-r--r--includes/libs/objectcache/EmptyBagOStuff.php5
-rw-r--r--includes/libs/objectcache/HashBagOStuff.php13
-rw-r--r--includes/libs/objectcache/IStoreKeyEncoder.php9
-rw-r--r--includes/libs/objectcache/MediumSpecificBagOStuff.php69
-rw-r--r--includes/libs/objectcache/MemcachedBagOStuff.php17
-rw-r--r--includes/libs/objectcache/MemcachedPeclBagOStuff.php17
-rw-r--r--includes/libs/objectcache/MemcachedPhpBagOStuff.php14
-rw-r--r--includes/libs/objectcache/MultiWriteBagOStuff.php11
-rw-r--r--includes/libs/objectcache/RESTBagOStuff.php13
-rw-r--r--includes/libs/objectcache/RedisBagOStuff.php18
-rw-r--r--includes/libs/objectcache/ReplicatedBagOStuff.php2
-rw-r--r--includes/libs/objectcache/WinCacheBagOStuff.php5
-rw-r--r--includes/libs/objectcache/wancache/WANObjectCache.php3
16 files changed, 244 insertions, 12 deletions
diff --git a/includes/libs/objectcache/APCUBagOStuff.php b/includes/libs/objectcache/APCUBagOStuff.php
index 8395fb75d262..9f88883b374f 100644
--- a/includes/libs/objectcache/APCUBagOStuff.php
+++ b/includes/libs/objectcache/APCUBagOStuff.php
@@ -21,6 +21,8 @@
* @ingroup Cache
*/
+namespace Wikimedia\ObjectCache;
+
/**
* This is a wrapper for APCu's shared memory functions
*
@@ -133,3 +135,6 @@ class APCUBagOStuff extends MediumSpecificBagOStuff {
return $result;
}
}
+
+/** @deprecated class alias since 1.43 */
+class_alias( APCUBagOStuff::class, 'APCUBagOStuff' );
diff --git a/includes/libs/objectcache/BagOStuff.php b/includes/libs/objectcache/BagOStuff.php
index 96a79924c872..41d076213ce2 100644
--- a/includes/libs/objectcache/BagOStuff.php
+++ b/includes/libs/objectcache/BagOStuff.php
@@ -26,6 +26,9 @@
* @defgroup Cache Cache
*/
+namespace Wikimedia\ObjectCache;
+
+use InvalidArgumentException;
use Psr\Log\LoggerAwareInterface;
use Psr\Log\LoggerInterface;
use Psr\Log\NullLogger;
@@ -151,13 +154,15 @@ abstract class BagOStuff implements
/**
* @stable to call
+ *
* @param array $params Parameters include:
* - keyspace: Keyspace to use for keys in makeKey(). [Default: "local"]
* - asyncHandler: Callable to use for scheduling tasks after the web request ends.
* In CLI mode, it should run the task immediately. [Default: null]
* - stats: IStatsdDataFactory instance. [optional]
- * - logger: Psr\Log\LoggerInterface instance. [optional]
- * @phan-param array{keyspace?:string,logger?:Psr\Log\LoggerInterface,asyncHandler?:callable} $params
+ * - logger: \Psr\Log\LoggerInterface instance. [optional]
+ *
+ * @phan-param array{keyspace?:string,logger?:\Psr\Log\LoggerInterface,asyncHandler?:callable} $params
*/
public function __construct( array $params = [] ) {
$this->keyspace = $params['keyspace'] ?? 'local';
@@ -172,6 +177,7 @@ abstract class BagOStuff implements
/**
* @param LoggerInterface $logger
+ *
* @return void
*/
public function setLogger( LoggerInterface $logger ) {
@@ -196,6 +202,7 @@ abstract class BagOStuff implements
* @param int $exptime Time-to-live (seconds)
* @param callable $callback Callback that derives the new value
* @param int $flags Bitfield of BagOStuff::READ_* or BagOStuff::WRITE_* constants [optional]
+ *
* @return mixed The cached value if found or the result of $callback otherwise
* @since 1.27
*/
@@ -223,6 +230,7 @@ abstract class BagOStuff implements
*
* @param string $key
* @param int $flags Bitfield of BagOStuff::READ_* constants [optional]
+ *
* @return mixed Returns false on failure or if the item does not exist
*/
abstract public function get( $key, $flags = 0 );
@@ -234,6 +242,7 @@ abstract class BagOStuff implements
* @param mixed $value
* @param int $exptime Either an interval in seconds or a unix timestamp for expiry
* @param int $flags Bitfield of BagOStuff::WRITE_* constants
+ *
* @return bool Success
*/
abstract public function set( $key, $value, $exptime = 0, $flags = 0 );
@@ -247,6 +256,7 @@ abstract class BagOStuff implements
*
* @param string $key
* @param int $flags Bitfield of BagOStuff::WRITE_* constants
+ *
* @return bool Success (item deleted or not found)
*/
abstract public function delete( $key, $flags = 0 );
@@ -258,6 +268,7 @@ abstract class BagOStuff implements
* @param mixed $value
* @param int $exptime
* @param int $flags Bitfield of BagOStuff::WRITE_* constants (since 1.33)
+ *
* @return bool Success (item created)
*/
abstract public function add( $key, $value, $exptime = 0, $flags = 0 );
@@ -276,6 +287,7 @@ abstract class BagOStuff implements
* @param int $exptime Either an interval in seconds or a unix timestamp for expiry
* @param int $attempts The amount of times to attempt a merge in case of failure
* @param int $flags Bitfield of BagOStuff::WRITE_* constants
+ *
* @return bool Success
* @throws InvalidArgumentException
*/
@@ -301,6 +313,7 @@ abstract class BagOStuff implements
* @param string $key
* @param int $exptime TTL or UNIX timestamp
* @param int $flags Bitfield of BagOStuff::WRITE_* constants (since 1.33)
+ *
* @return bool Success (item found and updated)
* @since 1.28
*/
@@ -316,6 +329,7 @@ abstract class BagOStuff implements
* using the same value for this parameter, then return true and use reference counting so
* that only the unlock() call from the outermost lock() caller actually releases the lock
* (note that only the outermost time-to-live is used) [optional]
+ *
* @return bool Success
*/
abstract public function lock( $key, $timeout = 6, $exptime = 6, $rclass = '' );
@@ -324,6 +338,7 @@ abstract class BagOStuff implements
* Release an advisory lock on a key string
*
* @param string $key
+ *
* @return bool Success
*/
abstract public function unlock( $key );
@@ -341,6 +356,7 @@ abstract class BagOStuff implements
* @param int $timeout Lock wait timeout; 0 for non-blocking [optional]
* @param int $exptime Lock time-to-live [optional]; 1 day maximum
* @param string $rclass Allow reentry if set and the current lock used this value
+ *
* @return ScopedCallback|null Returns null on failure
* @since 1.26
*/
@@ -366,6 +382,7 @@ abstract class BagOStuff implements
* @param int|float $limit Maximum number of keys to delete [default: INF]
* @param string|null $tag Tag to purge a single shard only.
* This is only supported when server tags are used in configuration.
+ *
* @return bool Success; false if unimplemented
*/
abstract public function deleteObjectsExpiringBefore(
@@ -380,6 +397,7 @@ abstract class BagOStuff implements
*
* @param string[] $keys List of keys
* @param int $flags Bitfield; supports READ_LATEST [optional]
+ *
* @return mixed[] Map of (key => value) for existing keys
*/
abstract public function getMulti( array $keys, $flags = 0 );
@@ -394,6 +412,7 @@ abstract class BagOStuff implements
* @param mixed[] $valueByKey Map of (key => value)
* @param int $exptime Either an interval in seconds or a unix timestamp for expiry
* @param int $flags Bitfield of BagOStuff::WRITE_* constants (since 1.33)
+ *
* @return bool Success
* @since 1.24
*/
@@ -408,6 +427,7 @@ abstract class BagOStuff implements
*
* @param string[] $keys List of keys
* @param int $flags Bitfield of BagOStuff::WRITE_* constants
+ *
* @return bool Success (items deleted and/or not found)
* @since 1.33
*/
@@ -421,6 +441,7 @@ abstract class BagOStuff implements
* @param string[] $keys List of keys
* @param int $exptime TTL or UNIX timestamp
* @param int $flags Bitfield of BagOStuff::WRITE_* constants (since 1.33)
+ *
* @return bool Success (all items found and updated)
* @since 1.34
*/
@@ -441,6 +462,7 @@ abstract class BagOStuff implements
* @param int $step Amount to increase the key value by [default: 1]
* @param int|null $init Value to initialize the key to if it does not exist [default: $step]
* @param int $flags Bit field of class WRITE_* constants [optional]
+ *
* @return int|bool New value (or true if asynchronous) on success; false on failure
* @since 1.24
*/
@@ -470,6 +492,7 @@ abstract class BagOStuff implements
* - The caller invokes getLastError()
*
* @param int $watchPoint Only consider errors from after this "watch point" [optional]
+ *
* @return int BagOStuff:ERR_* constant for the "last error" registry
* @note Parameters added in 1.38: $watchPoint
* @since 1.23
@@ -492,6 +515,7 @@ abstract class BagOStuff implements
* Set the "last error" registry due to a problem encountered during an attempted operation
*
* @param int $error BagOStuff:ERR_* constant
+ *
* @since 1.23
*/
protected function setLastError( $error ) {
@@ -509,8 +533,10 @@ abstract class BagOStuff implements
*
* @see BagOStuff::makeKeyInternal
* @since 1.27
+ *
* @param string $keygroup Key group component, should be under 48 characters.
* @param string|int ...$components Additional, ordered, key components for entity IDs
+ *
* @return string Colon-separated, keyspace-prepended, ordered list of encoded components
*/
public function makeGlobalKey( $keygroup, ...$components ) {
@@ -538,8 +564,10 @@ abstract class BagOStuff implements
*
* @see BagOStuff::makeKeyInternal
* @since 1.27
+ *
* @param string $keygroup Key group component, should be under 48 characters.
* @param string|int ...$components Additional, ordered, key components for entity IDs
+ *
* @return string Colon-separated, keyspace-prepended, ordered list of encoded components
*/
public function makeKey( $keygroup, ...$components ) {
@@ -550,6 +578,7 @@ abstract class BagOStuff implements
* Check whether a cache key is in the global keyspace
*
* @param string $key
+ *
* @return bool
* @since 1.35
*/
@@ -559,6 +588,7 @@ abstract class BagOStuff implements
/**
* @param int $flag BagOStuff::ATTR_* constant
+ *
* @return int BagOStuff:QOS_* constant
* @since 1.28
*/
@@ -573,6 +603,7 @@ abstract class BagOStuff implements
*/
public function getSegmentationSize() {
wfDeprecated( __METHOD__, '1.43' );
+
return INF;
}
@@ -583,12 +614,14 @@ abstract class BagOStuff implements
*/
public function getSegmentedValueMaxSize() {
wfDeprecated( __METHOD__, '1.43' );
+
return INF;
}
/**
* @param int $field
* @param int $flags
+ *
* @return bool
* @since 1.34
*/
@@ -600,6 +633,7 @@ abstract class BagOStuff implements
* Merge the flag maps of one or more BagOStuff objects into a "lowest common denominator" map
*
* @param BagOStuff[] $bags
+ *
* @return int[] Resulting flag map (class ATTR_* constant => class QOS_* constant)
*/
final protected function mergeFlagMaps( array $bags ) {
@@ -630,8 +664,10 @@ abstract class BagOStuff implements
*
* @see BagOStuff::proxyCall
* @since 1.27
+ *
* @param string $keyspace
* @param string[]|int[] $components Key group and other components
+ *
* @return string
*/
protected function makeKeyInternal( $keyspace, $components ) {
@@ -644,6 +680,7 @@ abstract class BagOStuff implements
// Escape delimiter (":") and escape ("%") characters
$key .= ':' . strtr( $component, [ '%' => '%25', ':' => '%3A' ] );
}
+
return $key;
}
@@ -664,7 +701,9 @@ abstract class BagOStuff implements
* Convert a key from BagOStuff::makeKeyInternal into one for the current subclass
*
* @see BagOStuff::proxyCall
+ *
* @param string $key Result from BagOStuff::makeKeyInternal
+ *
* @return string Result from current subclass override of BagOStuff::makeKeyInternal
*/
private function convertGenericKey( $key ) {
@@ -704,6 +743,7 @@ abstract class BagOStuff implements
* @param int $resSig BagOStuff::RES_* constant describing the return value
* @param array $genericArgs Method arguments passed to the wrapper instance
* @param BagOStuff $wrapper The wrapper BagOStuff instance using this result
+ *
* @return mixed Method result with any keys remapped to "generic" keys
*/
protected function proxyCall(
@@ -767,10 +807,15 @@ abstract class BagOStuff implements
/**
* @internal For testing only
+ *
* @param float|null &$time Mock UNIX timestamp
+ *
* @codeCoverageIgnore
*/
public function setMockTime( &$time ) {
$this->wallClockOverride =& $time;
}
}
+
+/** @deprecated class alias since 1.43 */
+class_alias( BagOStuff::class, 'BagOStuff' );
diff --git a/includes/libs/objectcache/CachedBagOStuff.php b/includes/libs/objectcache/CachedBagOStuff.php
index 72662e6f5a01..80163e8e2839 100644
--- a/includes/libs/objectcache/CachedBagOStuff.php
+++ b/includes/libs/objectcache/CachedBagOStuff.php
@@ -21,6 +21,8 @@
* @ingroup Cache
*/
+namespace Wikimedia\ObjectCache;
+
/**
* Wrapper around a BagOStuff that caches data in memory
*
@@ -42,6 +44,7 @@ class CachedBagOStuff extends BagOStuff {
/**
* @stable to call
+ *
* @param BagOStuff $backend Permanent backend to use
* @param array $params Parameters for HashBagOStuff
*/
@@ -271,3 +274,6 @@ class CachedBagOStuff extends BagOStuff {
// @codeCoverageIgnoreEnd
}
+
+/** @deprecated class alias since 1.43 */
+class_alias( CachedBagOStuff::class, 'CachedBagOStuff' );
diff --git a/includes/libs/objectcache/EmptyBagOStuff.php b/includes/libs/objectcache/EmptyBagOStuff.php
index d9d1c314153b..eef3cc0017d3 100644
--- a/includes/libs/objectcache/EmptyBagOStuff.php
+++ b/includes/libs/objectcache/EmptyBagOStuff.php
@@ -21,6 +21,8 @@
* @ingroup Cache
*/
+namespace Wikimedia\ObjectCache;
+
/**
* A BagOStuff object with no objects in it. Used to provide a no-op object to calling code.
*
@@ -61,3 +63,6 @@ class EmptyBagOStuff extends MediumSpecificBagOStuff {
return true;
}
}
+
+/** @deprecated class alias since 1.43 */
+class_alias( EmptyBagOStuff::class, 'EmptyBagOStuff' );
diff --git a/includes/libs/objectcache/HashBagOStuff.php b/includes/libs/objectcache/HashBagOStuff.php
index aebbaf3ed4db..07b74fbfbd90 100644
--- a/includes/libs/objectcache/HashBagOStuff.php
+++ b/includes/libs/objectcache/HashBagOStuff.php
@@ -21,6 +21,10 @@
* @ingroup Cache
*/
+namespace Wikimedia\ObjectCache;
+
+use InvalidArgumentException;
+
/**
* Simple store for keeping values in an associative array for the current process.
*
@@ -47,10 +51,12 @@ class HashBagOStuff extends MediumSpecificBagOStuff {
/**
* @stable to call
+ *
* @param array $params Additional parameters include:
* - maxKeys : only allow this many keys (using oldest-first eviction)
+ *
* @phpcs:ignore Generic.Files.LineLength
- * @phan-param array{logger?:Psr\Log\LoggerInterface,asyncHandler?:callable,keyspace?:string,reportDupes?:bool,segmentationSize?:int,segmentedValueMaxSize?:int,maxKeys?:int} $params
+ * @phan-param array{logger?:\Psr\Log\LoggerInterface,asyncHandler?:callable,keyspace?:string,reportDupes?:bool,segmentationSize?:int,segmentedValueMaxSize?:int,maxKeys?:int} $params
*/
public function __construct( $params = [] ) {
$params['segmentationSize'] ??= INF;
@@ -142,6 +148,7 @@ class HashBagOStuff extends MediumSpecificBagOStuff {
/**
* @param string $key
+ *
* @return bool
*/
protected function expire( $key ) {
@@ -159,6 +166,7 @@ class HashBagOStuff extends MediumSpecificBagOStuff {
* Does this bag have a non-null value for the given key?
*
* @param string $key
+ *
* @return bool
* @since 1.27
*/
@@ -166,3 +174,6 @@ class HashBagOStuff extends MediumSpecificBagOStuff {
return isset( $this->bag[$key] );
}
}
+
+/** @deprecated class alias since 1.43 */
+class_alias( HashBagOStuff::class, 'HashBagOStuff' );
diff --git a/includes/libs/objectcache/IStoreKeyEncoder.php b/includes/libs/objectcache/IStoreKeyEncoder.php
index b7223ef44f7f..b39ec8035dd8 100644
--- a/includes/libs/objectcache/IStoreKeyEncoder.php
+++ b/includes/libs/objectcache/IStoreKeyEncoder.php
@@ -1,5 +1,7 @@
<?php
+namespace Wikimedia\ObjectCache;
+
/**
* Key-encoding methods for object caching (BagOStuff and WANObjectCache)
*
@@ -9,17 +11,24 @@
interface IStoreKeyEncoder {
/**
* @see BagOStuff::makeGlobalKey
+ *
* @param string $keygroup
* @param string|int ...$components
+ *
* @return string
*/
public function makeGlobalKey( $keygroup, ...$components );
/**
* @see BagOStuff::makeKey
+ *
* @param string $keygroup
* @param string|int ...$components
+ *
* @return string
*/
public function makeKey( $keygroup, ...$components );
}
+
+/** @deprecated class alias since 1.43 */
+class_alias( IStoreKeyEncoder::class, 'IStoreKeyEncoder' );
diff --git a/includes/libs/objectcache/MediumSpecificBagOStuff.php b/includes/libs/objectcache/MediumSpecificBagOStuff.php
index 6d4bd0fe2d95..7530f2602ddd 100644
--- a/includes/libs/objectcache/MediumSpecificBagOStuff.php
+++ b/includes/libs/objectcache/MediumSpecificBagOStuff.php
@@ -21,6 +21,12 @@
* @ingroup Cache
*/
+namespace Wikimedia\ObjectCache;
+
+use InvalidArgumentException;
+use JsonSerializable;
+use SerializedValueContainer;
+use stdClass;
use Wikimedia\WaitConditionLoop;
/**
@@ -81,9 +87,11 @@ abstract class MediumSpecificBagOStuff extends BagOStuff {
* - segmentedValueMaxSize: The maximum total size, in bytes, of segmented values.
* This should be configured to a reasonable size give the site traffic and the
* amount of I/O between application and cache servers that the network can handle.
+ *
* @param array $params
+ *
* @phpcs:ignore Generic.Files.LineLength
- * @phan-param array{logger?:Psr\Log\LoggerInterface,asyncHandler?:callable,reportDupes?:bool,segmentationSize?:int|float,segmentedValueMaxSize?:int} $params
+ * @phan-param array{logger?:\Psr\Log\LoggerInterface,asyncHandler?:callable,reportDupes?:bool,segmentationSize?:int|float,segmentedValueMaxSize?:int} $params
*/
public function __construct( array $params = [] ) {
parent::__construct( $params );
@@ -109,6 +117,7 @@ abstract class MediumSpecificBagOStuff extends BagOStuff {
*
* @param string $key
* @param int $flags Bitfield of BagOStuff::READ_* constants [optional]
+ *
* @return mixed Returns false on failure or if the item does not exist
*/
public function get( $key, $flags = 0 ) {
@@ -119,6 +128,7 @@ abstract class MediumSpecificBagOStuff extends BagOStuff {
/**
* Track the number of times that a given key has been used.
+ *
* @param string $key
*/
private function trackDuplicateKeys( $key ) {
@@ -158,6 +168,7 @@ abstract class MediumSpecificBagOStuff extends BagOStuff {
* @param string $key
* @param int $flags Bitfield of BagOStuff::READ_* constants [optional]
* @param mixed &$casToken CAS token if MediumSpecificBagOStuff::PASS_BY_REF [returned]
+ *
* @return mixed Returns false on failure or if the item does not exist
*/
abstract protected function doGet( $key, $flags = 0, &$casToken = null );
@@ -169,10 +180,12 @@ abstract class MediumSpecificBagOStuff extends BagOStuff {
* @param mixed $value
* @param int $exptime Either an interval in seconds or a unix timestamp for expiry
* @param int $flags Bitfield of BagOStuff::WRITE_* constants
+ *
* @return bool Success
*/
public function set( $key, $value, $exptime = 0, $flags = 0 ) {
$entry = $this->makeValueOrSegmentList( $key, $value, $exptime, $flags, $ok );
+
// Only when all segments (if any) are stored should the main key be changed
return $ok && $this->doSet( $key, $entry, $exptime, $flags );
}
@@ -184,6 +197,7 @@ abstract class MediumSpecificBagOStuff extends BagOStuff {
* @param mixed $value
* @param int $exptime Either an interval in seconds or a unix timestamp for expiry
* @param int $flags Bitfield of BagOStuff::WRITE_* constants
+ *
* @return bool Success
*/
abstract protected function doSet( $key, $value, $exptime = 0, $flags = 0 );
@@ -197,6 +211,7 @@ abstract class MediumSpecificBagOStuff extends BagOStuff {
*
* @param string $key
* @param int $flags Bitfield of BagOStuff::WRITE_* constants
+ *
* @return bool True if the item was deleted or not found, false on failure
*/
public function delete( $key, $flags = 0 ) {
@@ -229,12 +244,14 @@ abstract class MediumSpecificBagOStuff extends BagOStuff {
*
* @param string $key
* @param int $flags Bitfield of BagOStuff::WRITE_* constants
+ *
* @return bool True if the item was deleted or not found, false on failure
*/
abstract protected function doDelete( $key, $flags = 0 );
public function add( $key, $value, $exptime = 0, $flags = 0 ) {
$entry = $this->makeValueOrSegmentList( $key, $value, $exptime, $flags, $ok );
+
// Only when all segments (if any) are stored should the main key be changed
return $ok && $this->doAdd( $key, $entry, $exptime, $flags );
}
@@ -246,6 +263,7 @@ abstract class MediumSpecificBagOStuff extends BagOStuff {
* @param mixed $value
* @param int $exptime
* @param int $flags Bitfield of BagOStuff::WRITE_* constants (since 1.33)
+ *
* @return bool Success
*/
abstract protected function doAdd( $key, $value, $exptime = 0, $flags = 0 );
@@ -264,6 +282,7 @@ abstract class MediumSpecificBagOStuff extends BagOStuff {
* @param int $exptime Either an interval in seconds or a unix timestamp for expiry
* @param int $attempts The amount of times to attempt a merge in case of failure
* @param int $flags Bitfield of BagOStuff::WRITE_* constants
+ *
* @return bool Success
*/
public function merge( $key, callable $callback, $exptime = 0, $attempts = 10, $flags = 0 ) {
@@ -276,6 +295,7 @@ abstract class MediumSpecificBagOStuff extends BagOStuff {
* @param int $exptime Either an interval in seconds or a unix timestamp for expiry
* @param int $attempts The amount of times to attempt a merge in case of failure
* @param int $flags Bitfield of BagOStuff::WRITE_* constants
+ *
* @return bool Success
* @see BagOStuff::merge()
*/
@@ -292,8 +312,7 @@ abstract class MediumSpecificBagOStuff extends BagOStuff {
if ( $this->getLastError( $watchPoint ) ) {
// Don't spam slow retries due to network problems (retry only on races)
$this->logger->warning(
- __METHOD__ . ' failed due to read I/O error on get() for {key}.',
- [ 'key' => $key ]
+ __METHOD__ . ' failed due to read I/O error on get() for {key}.', [ 'key' => $key ]
);
$success = false;
break;
@@ -343,6 +362,7 @@ abstract class MediumSpecificBagOStuff extends BagOStuff {
* @param mixed $value
* @param int $exptime Either an interval in seconds or a unix timestamp for expiry
* @param int $flags Bitfield of BagOStuff::WRITE_* constants
+ *
* @return bool Success
*/
protected function cas( $casToken, $key, $value, $exptime = 0, $flags = 0 ) {
@@ -357,6 +377,7 @@ abstract class MediumSpecificBagOStuff extends BagOStuff {
}
$entry = $this->makeValueOrSegmentList( $key, $value, $exptime, $flags, $ok );
+
// Only when all segments (if any) are stored should the main key be changed
return $ok && $this->doCas( $casToken, $key, $entry, $exptime, $flags );
}
@@ -369,6 +390,7 @@ abstract class MediumSpecificBagOStuff extends BagOStuff {
* @param mixed $value
* @param int $exptime Either an interval in seconds or a unix timestamp for expiry
* @param int $flags Bitfield of BagOStuff::WRITE_* constants
+ *
* @return bool Success
*/
protected function doCas( $casToken, $key, $value, $exptime = 0, $flags = 0 ) {
@@ -407,6 +429,7 @@ abstract class MediumSpecificBagOStuff extends BagOStuff {
/**
* @param mixed $value CAS token for an existing key
* @param mixed $otherValue CAS token for an existing key
+ *
* @return bool Whether the two tokens match
*/
final protected function tokensMatch( $value, $otherValue ) {
@@ -421,6 +444,7 @@ abstract class MediumSpecificBagOStuff extends BagOStuff {
if ( $type === 'array' || $type === 'object' ) {
return ( serialize( $value ) === serialize( $otherValue ) );
}
+
// For string/integer tokens, use a simple comparison
return ( $value === $otherValue );
}
@@ -439,6 +463,7 @@ abstract class MediumSpecificBagOStuff extends BagOStuff {
* @param string $key
* @param int $exptime TTL or UNIX timestamp
* @param int $flags Bitfield of BagOStuff::WRITE_* constants (since 1.33)
+ *
* @return bool Success Returns false on failure or if the item does not exist
* @since 1.28
*/
@@ -450,6 +475,7 @@ abstract class MediumSpecificBagOStuff extends BagOStuff {
* @param string $key
* @param int $exptime
* @param int $flags
+ *
* @return bool
*/
protected function doChangeTTL( $key, $exptime, $flags ) {
@@ -491,6 +517,7 @@ abstract class MediumSpecificBagOStuff extends BagOStuff {
* @param int $step
* @param int $init
* @param int $flags
+ *
* @return int|bool New value or false on failure
*/
abstract protected function doIncrWithInit( $key, $exptime, $step, $init, $flags );
@@ -500,6 +527,7 @@ abstract class MediumSpecificBagOStuff extends BagOStuff {
* @param int $timeout
* @param int $exptime
* @param string $rclass
+ *
* @return bool
*/
public function lock( $key, $timeout = 6, $exptime = 6, $rclass = '' ) {
@@ -536,6 +564,7 @@ abstract class MediumSpecificBagOStuff extends BagOStuff {
* @param string $key
* @param int $timeout Lock wait timeout; 0 for non-blocking [optional]
* @param int $exptime Lock time-to-live 1 day maximum [optional]
+ *
* @return float|null UNIX timestamp of acquisition; null on failure
*/
protected function doLock( $key, $timeout, $exptime ) {
@@ -578,6 +607,7 @@ abstract class MediumSpecificBagOStuff extends BagOStuff {
* Release an advisory lock on a key string
*
* @param string $key
+ *
* @return bool Success
*/
public function unlock( $key ) {
@@ -610,6 +640,7 @@ abstract class MediumSpecificBagOStuff extends BagOStuff {
* @see MediumSpecificBagOStuff::unlock()
*
* @param string $key
+ *
* @return bool Success
*/
protected function doUnlock( $key ) {
@@ -642,6 +673,7 @@ abstract class MediumSpecificBagOStuff extends BagOStuff {
/**
* @param string $key
+ *
* @return string
*/
protected function makeLockKey( $key ) {
@@ -659,8 +691,10 @@ abstract class MediumSpecificBagOStuff extends BagOStuff {
/**
* Get an associative array containing the item for each of the keys that have items.
+ *
* @param string[] $keys List of keys; can be a map of (unused => key) for convenience
* @param int $flags Bitfield; supports READ_LATEST [optional]
+ *
* @return mixed[] Map of (key => value) for existing keys; preserves the order of $keys
*/
public function getMulti( array $keys, $flags = 0 ) {
@@ -683,8 +717,10 @@ abstract class MediumSpecificBagOStuff extends BagOStuff {
/**
* Get an associative array containing the item for each of the keys that have items.
+ *
* @param string[] $keys List of keys
* @param int $flags Bitfield; supports READ_LATEST [optional]
+ *
* @return array Map of (key => value) for existing keys; preserves the order of $keys
*/
protected function doGetMulti( array $keys, $flags = 0 ) {
@@ -707,6 +743,7 @@ abstract class MediumSpecificBagOStuff extends BagOStuff {
* @param mixed[] $valueByKey Map of (key => value)
* @param int $exptime Either an interval in seconds or a unix timestamp for expiry
* @param int $flags Bitfield of BagOStuff::WRITE_* constants (since 1.33)
+ *
* @return bool Success
* @since 1.24
*/
@@ -722,6 +759,7 @@ abstract class MediumSpecificBagOStuff extends BagOStuff {
* @param mixed[] $data Map of (key => value)
* @param int $exptime Either an interval in seconds or a unix timestamp for expiry
* @param int $flags Bitfield of BagOStuff::WRITE_* constants
+ *
* @return bool Success
*/
protected function doSetMulti( array $data, $exptime = 0, $flags = 0 ) {
@@ -740,6 +778,7 @@ abstract class MediumSpecificBagOStuff extends BagOStuff {
*
* @param string[] $keys List of keys
* @param int $flags Bitfield of BagOStuff::WRITE_* constants
+ *
* @return bool Success
* @since 1.33
*/
@@ -754,6 +793,7 @@ abstract class MediumSpecificBagOStuff extends BagOStuff {
/**
* @param string[] $keys List of keys
* @param int $flags Bitfield of BagOStuff::WRITE_* constants
+ *
* @return bool Success
*/
protected function doDeleteMulti( array $keys, $flags = 0 ) {
@@ -761,6 +801,7 @@ abstract class MediumSpecificBagOStuff extends BagOStuff {
foreach ( $keys as $key ) {
$res = $this->doDelete( $key, $flags ) && $res;
}
+
return $res;
}
@@ -770,6 +811,7 @@ abstract class MediumSpecificBagOStuff extends BagOStuff {
* @param string[] $keys List of keys
* @param int $exptime TTL or UNIX timestamp
* @param int $flags Bitfield of BagOStuff::WRITE_* constants (since 1.33)
+ *
* @return bool Success
*
* @since 1.34
@@ -782,6 +824,7 @@ abstract class MediumSpecificBagOStuff extends BagOStuff {
* @param string[] $keys List of keys
* @param int $exptime TTL or UNIX timestamp
* @param int $flags Bitfield of BagOStuff::WRITE_* constants
+ *
* @return bool Success
*/
protected function doChangeTTLMulti( array $keys, $exptime, $flags = 0 ) {
@@ -798,6 +841,7 @@ abstract class MediumSpecificBagOStuff extends BagOStuff {
*
* @param string $key
* @param mixed $mainValue
+ *
* @return string|null|bool The combined string, false if missing, null on error
*/
final protected function resolveSegments( $key, $mainValue ) {
@@ -837,6 +881,7 @@ abstract class MediumSpecificBagOStuff extends BagOStuff {
*
* @param mixed $value
* @param int $flags
+ *
* @return bool
*/
private function useSegmentationWrapper( $value, $flags ) {
@@ -872,6 +917,7 @@ abstract class MediumSpecificBagOStuff extends BagOStuff {
* @param int $exptime
* @param int $flags
* @param mixed|null &$ok Whether the entry is usable (e.g. no missing segments) [returned]
+ *
* @return mixed The entry (inline value, wrapped inline value, or wrapped segment list)
* @since 1.34
*/
@@ -912,6 +958,7 @@ abstract class MediumSpecificBagOStuff extends BagOStuff {
/**
* @param int|float $exptime
+ *
* @return bool Whether the expiry is non-infinite, and, negative or not a UNIX timestamp
* @since 1.34
*/
@@ -929,6 +976,7 @@ abstract class MediumSpecificBagOStuff extends BagOStuff {
* - positive (>= 10 years): absolute UNIX timestamp; return this value
*
* @param int $exptime
+ *
* @return int Expiration timestamp or TTL_INDEFINITE for indefinite
* @since 1.34
*/
@@ -953,6 +1001,7 @@ abstract class MediumSpecificBagOStuff extends BagOStuff {
* - positive (>= 10 years): absolute UNIX timestamp; return offset to current time
*
* @param int $exptime
+ *
* @return int Relative TTL or TTL_INDEFINITE for indefinite
* @since 1.34
*/
@@ -970,6 +1019,7 @@ abstract class MediumSpecificBagOStuff extends BagOStuff {
* Check if a value is an integer
*
* @param mixed $value
+ *
* @return bool
*/
final protected function isInteger( $value ) {
@@ -993,6 +1043,7 @@ abstract class MediumSpecificBagOStuff extends BagOStuff {
*/
public function getSegmentationSize() {
wfDeprecated( __METHOD__, '1.43' );
+
return $this->segmentationSize;
}
@@ -1001,6 +1052,7 @@ abstract class MediumSpecificBagOStuff extends BagOStuff {
*/
public function getSegmentedValueMaxSize() {
wfDeprecated( __METHOD__, '1.43' );
+
return $this->segmentedValueMaxSize;
}
@@ -1009,6 +1061,7 @@ abstract class MediumSpecificBagOStuff extends BagOStuff {
*
* @param mixed $value
* @param string $key
+ *
* @return string|int String/integer representation of value
* @since 1.35
*/
@@ -1063,8 +1116,8 @@ abstract class MediumSpecificBagOStuff extends BagOStuff {
if ( is_object( $entry ) ) {
// Note that Closure instances count as objects
if (
- !( $entry instanceof stdClass ) &&
- !( $entry instanceof JsonSerializable )
+ !( $entry instanceof \stdClass ) &&
+ !( $entry instanceof \JsonSerializable )
) {
$this->logger->warning(
"{class} value for '{cachekey}' at '$index'; serialization is suspect.",
@@ -1079,6 +1132,7 @@ abstract class MediumSpecificBagOStuff extends BagOStuff {
/**
* @param mixed $value
+ *
* @return string|int|false String/integer representation
* @note Special handling is usually needed for integers so incr()/decr() work
*/
@@ -1088,6 +1142,7 @@ abstract class MediumSpecificBagOStuff extends BagOStuff {
/**
* @param string|int|false $value
+ *
* @return mixed Original value or false on error
* @note Special handling is usually needed for integers so incr()/decr() work
*/
@@ -1104,6 +1159,7 @@ abstract class MediumSpecificBagOStuff extends BagOStuff {
/**
* @param string $key Key generated by BagOStuff::makeKeyInternal
+ *
* @return string A stats prefix to describe this class of key (e.g. "objectcache.file")
*/
private function determinekeyGroupForStats( $key ): string {
@@ -1192,3 +1248,6 @@ abstract class MediumSpecificBagOStuff extends BagOStuff {
}
}
}
+
+/** @deprecated class alias since 1.43 */
+class_alias( MediumSpecificBagOStuff::class, 'MediumSpecificBagOStuff' );
diff --git a/includes/libs/objectcache/MemcachedBagOStuff.php b/includes/libs/objectcache/MemcachedBagOStuff.php
index 5c208bf7d02e..aab6d412dd98 100644
--- a/includes/libs/objectcache/MemcachedBagOStuff.php
+++ b/includes/libs/objectcache/MemcachedBagOStuff.php
@@ -21,6 +21,12 @@
* @ingroup Cache
*/
+namespace Wikimedia\ObjectCache;
+
+use Exception;
+use InvalidArgumentException;
+use RuntimeException;
+
/**
* Base class for memcached clients.
*
@@ -54,8 +60,10 @@ abstract class MemcachedBagOStuff extends MediumSpecificBagOStuff {
*
* @since 1.27
* @see BagOStuff::makeKeyInternal
+ *
* @param string $keyspace
* @param string[]|int[] $components
+ *
* @return string
*/
protected function makeKeyInternal( $keyspace, $components ) {
@@ -101,6 +109,7 @@ abstract class MemcachedBagOStuff extends MediumSpecificBagOStuff {
* characters above the ASCII range.)
*
* @param string $key
+ *
* @return string
* @throws Exception
*/
@@ -114,6 +123,7 @@ abstract class MemcachedBagOStuff extends MediumSpecificBagOStuff {
/**
* @param string $key
+ *
* @return string
*/
protected function validateKeyAndPrependRoute( $key ) {
@@ -132,6 +142,7 @@ abstract class MemcachedBagOStuff extends MediumSpecificBagOStuff {
/**
* @param string $key
+ *
* @return string
*/
protected function stripRouteFromKey( $key ) {
@@ -148,6 +159,7 @@ abstract class MemcachedBagOStuff extends MediumSpecificBagOStuff {
/**
* @param int|float $exptime
+ *
* @return int
*/
protected function fixExpiry( $exptime ) {
@@ -181,6 +193,7 @@ abstract class MemcachedBagOStuff extends MediumSpecificBagOStuff {
* @param int $exptime
* @param int $step
* @param int $init
+ *
* @return bool True on success, false on failure
*/
abstract protected function doIncrWithInitAsync( $key, $exptime, $step, $init );
@@ -190,7 +203,11 @@ abstract class MemcachedBagOStuff extends MediumSpecificBagOStuff {
* @param int $exptime
* @param int $step
* @param int $init
+ *
* @return int|bool New value or false on failure
*/
abstract protected function doIncrWithInitSync( $key, $exptime, $step, $init );
}
+
+/** @deprecated class alias since 1.43 */
+class_alias( MemcachedBagOStuff::class, 'MemcachedBagOStuff' );
diff --git a/includes/libs/objectcache/MemcachedPeclBagOStuff.php b/includes/libs/objectcache/MemcachedPeclBagOStuff.php
index 079b5e3b32fa..75159f51c946 100644
--- a/includes/libs/objectcache/MemcachedPeclBagOStuff.php
+++ b/includes/libs/objectcache/MemcachedPeclBagOStuff.php
@@ -21,6 +21,11 @@
* @ingroup Cache
*/
+namespace Wikimedia\ObjectCache;
+
+use Memcached;
+use RuntimeException;
+use UnexpectedValueException;
use Wikimedia\ScopedCallback;
/**
@@ -46,6 +51,7 @@ class MemcachedPeclBagOStuff extends MemcachedBagOStuff {
* option igbinary.compact_strings is off.
* - use_binary_protocol Whether to enable the binary protocol (default is ASCII)
* - allow_tcp_nagle_delay Whether to permit Nagle's algorithm for reducing packet count
+ *
* @param array $params
*/
public function __construct( $params ) {
@@ -86,6 +92,7 @@ class MemcachedPeclBagOStuff extends MemcachedBagOStuff {
*
* @param Memcached $client
* @param array $params
+ *
* @throws RuntimeException
*/
private function initializeClient( Memcached $client, array $params ) {
@@ -160,6 +167,7 @@ class MemcachedPeclBagOStuff extends MemcachedBagOStuff {
* This makes writes much faster.
*
* @param bool|int $flags
+ *
* @return ScopedCallback|null
*/
private function noReplyScope( $flags ) {
@@ -168,6 +176,7 @@ class MemcachedPeclBagOStuff extends MemcachedBagOStuff {
}
$client = $this->client;
$client->setOption( Memcached::OPT_NOREPLY, true );
+
return new ScopedCallback( static function () use ( $client ) {
$client->setOption( Memcached::OPT_NOREPLY, false );
} );
@@ -265,6 +274,7 @@ class MemcachedPeclBagOStuff extends MemcachedBagOStuff {
$this->checkResult( $key, $this->client->increment( $routeKey, $step ) );
ScopedCallback::consume( $scope );
$lastError = $this->getLastError( $watchPoint );
+
return !$lastError;
}
@@ -297,6 +307,7 @@ class MemcachedPeclBagOStuff extends MemcachedBagOStuff {
*
* @param string|false $key The key used by the caller, or false if there wasn't one.
* @param mixed $result The return value
+ *
* @return mixed
*/
protected function checkResult( $key, $result ) {
@@ -343,6 +354,7 @@ class MemcachedPeclBagOStuff extends MemcachedBagOStuff {
$this->logger->error( $msg, $logCtx );
$this->setLastError( $statusByCode[$code] ?? self::ERR_UNEXPECTED );
}
+
return $result;
}
@@ -369,6 +381,7 @@ class MemcachedPeclBagOStuff extends MemcachedBagOStuff {
}
$res = $this->checkResult( false, $res );
+
return $res !== false ? $res : [];
}
@@ -387,6 +400,7 @@ class MemcachedPeclBagOStuff extends MemcachedBagOStuff {
// phpcs:ignore Generic.PHP.NoSilencedErrors.Discouraged
$result = @$this->client->setMulti( $dataByRouteKey, $exptime );
ScopedCallback::consume( $noReplyScope );
+
return $this->checkResult( false, $result );
}
@@ -454,3 +468,6 @@ class MemcachedPeclBagOStuff extends MemcachedBagOStuff {
throw new UnexpectedValueException( __METHOD__ . ": got serializer '$serializer'." );
}
}
+
+/** @deprecated class alias since 1.43 */
+class_alias( MemcachedPeclBagOStuff::class, 'MemcachedPeclBagOStuff' );
diff --git a/includes/libs/objectcache/MemcachedPhpBagOStuff.php b/includes/libs/objectcache/MemcachedPhpBagOStuff.php
index 42c929e0ffe0..6b70dac27de6 100644
--- a/includes/libs/objectcache/MemcachedPhpBagOStuff.php
+++ b/includes/libs/objectcache/MemcachedPhpBagOStuff.php
@@ -21,6 +21,10 @@
* @ingroup Cache
*/
+namespace Wikimedia\ObjectCache;
+
+use MemcachedClient;
+
/**
* A wrapper class for the pure-PHP memcached client, exposing a BagOStuff interface.
*
@@ -62,10 +66,8 @@ class MemcachedPhpBagOStuff extends MemcachedBagOStuff {
$routeKey = $this->validateKeyAndPrependRoute( $key );
// T257003: only require "gets" (instead of "get") when a CAS token is needed
- $res = $getToken
- // @phan-suppress-next-line PhanTypeMismatchArgument False positive
- ? $this->client->get( $routeKey, $casToken )
- : $this->client->get( $routeKey );
+ $res = $getToken // @phan-suppress-next-line PhanTypeMismatchArgument False positive
+ ? $this->client->get( $routeKey, $casToken ) : $this->client->get( $routeKey );
if ( $this->client->_last_cmd_status !== self::ERR_NONE ) {
$this->setLastError( $this->client->_last_cmd_status );
@@ -127,6 +129,7 @@ class MemcachedPhpBagOStuff extends MemcachedBagOStuff {
$watchPoint = $this->watchErrors();
$this->client->add( $routeKey, $init - $step, $this->fixExpiry( $exptime ) );
$this->client->incr( $routeKey, $step );
+
return !$this->getLastError( $watchPoint );
}
@@ -188,3 +191,6 @@ class MemcachedPhpBagOStuff extends MemcachedBagOStuff {
return $this->isInteger( $value ) ? (int)$value : $this->client->unserialize( $value );
}
}
+
+/** @deprecated class alias since 1.43 */
+class_alias( MemcachedPhpBagOStuff::class, 'MemcachedPhpBagOStuff' );
diff --git a/includes/libs/objectcache/MultiWriteBagOStuff.php b/includes/libs/objectcache/MultiWriteBagOStuff.php
index 71deb15cfa48..e6042c05bcd3 100644
--- a/includes/libs/objectcache/MultiWriteBagOStuff.php
+++ b/includes/libs/objectcache/MultiWriteBagOStuff.php
@@ -20,6 +20,10 @@
* @file
* @ingroup Cache
*/
+
+namespace Wikimedia\ObjectCache;
+
+use InvalidArgumentException;
use Wikimedia\ObjectFactory\ObjectFactory;
/**
@@ -47,6 +51,7 @@ class MultiWriteBagOStuff extends BagOStuff {
/**
* @stable to call
+ *
* @param array $params
* - caches: A numbered array of either ObjectFactory::getObjectFromSpec
* arrays yielding BagOStuff objects or direct BagOStuff objects.
@@ -63,6 +68,7 @@ class MultiWriteBagOStuff extends BagOStuff {
* safe to use for modules when cached values: are immutable,
* invalidation uses logical TTLs, invalidation uses etag/timestamp
* validation against the DB, or merge() is used to handle races.
+ *
* @phan-param array{caches:array<int,array|BagOStuff>,replication:string} $params
* @throws InvalidArgumentException
*/
@@ -321,6 +327,7 @@ class MultiWriteBagOStuff extends BagOStuff {
* @param int $arg0Sig BagOStuff::A0_* constant describing argument 0
* @param int $rvSig BagOStuff::RV_* constant describing the return value
* @param array $args Method arguments
+ *
* @return mixed The result of calling the given method
*/
private function callKeyMethodOnTierCache( $index, $method, $arg0Sig, $rvSig, array $args ) {
@@ -335,6 +342,7 @@ class MultiWriteBagOStuff extends BagOStuff {
* @param int $arg0Sig BagOStuff::ARG0_* constant describing argument 0
* @param int $resSig BagOStuff::RES_* constant describing the return value
* @param array $args Method arguments
+ *
* @return mixed First synchronous result or false if any failed; null if all asynchronous
*/
private function callKeyWriteMethodOnTierCaches(
@@ -377,3 +385,6 @@ class MultiWriteBagOStuff extends BagOStuff {
return $res;
}
}
+
+/** @deprecated class alias since 1.43 */
+class_alias( MultiWriteBagOStuff::class, 'MultiWriteBagOStuff' );
diff --git a/includes/libs/objectcache/RESTBagOStuff.php b/includes/libs/objectcache/RESTBagOStuff.php
index 23c1c536ac3a..f8efad536226 100644
--- a/includes/libs/objectcache/RESTBagOStuff.php
+++ b/includes/libs/objectcache/RESTBagOStuff.php
@@ -1,5 +1,9 @@
<?php
+namespace Wikimedia\ObjectCache;
+
+use InvalidArgumentException;
+use LogicException;
use Psr\Log\LoggerInterface;
use Wikimedia\Http\MultiHttpClient;
@@ -103,24 +107,28 @@ class RESTBagOStuff extends MediumSpecificBagOStuff {
/**
* REST URL to use for storage.
+ *
* @var string
*/
private $url;
/**
* HTTP parameters: readHeaders, writeHeaders, deleteHeaders, writeMethod.
+ *
* @var array
*/
private $httpParams;
/**
* Optional serialization type to use. Allowed values: "PHP", "JSON".
+ *
* @var string
*/
private $serializationType;
/**
* Optional HMAC Key for protecting the serialized blob. If omitted no protection is done
+ *
* @var string
*/
private $hmacKey;
@@ -272,6 +280,7 @@ class RESTBagOStuff extends MediumSpecificBagOStuff {
* Processes the response body.
*
* @param string $body request body to process
+ *
* @return mixed|bool the processed body, or false on error
*/
private function decodeBody( $body ) {
@@ -306,6 +315,7 @@ class RESTBagOStuff extends MediumSpecificBagOStuff {
* Prepares the request body (the "value" portion of our key/value store) for transmission.
*
* @param string $body request body to prepare
+ *
* @return string the prepared body
* @throws LogicException
*/
@@ -375,3 +385,6 @@ class RESTBagOStuff extends MediumSpecificBagOStuff {
$this->setLastError( $rcode === 0 ? self::ERR_UNREACHABLE : self::ERR_UNEXPECTED );
}
}
+
+/** @deprecated class alias since 1.43 */
+class_alias( RESTBagOStuff::class, 'RESTBagOStuff' );
diff --git a/includes/libs/objectcache/RedisBagOStuff.php b/includes/libs/objectcache/RedisBagOStuff.php
index 622d866b4052..6faa2d793a05 100644
--- a/includes/libs/objectcache/RedisBagOStuff.php
+++ b/includes/libs/objectcache/RedisBagOStuff.php
@@ -20,6 +20,15 @@
* @file
*/
+namespace Wikimedia\ObjectCache;
+
+use ArrayUtils;
+use Exception;
+use Redis;
+use RedisConnectionPool;
+use RedisConnRef;
+use RedisException;
+
/**
* Redis-based caching module for redis server >= 2.6.12 and phpredis >= 2.2.4
*
@@ -66,6 +75,7 @@ class RedisBagOStuff extends MediumSpecificBagOStuff {
* consistent hashing algorithm). True by default. This has the
* potential to create consistency issues if a server is slow enough to
* flap, for example if it is in swap death.
+ *
* @param array $params
*/
public function __construct( $params ) {
@@ -440,6 +450,7 @@ LUA;
/**
* @param string[] $keys
+ *
* @return array ((server => redis handle wrapper), (server => key batch), success)
* @phan-return array{0:array<string,string[]>,1:array<string,RedisConnRef|Redis>,2:bool}
*/
@@ -504,6 +515,7 @@ LUA;
/**
* @param string $key
+ *
* @return RedisConnRef|Redis|null Redis handle wrapper for the key or null on failure
*/
protected function getConnection( $key ) {
@@ -527,6 +539,7 @@ LUA;
/**
* Log a fatal error
+ *
* @param string $msg
*/
protected function logError( $msg ) {
@@ -538,6 +551,7 @@ LUA;
* and protocol errors. Sometimes it also closes the connection, sometimes
* not. The safest response for us is to explicitly destroy the connection
* object and let it be reopened during the next request.
+ *
* @param RedisConnRef $conn
* @param RedisException $e
*/
@@ -548,6 +562,7 @@ LUA;
/**
* Send information about a single request to the debug log
+ *
* @param string $op
* @param string $keys
* @param string $server
@@ -557,3 +572,6 @@ LUA;
$this->debug( "$op($keys) on $server: " . ( $e ? "failure" : "success" ) );
}
}
+
+/** @deprecated class alias since 1.43 */
+class_alias( RedisBagOStuff::class, 'RedisBagOStuff' );
diff --git a/includes/libs/objectcache/ReplicatedBagOStuff.php b/includes/libs/objectcache/ReplicatedBagOStuff.php
index ad4a9e051de5..72033fe5be64 100644
--- a/includes/libs/objectcache/ReplicatedBagOStuff.php
+++ b/includes/libs/objectcache/ReplicatedBagOStuff.php
@@ -18,6 +18,8 @@
* @file
* @ingroup Cache
*/
+
+use Wikimedia\ObjectCache\BagOStuff;
use Wikimedia\ObjectFactory\ObjectFactory;
/**
diff --git a/includes/libs/objectcache/WinCacheBagOStuff.php b/includes/libs/objectcache/WinCacheBagOStuff.php
index f545d9c0521e..2e67bfbf0ca6 100644
--- a/includes/libs/objectcache/WinCacheBagOStuff.php
+++ b/includes/libs/objectcache/WinCacheBagOStuff.php
@@ -21,6 +21,8 @@
* @ingroup Cache
*/
+namespace Wikimedia\ObjectCache;
+
/**
* Wrapper for WinCache object caching functions; identical interface
* to the APC wrapper
@@ -168,3 +170,6 @@ class WinCacheBagOStuff extends MediumSpecificBagOStuff {
return $newValue;
}
}
+
+/** @deprecated class alias since 1.43 */
+class_alias( WinCacheBagOStuff::class, 'WinCacheBagOStuff' );
diff --git a/includes/libs/objectcache/wancache/WANObjectCache.php b/includes/libs/objectcache/wancache/WANObjectCache.php
index 57244d1ec05b..87e43782e5c5 100644
--- a/includes/libs/objectcache/wancache/WANObjectCache.php
+++ b/includes/libs/objectcache/wancache/WANObjectCache.php
@@ -25,6 +25,9 @@ use Psr\Log\LoggerInterface;
use Psr\Log\NullLogger;
use Wikimedia\LightweightObjectStore\ExpirationAwareness;
use Wikimedia\LightweightObjectStore\StorageAwareness;
+use Wikimedia\ObjectCache\BagOStuff;
+use Wikimedia\ObjectCache\EmptyBagOStuff;
+use Wikimedia\ObjectCache\IStoreKeyEncoder;
/**
* Multi-datacenter aware caching interface