summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--tests/phpunit/includes/object-cache.php1383
1 files changed, 703 insertions, 680 deletions
diff --git a/tests/phpunit/includes/object-cache.php b/tests/phpunit/includes/object-cache.php
index c97ccb8d64..c747a7a824 100644
--- a/tests/phpunit/includes/object-cache.php
+++ b/tests/phpunit/includes/object-cache.php
@@ -5,13 +5,13 @@
* If the specified key already exists, the value is not stored and the function
* returns false.
*
- * @link http://www.php.net/manual/en/memcached.add.php
+ * @link https://www.php.net/manual/en/memcached.add.php
*
- * @param string $key The key under which to store the value.
- * @param mixed $value The value to store.
- * @param string $group The group value appended to the $key.
- * @param int $expiration The expiration time, defaults to 0.
- * @return bool Returns TRUE on success or FALSE on failure.
+ * @param string $key The key under which to store the value.
+ * @param mixed $value The value to store.
+ * @param string $group The group value appended to the $key.
+ * @param int $expiration The expiration time, defaults to 0.
+ * @return bool True on success, false on failure.
*/
function wp_cache_add( $key, $value, $group = '', $expiration = 0 ) {
global $wp_object_cache;
@@ -26,14 +26,14 @@ function wp_cache_add( $key, $value, $group = '', $expiration = 0 ) {
* _cache object as part of the runtime cache. It will add it to an array for the
* specified server_key.
*
- * @link http://www.php.net/manual/en/memcached.addbykey.php
+ * @link https://www.php.net/manual/en/memcached.addbykey.php
*
- * @param string $server_key The key identifying the server to store the value on.
- * @param string $key The key under which to store the value.
- * @param mixed $value The value to store.
- * @param string $group The group value appended to the $key.
- * @param int $expiration The expiration time, defaults to 0.
- * @return bool Returns TRUE on success or FALSE on failure.
+ * @param string $server_key The key identifying the server to store the value on.
+ * @param string $key The key under which to store the value.
+ * @param mixed $value The value to store.
+ * @param string $group The group value appended to the $key.
+ * @param int $expiration The expiration time, defaults to 0.
+ * @return bool True on success, false on failure.
*/
function wp_cache_add_by_key( $server_key, $key, $value, $group = '', $expiration = 0 ) {
global $wp_object_cache;
@@ -41,14 +41,15 @@ function wp_cache_add_by_key( $server_key, $key, $value, $group = '', $expiratio
}
/**
- * Add a single server to the list of Memcached servers.
+ * Adds a single server to the list of Memcached servers.
*
- * @link http://www.php.net/manual/en/memcached.addserver.php
+ * @link https://www.php.net/manual/en/memcached.addserver.php
*
- * @param string $host The hostname of the memcache server.
- * @param int $port The port on which memcache is running.
- * @param int $weight The weight of the server relative to the total weight of all the servers in the pool.
- * @return bool Returns TRUE on success or FALSE on failure.
+ * @param string $host The hostname of the memcache server.
+ * @param int $port The port on which memcache is running.
+ * @param int $weight The weight of the server relative to the total weight
+ * of all the servers in the pool.
+ * @return bool True on success, false on failure.
*/
function wp_cache_add_server( $host, $port, $weight = 0 ) {
global $wp_object_cache;
@@ -61,10 +62,10 @@ function wp_cache_add_server( $host, $port, $weight = 0 ) {
* Each individual server in the array must include a domain and port, with an optional
* weight value: $servers = array( array( '127.0.0.1', 11211, 0 ) );
*
- * @link http://www.php.net/manual/en/memcached.addservers.php
+ * @link https://www.php.net/manual/en/memcached.addservers.php
*
- * @param array $servers Array of server to register.
- * @return bool True on success; false on failure.
+ * @param array $servers Array of server to register.
+ * @return bool True on success, false on failure.
*/
function wp_cache_add_servers( $servers ) {
global $wp_object_cache;
@@ -72,21 +73,21 @@ function wp_cache_add_servers( $servers ) {
}
/**
- * Append data to an existing item.
+ * Appends data to an existing item.
*
- * This method should throw an error if it is used with compressed data. This
- * is an expected behavior. Memcached casts the value to be appended to the initial value to the
- * type of the initial value. Be careful as this leads to unexpected behavior at times. Due to
- * how memcached treats types, the behavior has been mimicked in the internal cache to produce
- * similar results and improve consistency. It is recommend that appends only occur with data of
+ * This method should throw an error if it is used with compressed data.
+ * This is an expected behavior. Memcached casts the value to be appended to the initial value
+ * to the type of the initial value. Be careful as this leads to unexpected behavior at times.
+ * Due to how memcached treats types, the behavior has been mimicked in the internal cache to produce
+ * similar results and improve consistency. It is recommended that appends only occur with data of
* the same type.
*
- * @link http://www.php.net/manual/en/memcached.append.php
+ * @link https://www.php.net/manual/en/memcached.append.php
*
- * @param string $key The key under which to store the value.
- * @param mixed $value Must be string as appending mixed values is not well-defined
- * @param string $group The group value appended to the $key.
- * @return bool Returns TRUE on success or FALSE on failure.
+ * @param string $key The key under which to store the value.
+ * @param mixed $value Must be string as appending mixed values is not well-defined.
+ * @param string $group The group value appended to the $key.
+ * @return bool True on success, false on failure.
*/
function wp_cache_append( $key, $value, $group = '' ) {
global $wp_object_cache;
@@ -94,22 +95,22 @@ function wp_cache_append( $key, $value, $group = '' ) {
}
/**
- * Append data to an existing item by server key.
+ * Appends data to an existing item by server key.
*
- * This method should throw an error if it is used with compressed data. This
- * is an expected behavior. Memcached casts the value to be appended to the initial value to the
- * type of the initial value. Be careful as this leads to unexpected behavior at times. Due to
- * how memcached treats types, the behavior has been mimicked in the internal cache to produce
- * similar results and improve consistency. It is recommend that appends only occur with data of
+ * This method should throw an error if it is used with compressed data.
+ * This is an expected behavior. Memcached casts the value to be appended to the initial value
+ * to the type of the initial value. Be careful as this leads to unexpected behavior at times.
+ * Due to how memcached treats types, the behavior has been mimicked in the internal cache to produce
+ * similar results and improve consistency. It is recommended that appends only occur with data of
* the same type.
*
- * @link http://www.php.net/manual/en/memcached.appendbykey.php
+ * @link https://www.php.net/manual/en/memcached.appendbykey.php
*
- * @param string $server_key The key identifying the server to store the value on.
- * @param string $key The key under which to store the value.
- * @param mixed $value Must be string as appending mixed values is not well-defined
- * @param string $group The group value appended to the $key.
- * @return bool Returns TRUE on success or FALSE on failure.
+ * @param string $server_key The key identifying the server to store the value on.
+ * @param string $key The key under which to store the value.
+ * @param mixed $value Must be string as appending mixed values is not well-defined.
+ * @param string $group The group value appended to the $key.
+ * @return bool True on success, false on failure.
*/
function wp_cache_append_by_key( $server_key, $key, $value, $group = '' ) {
global $wp_object_cache;
@@ -119,17 +120,17 @@ function wp_cache_append_by_key( $server_key, $key, $value, $group = '' ) {
/**
* Performs a "check and set" to store data.
*
- * The set will be successful only if the no other request has updated the value since it was fetched by
- * this request.
+ * The set will be successful only if the no other request has updated the value
+ * since it was fetched by this request.
*
- * @link http://www.php.net/manual/en/memcached.cas.php
+ * @link https://www.php.net/manual/en/memcached.cas.php
*
- * @param float $cas_token Unique value associated with the existing item. Generated by memcached.
- * @param string $key The key under which to store the value.
- * @param mixed $value The value to store.
- * @param string $group The group value appended to the $key.
- * @param int $expiration The expiration time, defaults to 0.
- * @return bool Returns TRUE on success or FALSE on failure.
+ * @param float $cas_token Unique value associated with the existing item. Generated by memcached.
+ * @param string $key The key under which to store the value.
+ * @param mixed $value The value to store.
+ * @param string $group The group value appended to the $key.
+ * @param int $expiration The expiration time, defaults to 0.
+ * @return bool True on success, false on failure.
*/
function wp_cache_cas( $cas_token, $key, $value, $group = '', $expiration = 0 ) {
global $wp_object_cache;
@@ -139,18 +140,18 @@ function wp_cache_cas( $cas_token, $key, $value, $group = '', $expiration = 0 )
/**
* Performs a "check and set" to store data with a server key.
*
- * The set will be successful only if the no other request has updated the value since it was fetched by
- * this request.
+ * The set will be successful only if the no other request has updated the value
+ * since it was fetched by this request.
*
- * @link http://www.php.net/manual/en/memcached.casbykey.php
+ * @link https://www.php.net/manual/en/memcached.casbykey.php
*
- * @param string $server_key The key identifying the server to store the value on.
- * @param float $cas_token Unique value associated with the existing item. Generated by memcached.
- * @param string $key The key under which to store the value.
- * @param mixed $value The value to store.
- * @param string $group The group value appended to the $key.
- * @param int $expiration The expiration time, defaults to 0.
- * @return bool Returns TRUE on success or FALSE on failure.
+ * @param string $server_key The key identifying the server to store the value on.
+ * @param float $cas_token Unique value associated with the existing item. Generated by memcached.
+ * @param string $key The key under which to store the value.
+ * @param mixed $value The value to store.
+ * @param string $group The group value appended to the $key.
+ * @param int $expiration The expiration time, defaults to 0.
+ * @return bool True on success, false on failure.
*/
function wp_cache_cas_by_key( $cas_token, $server_key, $key, $value, $group = '', $expiration = 0 ) {
global $wp_object_cache;
@@ -160,28 +161,28 @@ function wp_cache_cas_by_key( $cas_token, $server_key, $key, $value, $group = ''
/**
* Closes the cache.
*
- * This function has ceased to do anything since WordPress 2.5. The
- * functionality was removed along with the rest of the persistent cache. This
- * does not mean that plugins can't implement this function when they need to
- * make sure that the cache is cleaned up after WordPress no longer needs it.
+ * This function has ceased to do anything since WordPress 2.5.
+ * The functionality was removed along with the rest of the persistent cache.
+ * This does not mean that plugins can't implement this function when they need
+ * to make sure that the cache is cleaned up after WordPress no longer needs it.
*
* @since 2.0.0
*
- * @return bool Always returns True
+ * @return bool Always returns true.
*/
function wp_cache_close() {
return true;
}
/**
- * Decrement a numeric item's value.
+ * Decrements a numeric item's value.
*
- * @link http://www.php.net/manual/en/memcached.decrement.php
+ * @link https://www.php.net/manual/en/memcached.decrement.php
*
- * @param string $key The key under which to store the value.
- * @param int $offset The amount by which to decrement the item's value.
- * @param string $group The group value appended to the $key.
- * @return int|bool Returns item's new value on success or FALSE on failure.
+ * @param string $key The key under which to store the value.
+ * @param int $offset The amount by which to decrement the item's value.
+ * @param string $group The group value appended to the $key.
+ * @return int|bool Item's new value on success, false on failure.
*/
function wp_cache_decrement( $key, $offset = 1, $group = '' ) {
global $wp_object_cache;
@@ -189,36 +190,36 @@ function wp_cache_decrement( $key, $offset = 1, $group = '' ) {
}
/**
- * Decrement a numeric item's value.
+ * Decrements a numeric item's value.
*
- * Same as wp_cache_decrement. Original WordPress caching backends use wp_cache_decr. I
- * want both spellings to work.
+ * This is the same as wp_cache_decrement(), but kept for backward compatibility.
+ * The original WordPress caching backends use wp_cache_decr().
*
- * @link http://www.php.net/manual/en/memcached.decrement.php
+ * @link https://www.php.net/manual/en/memcached.decrement.php
*
- * @param string $key The key under which to store the value.
- * @param int $offset The amount by which to decrement the item's value.
- * @param string $group The group value appended to the $key.
- * @return int|bool Returns item's new value on success or FALSE on failure.
+ * @param string $key The key under which to store the value.
+ * @param int $offset The amount by which to decrement the item's value.
+ * @param string $group The group value appended to the $key.
+ * @return int|bool Item's new value on success, false on failure.
*/
function wp_cache_decr( $key, $offset = 1, $group = '' ) {
return wp_cache_decrement( $key, $offset, $group );
}
/**
- * Remove the item from the cache.
+ * Removes the item from the cache.
*
- * Remove an item from memcached with identified by $key after $time seconds. The
- * $time parameter allows an object to be queued for deletion without immediately
- * deleting. Between the time that it is queued and the time it's deleted, add,
- * replace, and get will fail, but set will succeed.
+ * Removes an item from memcached with identified by $key after $time seconds.
+ * The $time parameter allows an object to be queued for deletion without
+ * immediately deleting. Between the time that it is queued and the time it's deleted,
+ * add, replace, and get will fail, but set will succeed.
*
- * @link http://www.php.net/manual/en/memcached.delete.php
+ * @link https://www.php.net/manual/en/memcached.delete.php
*
- * @param string $key The key under which to store the value.
- * @param string $group The group value appended to the $key.
- * @param int $time The amount of time the server will wait to delete the item in seconds.
- * @return bool Returns TRUE on success or FALSE on failure.
+ * @param string $key The key under which to store the value.
+ * @param string $group The group value appended to the $key.
+ * @param int $time The amount of time the server will wait to delete the item in seconds.
+ * @return bool True on success, false on failure.
*/
function wp_cache_delete( $key, $group = '', $time = 0 ) {
global $wp_object_cache;
@@ -226,20 +227,20 @@ function wp_cache_delete( $key, $group = '', $time = 0 ) {
}
/**
- * Remove the item from the cache by server key.
+ * Removes the item from the cache by server key.
*
- * Remove an item from memcached with identified by $key after $time seconds. The
- * $time parameter allows an object to be queued for deletion without immediately
- * deleting. Between the time that it is queued and the time it's deleted, add,
- * replace, and get will fail, but set will succeed.
+ * Removes an item from memcached with identified by $key after $time seconds.
+ * The $time parameter allows an object to be queued for deletion without
+ * immediately deleting. Between the time that it is queued and the time it's deleted,
+ * add, replace, and get will fail, but set will succeed.
*
- * @link http://www.php.net/manual/en/memcached.deletebykey.php
+ * @link https://www.php.net/manual/en/memcached.deletebykey.php
*
- * @param string $server_key The key identifying the server to store the value on.
- * @param string $key The key under which to store the value.
- * @param string $group The group value appended to the $key.
- * @param int $time The amount of time the server will wait to delete the item in seconds.
- * @return bool Returns TRUE on success or FALSE on failure.
+ * @param string $server_key The key identifying the server to store the value on.
+ * @param string $key The key under which to store the value.
+ * @param string $group The group value appended to the $key.
+ * @param int $time The amount of time the server will wait to delete the item in seconds.
+ * @return bool True on success, false on failure.
*/
function wp_cache_delete_by_key( $server_key, $key, $group = '', $time = 0 ) {
global $wp_object_cache;
@@ -247,11 +248,11 @@ function wp_cache_delete_by_key( $server_key, $key, $group = '', $time = 0 ) {
}
/**
- * Fetch the next result.
+ * Fetches the next result.
*
- * @link http://www.php.net/manual/en/memcached.fetch.php
+ * @link https://www.php.net/manual/en/memcached.fetch.php
*
- * @return array|bool Returns the next result or FALSE otherwise.
+ * @return array|false The next result on success, false on failure.
*/
function wp_cache_fetch() {
global $wp_object_cache;
@@ -259,11 +260,11 @@ function wp_cache_fetch() {
}
/**
- * Fetch all remaining results from the last request.
+ * Fetches all remaining results from the last request.
*
- * @link http://www.php.net/manual/en/memcached.fetchall.php
+ * @link https://www.php.net/manual/en/memcached.fetchall.php
*
- * @return array|bool Returns the results or FALSE on failure.
+ * @return array|false The results on success, false on failure.
*/
function wp_cache_fetch_all() {
global $wp_object_cache;
@@ -271,12 +272,12 @@ function wp_cache_fetch_all() {
}
/**
- * Invalidate all items in the cache.
+ * Invalidates all items in the cache.
*
- * @link http://www.php.net/manual/en/memcached.flush.php
+ * @link https://www.php.net/manual/en/memcached.flush.php
*
- * @param int $delay Number of seconds to wait before invalidating the items.
- * @return bool Returns TRUE on success or FALSE on failure.
+ * @param int $delay Number of seconds to wait before invalidating the items.
+ * @return bool True on success, false on failure.
*/
function wp_cache_flush( $delay = 0 ) {
global $wp_object_cache;
@@ -284,24 +285,25 @@ function wp_cache_flush( $delay = 0 ) {
}
/**
- * Retrieve object from cache.
+ * Retrieves object from cache.
*
- * Gets an object from cache based on $key and $group. In order to fully support the $cache_cb and $cas_token
- * parameters, the runtime cache is ignored by this function if either of those values are set. If either of
- * those values are set, the request is made directly to the memcached server for proper handling of the
- * callback and/or token.
+ * Gets an object from cache based on $key and $group. In order to fully support
+ * the $cache_cb and $cas_token parameters, the runtime cache is ignored by this function
+ * if either of those values are set. In that case, the request is made directly
+ * to the memcached server for proper handling of the callback and/or token.
*
- * Note that the $deprecated and $found args are only here for compatibility with the native wp_cache_get function.
+ * Note that the $deprecated and $found args are only here for compatibility
+ * with the native wp_cache_get() function.
*
- * @link http://www.php.net/manual/en/memcached.get.php
+ * @link https://www.php.net/manual/en/memcached.get.php
*
- * @param string $key The key under which to store the value.
- * @param string $group The group value appended to the $key.
- * @param bool $force Whether or not to force a cache invalidation.
- * @param null|bool $found Variable passed by reference to determine if the value was found or not.
- * @param null|string $cache_cb Read-through caching callback.
- * @param null|float $cas_token The variable to store the CAS token in.
- * @return bool|mixed Cached object value.
+ * @param string $key The key under which to store the value.
+ * @param string $group The group value appended to the $key.
+ * @param bool $force Whether or not to force a cache invalidation.
+ * @param null|bool $found Variable passed by reference to determine if the value was found or not.
+ * @param null|string $cache_cb Read-through caching callback.
+ * @param null|float $cas_token The variable to store the CAS token in.
+ * @return bool|mixed Cached object value.
*/
function wp_cache_get( $key, $group = '', $force = false, &$found = null, $cache_cb = null, &$cas_token = null ) {
global $wp_object_cache;
@@ -314,23 +316,23 @@ function wp_cache_get( $key, $group = '', $force = false, &$found = null, $cache
}
/**
- * Retrieve object from cache from specified server.
- *
- * Gets an object from cache based on $key, $group and $server_key. In order to fully support the $cache_cb and $cas_token
- * parameters, the runtime cache is ignored by this function if either of those values are set. If either of
- * those values are set, the request is made directly to the memcached server for proper handling of the
- * callback and/or token.
- *
- * @link http://www.php.net/manual/en/memcached.getbykey.php
- *
- * @param string $server_key The key identifying the server to store the value on.
- * @param string $key The key under which to store the value.
- * @param string $group The group value appended to the $key.
- * @param bool $force Whether or not to force a cache invalidation.
- * @param null|bool $found Variable passed by reference to determine if the value was found or not.
- * @param null|string $cache_cb Read-through caching callback.
- * @param null|float $cas_token The variable to store the CAS token in.
- * @return bool|mixed Cached object value.
+ * Retrieves object from cache from specified server.
+ *
+ * Gets an object from cache based on $key, $group, and $server_key. In order to fully support
+ * the $cache_cb and $cas_token parameters, the runtime cache is ignored by this function
+ * if either of those values are set. In that case, the request is made directly
+ * to the memcached server for proper handling of the callback and/or token.
+ *
+ * @link https://www.php.net/manual/en/memcached.getbykey.php
+ *
+ * @param string $server_key The key identifying the server to store the value on.
+ * @param string $key The key under which to store the value.
+ * @param string $group The group value appended to the $key.
+ * @param bool $force Whether or not to force a cache invalidation.
+ * @param null|bool $found Variable passed by reference to determine if the value was found or not.
+ * @param null|string $cache_cb Read-through caching callback.
+ * @param null|float $cas_token The variable to store the CAS token in.
+ * @return bool|mixed Cached object value.
*/
function wp_cache_get_by_key( $server_key, $key, $group = '', $force = false, &$found = null, $cache_cb = null, &$cas_token = null ) {
global $wp_object_cache;
@@ -343,15 +345,16 @@ function wp_cache_get_by_key( $server_key, $key, $group = '', $force = false, &$
}
/**
- * Request multiple keys without blocking.
+ * Requests multiple keys without blocking.
*
- * @link http://www.php.net/manual/en/memcached.getdelayed.php
+ * @link https://www.php.net/manual/en/memcached.getdelayed.php
*
- * @param string|array $keys Array or string of key(s) to request.
- * @param string|array $groups Array or string of group(s) for the key(s). See buildKeys for more on how these are handled.
- * @param bool $with_cas Whether to request CAS token values also.
- * @param null $value_cb The result callback or NULL.
- * @return bool Returns TRUE on success or FALSE on failure.
+ * @param string|array $keys Array or string of key(s) to request.
+ * @param string|array $groups Array or string of group(s) for the key(s).
+ * See buildKeys for more on how these are handled.
+ * @param bool $with_cas Whether to request CAS token values also.
+ * @param null $value_cb The result callback or null.
+ * @return bool True on success, false on failure.
*/
function wp_cache_get_delayed( $keys, $groups = '', $with_cas = false, $value_cb = null ) {
global $wp_object_cache;
@@ -359,16 +362,17 @@ function wp_cache_get_delayed( $keys, $groups = '', $with_cas = false, $value_cb
}
/**
- * Request multiple keys without blocking from a specified server.
+ * Requests multiple keys without blocking from a specified server.
*
- * @link http://www.php.net/manual/en/memcached.getdelayed.php
+ * @link https://www.php.net/manual/en/memcached.getdelayed.php
*
- * @param string $server_key The key identifying the server to store the value on.
- * @param string|array $keys Array or string of key(s) to request.
- * @param string|array $groups Array or string of group(s) for the key(s). See buildKeys for more on how these are handled.
- * @param bool $with_cas Whether to request CAS token values also.
- * @param null $value_cb The result callback or NULL.
- * @return bool Returns TRUE on success or FALSE on failure.
+ * @param string $server_key The key identifying the server to store the value on.
+ * @param string|array $keys Array or string of key(s) to request.
+ * @param string|array $groups Array or string of group(s) for the key(s).
+ * See buildKeys for more on how these are handled.
+ * @param bool $with_cas Whether to request CAS token values also.
+ * @param null $value_cb The result callback or null.
+ * @return bool True on success, false on failure.
*/
function wp_cache_get_delayed_by_key( $server_key, $keys, $groups = '', $with_cas = false, $value_cb = null ) {
global $wp_object_cache;
@@ -380,13 +384,14 @@ function wp_cache_get_delayed_by_key( $server_key, $keys, $groups = '', $with_ca
*
* See the buildKeys method definition to understand the $keys/$groups parameters.
*
- * @link http://www.php.net/manual/en/memcached.getmulti.php
+ * @link https://www.php.net/manual/en/memcached.getmulti.php
*
- * @param array $keys Array of keys to retrieve.
- * @param string|array $groups If string, used for all keys. If arrays, corresponds with the $keys array.
- * @param null|array $cas_tokens The variable to store the CAS tokens for the found items.
- * @param int $flags The flags for the get operation.
- * @return bool|array Returns the array of found items or FALSE on failure.
+ * @param array $keys Array of keys to retrieve.
+ * @param string|array $groups If string, used for all keys.
+ * If arrays, corresponds with the $keys array.
+ * @param null|array $cas_tokens The variable to store the CAS tokens for the found items.
+ * @param int $flags The flags for the get operation.
+ * @return bool|array The array of found items on success, false on failure.
*/
function wp_cache_get_multi( $keys, $groups = '', &$cas_tokens = null, $flags = null ) {
global $wp_object_cache;
@@ -403,14 +408,15 @@ function wp_cache_get_multi( $keys, $groups = '', &$cas_tokens = null, $flags =
*
* See the buildKeys method definition to understand the $keys/$groups parameters.
*
- * @link http://www.php.net/manual/en/memcached.getmultibykey.php
+ * @link https://www.php.net/manual/en/memcached.getmultibykey.php
*
- * @param string $server_key The key identifying the server to store the value on.
- * @param array $keys Array of keys to retrieve.
- * @param string|array $groups If string, used for all keys. If arrays, corresponds with the $keys array.
- * @param null|array $cas_tokens The variable to store the CAS tokens for the found items.
- * @param int $flags The flags for the get operation.
- * @return bool|array Returns the array of found items or FALSE on failure.
+ * @param string $server_key The key identifying the server to store the value on.
+ * @param array $keys Array of keys to retrieve.
+ * @param string|array $groups If string, used for all keys.
+ * If arrays, corresponds with the $keys array.
+ * @param null|array $cas_tokens The variable to store the CAS tokens for the found items.
+ * @param int $flags The flags for the get operation.
+ * @return bool|array The array of found items on success, false on failure.
*/
function wp_cache_get_multi_by_key( $server_key, $keys, $groups = '', &$cas_tokens = null, $flags = null ) {
global $wp_object_cache;
@@ -423,12 +429,12 @@ function wp_cache_get_multi_by_key( $server_key, $keys, $groups = '', &$cas_toke
}
/**
- * Retrieve a Memcached option value.
+ * Retrieves a Memcached option value.
*
- * @link http://www.php.net/manual/en/memcached.getoption.php
+ * @link https://www.php.net/manual/en/memcached.getoption.php
*
- * @param int $option One of the Memcached::OPT_* constants.
- * @return mixed Returns the value of the requested option, or FALSE on error.
+ * @param int $option One of the Memcached::OPT_* constants.
+ * @return mixed The value of the requested option on success, false on failure.
*/
function wp_cache_get_option( $option ) {
global $wp_object_cache;
@@ -436,11 +442,11 @@ function wp_cache_get_option( $option ) {
}
/**
- * Return the result code of the last option.
+ * Returns the result code of the last option.
*
- * @link http://www.php.net/manual/en/memcached.getresultcode.php
+ * @link https://www.php.net/manual/en/memcached.getresultcode.php
*
- * @return int Result code of the last Memcached operation.
+ * @return int Result code of the last Memcached operation.
*/
function wp_cache_get_result_code() {
global $wp_object_cache;
@@ -450,9 +456,9 @@ function wp_cache_get_result_code() {
/**
* Return the message describing the result of the last operation.
*
- * @link http://www.php.net/manual/en/memcached.getresultmessage.php
+ * @link https://www.php.net/manual/en/memcached.getresultmessage.php
*
- * @return string Message describing the result of the last Memcached operation.
+ * @return string Message describing the result of the last Memcached operation.
*/
function wp_cache_get_result_message() {
global $wp_object_cache;
@@ -460,12 +466,12 @@ function wp_cache_get_result_message() {
}
/**
- * Get server information by key.
+ * Gets server information by key.
*
- * @link http://www.php.net/manual/en/memcached.getserverbykey.php
+ * @link https://www.php.net/manual/en/memcached.getserverbykey.php
*
- * @param string $server_key The key identifying the server to store the value on.
- * @return array Array with host, post, and weight on success, FALSE on failure.
+ * @param string $server_key The key identifying the server to store the value on.
+ * @return array Array with host, post, and weight on success, fales on failure.
*/
function wp_cache_get_server_by_key( $server_key ) {
global $wp_object_cache;
@@ -473,11 +479,11 @@ function wp_cache_get_server_by_key( $server_key ) {
}
/**
- * Get the list of servers in the pool.
+ * Gets the list of servers in the pool.
*
- * @link http://www.php.net/manual/en/memcached.getserverlist.php
+ * @link https://www.php.net/manual/en/memcached.getserverlist.php
*
- * @return array The list of all servers in the server pool.
+ * @return array The list of all servers in the server pool.
*/
function wp_cache_get_server_list() {
global $wp_object_cache;
@@ -485,11 +491,11 @@ function wp_cache_get_server_list() {
}
/**
- * Get server pool statistics.
+ * Gets server pool statistics.
*
- * @link http://www.php.net/manual/en/memcached.getstats.php
+ * @link https://www.php.net/manual/en/memcached.getstats.php
*
- * @return array Array of server statistics, one entry per server.
+ * @return array Array of server statistics, one entry per server.
*/
function wp_cache_get_stats() {
global $wp_object_cache;
@@ -497,11 +503,11 @@ function wp_cache_get_stats() {
}
/**
- * Get server pool memcached version information.
+ * Gets server pool memcached version information.
*
- * @link http://www.php.net/manual/en/memcached.getversion.php
+ * @link https://www.php.net/manual/en/memcached.getversion.php
*
- * @return array Array of server versions, one entry per server.
+ * @return array Array of server versions, one entry per server.
*/
function wp_cache_get_version() {
global $wp_object_cache;
@@ -509,14 +515,14 @@ function wp_cache_get_version() {
}
/**
- * Increment a numeric item's value.
+ * Increments a numeric item's value.
*
- * @link http://www.php.net/manual/en/memcached.increment.php
+ * @link https://www.php.net/manual/en/memcached.increment.php
*
- * @param string $key The key under which to store the value.
- * @param int $offset The amount by which to increment the item's value.
- * @param string $group The group value appended to the $key.
- * @return int|bool Returns item's new value on success or FALSE on failure.
+ * @param string $key The key under which to store the value.
+ * @param int $offset The amount by which to increment the item's value.
+ * @param string $group The group value appended to the $key.
+ * @return int|bool Item's new value on success, false on failure.
*/
function wp_cache_increment( $key, $offset = 1, $group = '' ) {
global $wp_object_cache;
@@ -524,39 +530,39 @@ function wp_cache_increment( $key, $offset = 1, $group = '' ) {
}
/**
- * Increment a numeric item's value.
+ * Increments a numeric item's value.
*
- * This is the same as wp_cache_increment, but kept for back compatibility. The original
- * WordPress caching backends use wp_cache_incr. I want both to work.
+ * This is the same as wp_cache_increment(), but kept for backward compatibility.
+ * The original WordPress caching backends use wp_cache_incr().
*
- * @link http://www.php.net/manual/en/memcached.increment.php
+ * @link https://www.php.net/manual/en/memcached.increment.php
*
- * @param string $key The key under which to store the value.
- * @param int $offset The amount by which to increment the item's value.
- * @param string $group The group value appended to the $key.
- * @return int|bool Returns item's new value on success or FALSE on failure.
+ * @param string $key The key under which to store the value.
+ * @param int $offset The amount by which to increment the item's value.
+ * @param string $group The group value appended to the $key.
+ * @return int|bool Item's new value on success, false on failure.
*/
function wp_cache_incr( $key, $offset = 1, $group = '' ) {
return wp_cache_increment( $key, $offset, $group );
}
/**
- * Prepend data to an existing item.
+ * Prepends data to an existing item.
*
* This method should throw an error if it is used with compressed data. This is an expected behavior.
- * Memcached casts the value to be prepended to the initial value to the type of the initial value. Be
- * careful as this leads to unexpected behavior at times. For instance, prepending (float) 45.23 to
- * (int) 23 will result in 45, because the value is first combined (45.2323) then cast to "integer"
+ * Memcached casts the value to be prepended to the initial value to the type of the initial value.
+ * Be careful as this leads to unexpected behavior at times. For instance, prepending (float) 45.23
+ * to (int) 23 will result in 45, because the value is first combined (45.2323) then cast to "integer"
* (the original value), which will be (int) 45. Due to how memcached treats types, the behavior has been
- * mimicked in the internal cache to produce similar results and improve consistency. It is recommend
+ * mimicked in the internal cache to produce similar results and improve consistency. It is recommended
* that prepends only occur with data of the same type.
*
- * @link http://www.php.net/manual/en/memcached.prepend.php
+ * @link https://www.php.net/manual/en/memcached.prepend.php
*
- * @param string $key The key under which to store the value.
- * @param string $value Must be string as prepending mixed values is not well-defined.
- * @param string $group The group value prepended to the $key.
- * @return bool Returns TRUE on success or FALSE on failure.
+ * @param string $key The key under which to store the value.
+ * @param string $value Must be string as prepending mixed values is not well-defined.
+ * @param string $group The group value prepended to the $key.
+ * @return bool True on success, false on failure.
*/
function wp_cache_prepend( $key, $value, $group = '' ) {
global $wp_object_cache;
@@ -564,23 +570,23 @@ function wp_cache_prepend( $key, $value, $group = '' ) {
}
/**
- * Append data to an existing item by server key.
+ * Appends data to an existing item by server key.
*
* This method should throw an error if it is used with compressed data. This is an expected behavior.
- * Memcached casts the value to be prepended to the initial value to the type of the initial value. Be
- * careful as this leads to unexpected behavior at times. For instance, prepending (float) 45.23 to
- * (int) 23 will result in 45, because the value is first combined (45.2323) then cast to "integer"
+ * Memcached casts the value to be prepended to the initial value to the type of the initial value.
+ * Be careful as this leads to unexpected behavior at times. For instance, prepending (float) 45.23
+ * to (int) 23 will result in 45, because the value is first combined (45.2323) then cast to "integer"
* (the original value), which will be (int) 45. Due to how memcached treats types, the behavior has been
- * mimicked in the internal cache to produce similar results and improve consistency. It is recommend
+ * mimicked in the internal cache to produce similar results and improve consistency. It is recommended
* that prepends only occur with data of the same type.
*
- * @link http://www.php.net/manual/en/memcached.prependbykey.php
+ * @link https://www.php.net/manual/en/memcached.prependbykey.php
*
- * @param string $server_key The key identifying the server to store the value on.
- * @param string $key The key under which to store the value.
- * @param string $value Must be string as prepending mixed values is not well-defined.
- * @param string $group The group value prepended to the $key.
- * @return bool Returns TRUE on success or FALSE on failure.
+ * @param string $server_key The key identifying the server to store the value on.
+ * @param string $key The key under which to store the value.
+ * @param string $value Must be string as prepending mixed values is not well-defined.
+ * @param string $group The group value prepended to the $key.
+ * @return bool True on success, false on failure.
*/
function wp_cache_prepend_by_key( $server_key, $key, $value, $group = '' ) {
global $wp_object_cache;
@@ -590,16 +596,16 @@ function wp_cache_prepend_by_key( $server_key, $key, $value, $group = '' ) {
/**
* Replaces a value in cache.
*
- * This method is similar to "add"; however, is does not successfully set a value if
- * the object's key is not already set in cache.
+ * This method is similar to "add"; however, is does not successfully set a value
+ * if the object's key is not already set in cache.
*
- * @link http://www.php.net/manual/en/memcached.replace.php
+ * @link https://www.php.net/manual/en/memcached.replace.php
*
- * @param string $key The key under which to store the value.
- * @param mixed $value The value to store.
- * @param string $group The group value appended to the $key.
- * @param int $expiration The expiration time, defaults to 0.
- * @return bool Returns TRUE on success or FALSE on failure.
+ * @param string $key The key under which to store the value.
+ * @param mixed $value The value to store.
+ * @param string $group The group value appended to the $key.
+ * @param int $expiration The expiration time, defaults to 0.
+ * @return bool True on success, false on failure.
*/
function wp_cache_replace( $key, $value, $group = '', $expiration = 0 ) {
global $wp_object_cache;
@@ -609,17 +615,17 @@ function wp_cache_replace( $key, $value, $group = '', $expiration = 0 ) {
/**
* Replaces a value in cache on a specific server.
*
- * This method is similar to "addByKey"; however, is does not successfully set a value if
- * the object's key is not already set in cache.
+ * This method is similar to "addByKey"; however, is does not successfully set a value
+ * if the object's key is not already set in cache.
*
- * @link http://www.php.net/manual/en/memcached.addbykey.php
+ * @link https://www.php.net/manual/en/memcached.addbykey.php
*
- * @param string $server_key The key identifying the server to store the value on.
- * @param string $key The key under which to store the value.
- * @param mixed $value The value to store.
- * @param string $group The group value appended to the $key.
- * @param int $expiration The expiration time, defaults to 0.
- * @return bool Returns TRUE on success or FALSE on failure.
+ * @param string $server_key The key identifying the server to store the value on.
+ * @param string $key The key under which to store the value.
+ * @param mixed $value The value to store.
+ * @param string $group The group value appended to the $key.
+ * @param int $expiration The expiration time, defaults to 0.
+ * @return bool True on success, false on failure.
*/
function wp_cache_replace_by_key( $server_key, $key, $value, $group = '', $expiration = 0 ) {
global $wp_object_cache;
@@ -631,13 +637,13 @@ function wp_cache_replace_by_key( $server_key, $key, $value, $group = '', $expir
*
* The value is set whether or not this key already exists in memcached.
*
- * @link http://www.php.net/manual/en/memcached.set.php
+ * @link https://www.php.net/manual/en/memcached.set.php
*
- * @param string $key The key under which to store the value.
- * @param mixed $value The value to store.
- * @param string $group The group value appended to the $key.
- * @param int $expiration The expiration time, defaults to 0.
- * @return bool Returns TRUE on success or FALSE on failure.
+ * @param string $key The key under which to store the value.
+ * @param mixed $value The value to store.
+ * @param string $group The group value appended to the $key.
+ * @param int $expiration The expiration time, defaults to 0.
+ * @return bool True on success, false on failure.
*/
function wp_cache_set( $key, $value, $group = '', $expiration = 0 ) {
global $wp_object_cache;
@@ -649,14 +655,14 @@ function wp_cache_set( $key, $value, $group = '', $expiration = 0 ) {
*
* The value is set whether or not this key already exists in memcached.
*
- * @link http://www.php.net/manual/en/memcached.set.php
+ * @link https://www.php.net/manual/en/memcached.set.php
*
- * @param string $server_key The key identifying the server to store the value on.
- * @param string $key The key under which to store the value.
- * @param mixed $value The value to store.
- * @param string $group The group value appended to the $key.
- * @param int $expiration The expiration time, defaults to 0.
- * @return bool Returns TRUE on success or FALSE on failure.
+ * @param string $server_key The key identifying the server to store the value on.
+ * @param string $key The key under which to store the value.
+ * @param mixed $value The value to store.
+ * @param string $group The group value appended to the $key.
+ * @param int $expiration The expiration time, defaults to 0.
+ * @return bool True on success, false on failure.
*/
function wp_cache_set_by_key( $server_key, $key, $value, $group = '', $expiration = 0 ) {
global $wp_object_cache;
@@ -664,7 +670,7 @@ function wp_cache_set_by_key( $server_key, $key, $value, $group = '', $expiratio
}
/**
- * Set multiple values to cache at once.
+ * Sets multiple values to cache at once.
*
* By sending an array of $items to this function, all values are saved at once to
* memcached, reducing the need for multiple requests to memcached. The $items array
@@ -672,10 +678,10 @@ function wp_cache_set_by_key( $server_key, $key, $value, $group = '', $expiratio
* are merged with the $groups array/string value via buildKeys to determine the
* final key for the object.
*
- * @param array $items An array of key/value pairs to store on the server.
- * @param string|array $groups Group(s) to merge with key(s) in $items.
- * @param int $expiration The expiration time, defaults to 0.
- * @return bool Returns TRUE on success or FALSE on failure.
+ * @param array $items An array of key/value pairs to store on the server.
+ * @param string|array $groups Group(s) to merge with key(s) in $items.
+ * @param int $expiration The expiration time, defaults to 0.
+ * @return bool True on success, false on failure.
*/
function wp_cache_set_multi( $items, $groups = '', $expiration = 0 ) {
global $wp_object_cache;
@@ -683,7 +689,7 @@ function wp_cache_set_multi( $items, $groups = '', $expiration = 0 ) {
}
/**
- * Set multiple values to cache at once on specified server.
+ * Sets multiple values to cache at once on specified server.
*
* By sending an array of $items to this function, all values are saved at once to
* memcached, reducing the need for multiple requests to memcached. The $items array
@@ -691,11 +697,11 @@ function wp_cache_set_multi( $items, $groups = '', $expiration = 0 ) {
* are merged with the $groups array/string value via buildKeys to determine the
* final key for the object.
*
- * @param string $server_key The key identifying the server to store the value on.
- * @param array $items An array of key/value pairs to store on the server.
- * @param string|array $groups Group(s) to merge with key(s) in $items.
- * @param int $expiration The expiration time, defaults to 0.
- * @return bool Returns TRUE on success or FALSE on failure.
+ * @param string $server_key The key identifying the server to store the value on.
+ * @param array $items An array of key/value pairs to store on the server.
+ * @param string|array $groups Group(s) to merge with key(s) in $items.
+ * @param int $expiration The expiration time, defaults to 0.
+ * @return bool True on success, false on failure.
*/
function wp_cache_set_multi_by_key( $server_key, $items, $groups = 'default', $expiration = 0 ) {
global $wp_object_cache;
@@ -703,13 +709,13 @@ function wp_cache_set_multi_by_key( $server_key, $items, $groups = 'default', $e
}
/**
- * Set a Memcached option.
+ * Sets a Memcached option.
*
- * @link http://www.php.net/manual/en/memcached.setoption.php
+ * @link https://www.php.net/manual/en/memcached.setoption.php
*
- * @param int $option Option name.
- * @param mixed $value Option value.
- * @return bool Returns TRUE on success or FALSE on failure.
+ * @param int $option Option name.
+ * @param mixed $value Option value.
+ * @return bool True on success, false on failure.
*/
function wp_cache_set_option( $option, $value ) {
global $wp_object_cache;
@@ -717,9 +723,9 @@ function wp_cache_set_option( $option, $value ) {
}
/**
- * Switch blog prefix, which changes the cache that is accessed.
+ * Switches blog prefix, which changes the cache that is accessed.
*
- * @param int $blog_id Blog to switch to.
+ * @param int $blog_id Blog to switch to.
* @return void
*/
function wp_cache_switch_to_blog( $blog_id ) {
@@ -731,8 +737,8 @@ function wp_cache_switch_to_blog( $blog_id ) {
/**
* Sets up Object Cache Global and assigns it.
*
- * @global WP_Object_Cache $wp_object_cache WordPress Object Cache
- * @return void
+ * @global WP_Object_Cache $wp_object_cache WordPress Object Cache
+ * @return void
*/
function wp_cache_init() {
global $wp_object_cache;
@@ -742,8 +748,8 @@ function wp_cache_init() {
/**
* Adds a group or set of groups to the list of non-persistent groups.
*
- * @param string|array $groups A group or an array of groups to add.
- * @return void
+ * @param string|array $groups A group or an array of groups to add.
+ * @return void
*/
function wp_cache_add_global_groups( $groups ) {
global $wp_object_cache;
@@ -753,8 +759,8 @@ function wp_cache_add_global_groups( $groups ) {
/**
* Adds a group or set of groups to the list of non-Memcached groups.
*
- * @param string|array $groups A group or an array of groups to add.
- * @return void
+ * @param string|array $groups A group or an array of groups to add.
+ * @return void
*/
function wp_cache_add_non_persistent_groups( $groups ) {
global $wp_object_cache;
@@ -814,14 +820,15 @@ class WP_Object_Cache {
public $blog_prefix = '';
/**
- * Instantiate the Memcached class.
+ * Instantiates the Memcached class.
*
* Instantiates the Memcached class and returns adds the servers specified
* in the $memcached_servers global array.
*
- * @link http://www.php.net/manual/en/memcached.construct.php
+ * @link https://www.php.net/manual/en/memcached.construct.php
*
- * @param null $persistent_id To create an instance that persists between requests, use persistent_id to specify a unique ID for the instance.
+ * @param null $persistent_id To create an instance that persists between requests,
+ * use persistent_id to specify a unique ID for the instance.
*/
public function __construct( $persistent_id = null ) {
global $memcached_servers, $blog_id, $table_prefix;
@@ -841,20 +848,20 @@ class WP_Object_Cache {
$this->addServers( $this->servers );
/**
- * This approach is borrowed from Sivel and Boren. Use the salt for easy cache invalidation and for
- * multi single WP installations on the same server.
+ * This approach is borrowed from Sivel and Boren. Use the salt for easy cache invalidation
+ * and for multi single WP installations on the same server.
*/
if ( ! defined( 'WP_CACHE_KEY_SALT' ) ) {
define( 'WP_CACHE_KEY_SALT', '' );
}
- // Assign global and blog prefixes for use with keys
+ // Assign global and blog prefixes for use with keys.
if ( function_exists( 'is_multisite' ) ) {
$this->global_prefix = ( is_multisite() || defined( 'CUSTOM_USER_TABLE' ) && defined( 'CUSTOM_USER_META_TABLE' ) ) ? '' : $table_prefix;
$this->blog_prefix = ( is_multisite() ? $blog_id : $table_prefix ) . ':';
}
- // Setup cacheable values for handling expiration times
+ // Setup cacheable values for handling expiration times.
$this->thirty_days = 60 * 60 * 24 * 30;
$this->now = time();
}
@@ -865,15 +872,15 @@ class WP_Object_Cache {
* If the specified key already exists, the value is not stored and the function
* returns false.
*
- * @link http://www.php.net/manual/en/memcached.add.php
+ * @link https://www.php.net/manual/en/memcached.add.php
*
- * @param string $key The key under which to store the value.
- * @param mixed $value The value to store.
- * @param string $group The group value appended to the $key.
- * @param int $expiration The expiration time, defaults to 0.
- * @param string $server_key The key identifying the server to store the value on.
- * @param bool $by_key True to store in internal cache by key; false to not store by key
- * @return bool Returns TRUE on success or FALSE on failure.
+ * @param string $key The key under which to store the value.
+ * @param mixed $value The value to store.
+ * @param string $group The group value appended to the $key.
+ * @param int $expiration The expiration time, defaults to 0.
+ * @param string $server_key The key identifying the server to store the value on.
+ * @param bool $by_key True to store in internal cache by key; false to not store by key.
+ * @return bool True on success, false on failure.
*/
public function add( $key, $value, $group = 'default', $expiration = 0, $server_key = '', $by_key = false ) {
/*
@@ -889,10 +896,10 @@ class WP_Object_Cache {
$derived_key = $this->buildKey( $key, $group );
$expiration = $this->sanitize_expiration( $expiration );
- // If group is a non-Memcached group, save to runtime cache, not Memcached
+ // If group is a non-Memcached group, save to runtime cache, not Memcached.
if ( in_array( $group, $this->no_mc_groups, true ) ) {
- // Add does not set the value if the key exists; mimic that here
+ // Add does not set the value if the key exists; mimic that here.
if ( isset( $this->cache[ $derived_key ] ) ) {
return false;
}
@@ -902,14 +909,14 @@ class WP_Object_Cache {
return true;
}
- // Save to Memcached
+ // Save to Memcached.
if ( $by_key ) {
$result = $this->m->addByKey( $server_key, $derived_key, $value, $expiration );
} else {
$result = $this->m->add( $derived_key, $value, $expiration );
}
- // Store in runtime cache if add was successful
+ // Store in runtime cache if add was successful.
if ( Memcached::RES_SUCCESS === $this->getResultCode() ) {
$this->add_to_internal_cache( $derived_key, $value );
}
@@ -925,28 +932,29 @@ class WP_Object_Cache {
* _cache object as part of the runtime cache. It will add it to an array for the
* specified server_key.
*
- * @link http://www.php.net/manual/en/memcached.addbykey.php
+ * @link https://www.php.net/manual/en/memcached.addbykey.php
*
- * @param string $server_key The key identifying the server to store the value on.
- * @param string $key The key under which to store the value.
- * @param mixed $value The value to store.
- * @param string $group The group value appended to the $key.
- * @param int $expiration The expiration time, defaults to 0.
- * @return bool Returns TRUE on success or FALSE on failure.
+ * @param string $server_key The key identifying the server to store the value on.
+ * @param string $key The key under which to store the value.
+ * @param mixed $value The value to store.
+ * @param string $group The group value appended to the $key.
+ * @param int $expiration The expiration time, defaults to 0.
+ * @return bool True on success, false on failure.
*/
public function addByKey( $server_key, $key, $value, $group = 'default', $expiration = 0 ) {
return $this->add( $key, $value, $group, $expiration, $server_key, true );
}
/**
- * Add a single server to the list of Memcached servers.
+ * Adds a single server to the list of Memcached servers.
*
- * @link http://www.php.net/manual/en/memcached.addserver.php
+ * @link https://www.php.net/manual/en/memcached.addserver.php
*
- * @param string $host The hostname of the memcache server.
- * @param int $port The port on which memcache is running.
- * @param int $weight The weight of the server relative to the total weight of all the servers in the pool.
- * @return bool Returns TRUE on success or FALSE on failure.
+ * @param string $host The hostname of the memcache server.
+ * @param int $port The port on which memcache is running.
+ * @param int $weight The weight of the server relative to the total weight
+ * of all the servers in the pool.
+ * @return bool True on success, false on failure.
*/
public function addServer( $host, $port, $weight = 0 ) {
$host = is_string( $host ) ? $host : '127.0.0.1';
@@ -962,10 +970,10 @@ class WP_Object_Cache {
* Each individual server in the array must include a domain and port, with an optional
* weight value: $servers = array( array( '127.0.0.1', 11211, 0 ) );
*
- * @link http://www.php.net/manual/en/memcached.addservers.php
+ * @link https://www.php.net/manual/en/memcached.addservers.php
*
- * @param array $servers Array of server to register.
- * @return bool True on success; false on failure.
+ * @param array $servers Array of server to register.
+ * @return bool True on success, false on failure.
*/
public function addServers( $servers ) {
if ( ! is_object( $this->m ) ) {
@@ -976,23 +984,23 @@ class WP_Object_Cache {
}
/**
- * Append data to an existing item.
+ * Appends data to an existing item.
*
- * This method should throw an error if it is used with compressed data. This
- * is an expected behavior. Memcached casts the value to be appended to the initial value to the
- * type of the initial value. Be careful as this leads to unexpected behavior at times. Due to
- * how memcached treats types, the behavior has been mimicked in the internal cache to produce
- * similar results and improve consistency. It is recommend that appends only occur with data of
+ * This method should throw an error if it is used with compressed data.
+ * This is an expected behavior. Memcached casts the value to be appended to the initial value
+ * to the type of the initial value. Be careful as this leads to unexpected behavior at times.
+ * Due to how memcached treats types, the behavior has been mimicked in the internal cache to produce
+ * similar results and improve consistency. It is recommended that appends only occur with data of
* the same type.
*
- * @link http://www.php.net/manual/en/memcached.append.php
+ * @link https://www.php.net/manual/en/memcached.append.php
*
- * @param string $key The key under which to store the value.
- * @param mixed $value Must be string as appending mixed values is not well-defined.
- * @param string $group The group value appended to the $key.
- * @param string $server_key The key identifying the server to store the value on.
- * @param bool $by_key True to store in internal cache by key; false to not store by key
- * @return bool Returns TRUE on success or FALSE on failure.
+ * @param string $key The key under which to store the value.
+ * @param mixed $value Must be string as appending mixed values is not well-defined.
+ * @param string $group The group value appended to the $key.
+ * @param string $server_key The key identifying the server to store the value on.
+ * @param bool $by_key True to store in internal cache by key; false to not store by key.
+ * @return bool True on success, false on failure.
*/
public function append( $key, $value, $group = 'default', $server_key = '', $by_key = false ) {
if ( ! is_string( $value ) && ! is_int( $value ) && ! is_float( $value ) ) {
@@ -1001,7 +1009,7 @@ class WP_Object_Cache {
$derived_key = $this->buildKey( $key, $group );
- // If group is a non-Memcached group, append to runtime cache value, not Memcached
+ // If group is a non-Memcached group, append to runtime cache value, not Memcached.
if ( in_array( $group, $this->no_mc_groups, true ) ) {
if ( ! isset( $this->cache[ $derived_key ] ) ) {
return false;
@@ -1012,14 +1020,14 @@ class WP_Object_Cache {
return true;
}
- // Append to Memcached value
+ // Append to Memcached value.
if ( $by_key ) {
$result = $this->m->appendByKey( $server_key, $derived_key, $value );
} else {
$result = $this->m->append( $derived_key, $value );
}
- // Store in runtime cache if add was successful
+ // Store in runtime cache if add was successful.
if ( Memcached::RES_SUCCESS === $this->getResultCode() ) {
$combined = $this->combine_values( $this->cache[ $derived_key ], $value, 'app' );
$this->add_to_internal_cache( $derived_key, $combined );
@@ -1029,22 +1037,22 @@ class WP_Object_Cache {
}
/**
- * Append data to an existing item by server key.
+ * Appends data to an existing item by server key.
*
- * This method should throw an error if it is used with compressed data. This
- * is an expected behavior. Memcached casts the value to be appended to the initial value to the
- * type of the initial value. Be careful as this leads to unexpected behavior at times. Due to
- * how memcached treats types, the behavior has been mimicked in the internal cache to produce
- * similar results and improve consistency. It is recommend that appends only occur with data of
+ * This method should throw an error if it is used with compressed data.
+ * This is an expected behavior. Memcached casts the value to be appended to the initial value
+ * to the type of the initial value. Be careful as this leads to unexpected behavior at times.
+ * Due to how memcached treats types, the behavior has been mimicked in the internal cache to produce
+ * similar results and improve consistency. It is recommended that appends only occur with data of
* the same type.
*
- * @link http://www.php.net/manual/en/memcached.appendbykey.php
+ * @link https://www.php.net/manual/en/memcached.appendbykey.php
*
- * @param string $server_key The key identifying the server to store the value on.
- * @param string $key The key under which to store the value.
- * @param mixed $value Must be string as appending mixed values is not well-defined
- * @param string $group The group value appended to the $key.
- * @return bool Returns TRUE on success or FALSE on failure.
+ * @param string $server_key The key identifying the server to store the value on.
+ * @param string $key The key under which to store the value.
+ * @param mixed $value Must be string as appending mixed values is not well-defined.
+ * @param string $group The group value appended to the $key.
+ * @return bool True on success, false on failure.
*/
public function appendByKey( $server_key, $key, $value, $group = 'default' ) {
return $this->append( $key, $value, $group, $server_key, true );
@@ -1053,19 +1061,19 @@ class WP_Object_Cache {
/**
* Performs a "check and set" to store data.
*
- * The set will be successful only if the no other request has updated the value since it was fetched since
- * this request.
+ * The set will be successful only if the no other request has updated the value
+ * since it was fetched by this request.
*
- * @link http://www.php.net/manual/en/memcached.cas.php
+ * @link https://www.php.net/manual/en/memcached.cas.php
*
- * @param float $cas_token Unique value associated with the existing item. Generated by memcached.
- * @param string $key The key under which to store the value.
- * @param mixed $value The value to store.
- * @param string $group The group value appended to the $key.
- * @param int $expiration The expiration time, defaults to 0.
- * @param string $server_key The key identifying the server to store the value on.
- * @param bool $by_key True to store in internal cache by key; false to not store by key
- * @return bool Returns TRUE on success or FALSE on failure.
+ * @param float $cas_token Unique value associated with the existing item. Generated by memcached.
+ * @param string $key The key under which to store the value.
+ * @param mixed $value The value to store.
+ * @param string $group The group value appended to the $key.
+ * @param int $expiration The expiration time, defaults to 0.
+ * @param string $server_key The key identifying the server to store the value on.
+ * @param bool $by_key True to store in internal cache by key; false to not store by key.
+ * @return bool True on success, false on failure.
*/
public function cas( $cas_token, $key, $value, $group = 'default', $expiration = 0, $server_key = '', $by_key = false ) {
$derived_key = $this->buildKey( $key, $group );
@@ -1081,14 +1089,14 @@ class WP_Object_Cache {
return true;
}
- // Save to Memcached
+ // Save to Memcached.
if ( $by_key ) {
$result = $this->m->casByKey( $cas_token, $server_key, $derived_key, $value, $expiration );
} else {
$result = $this->m->cas( $cas_token, $derived_key, $value, $expiration );
}
- // Store in runtime cache if cas was successful
+ // Store in runtime cache if cas was successful.
if ( Memcached::RES_SUCCESS === $this->getResultCode() ) {
$this->add_to_internal_cache( $derived_key, $value );
}
@@ -1099,50 +1107,50 @@ class WP_Object_Cache {
/**
* Performs a "check and set" to store data with a server key.
*
- * The set will be successful only if the no other request has updated the value since it was fetched by
- * this request.
+ * The set will be successful only if the no other request has updated the value
+ * since it was fetched by this request.
*
- * @link http://www.php.net/manual/en/memcached.casbykey.php
+ * @link https://www.php.net/manual/en/memcached.casbykey.php
*
- * @param string $server_key The key identifying the server to store the value on.
- * @param float $cas_token Unique value associated with the existing item. Generated by memcached.
- * @param string $key The key under which to store the value.
- * @param mixed $value The value to store.
- * @param string $group The group value appended to the $key.
- * @param int $expiration The expiration time, defaults to 0.
- * @return bool Returns TRUE on success or FALSE on failure.
+ * @param string $server_key The key identifying the server to store the value on.
+ * @param float $cas_token Unique value associated with the existing item. Generated by memcached.
+ * @param string $key The key under which to store the value.
+ * @param mixed $value The value to store.
+ * @param string $group The group value appended to the $key.
+ * @param int $expiration The expiration time, defaults to 0.
+ * @return bool True on success, false on failure.
*/
public function casByKey( $cas_token, $server_key, $key, $value, $group = 'default', $expiration = 0 ) {
return $this->cas( $cas_token, $key, $value, $group, $expiration, $server_key, true );
}
/**
- * Decrement a numeric item's value.
+ * Decrements a numeric item's value.
*
- * @link http://www.php.net/manual/en/memcached.decrement.php
+ * @link https://www.php.net/manual/en/memcached.decrement.php
*
- * @param string $key The key under which to store the value.
- * @param int $offset The amount by which to decrement the item's value.
- * @param string $group The group value appended to the $key.
- * @return int|bool Returns item's new value on success or FALSE on failure.
+ * @param string $key The key under which to store the value.
+ * @param int $offset The amount by which to decrement the item's value.
+ * @param string $group The group value appended to the $key.
+ * @return int|bool Item's new value on success, false on failure.
*/
public function decrement( $key, $offset = 1, $group = 'default' ) {
$derived_key = $this->buildKey( $key, $group );
- // Decrement values in no_mc_groups
+ // Decrement values in no_mc_groups.
if ( in_array( $group, $this->no_mc_groups, true ) ) {
- // Only decrement if the key already exists and value is 0 or greater (mimics memcached behavior)
+ // Only decrement if the key already exists and value is 0 or greater (mimics memcached behavior).
if ( isset( $this->cache[ $derived_key ] ) && $this->cache[ $derived_key ] >= 0 ) {
- // If numeric, subtract; otherwise, consider it 0 and do nothing
+ // If numeric, subtract; otherwise, consider it 0 and do nothing.
if ( is_numeric( $this->cache[ $derived_key ] ) ) {
$this->cache[ $derived_key ] -= (int) $offset;
} else {
$this->cache[ $derived_key ] = 0;
}
- // Returned value cannot be less than 0
+ // Returned value cannot be less than 0.
if ( $this->cache[ $derived_key ] < 0 ) {
$this->cache[ $derived_key ] = 0;
}
@@ -1163,41 +1171,42 @@ class WP_Object_Cache {
}
/**
- * Decrement a numeric item's value.
+ * Decrements a numeric item's value.
*
- * Alias for $this->decrement. Other caching backends use this abbreviated form of the function. It *may* cause
- * breakage somewhere, so it is nice to have. This function will also allow the core unit tests to pass.
+ * Alias for $this->decrement(). Other caching backends use this abbreviated form
+ * of the function. It *may* cause breakage somewhere, so it is nice to have.
+ * This function will also allow the core unit tests to pass.
*
- * @param string $key The key under which to store the value.
- * @param int $offset The amount by which to decrement the item's value.
- * @param string $group The group value appended to the $key.
- * @return int|bool Returns item's new value on success or FALSE on failure.
+ * @param string $key The key under which to store the value.
+ * @param int $offset The amount by which to decrement the item's value.
+ * @param string $group The group value appended to the $key.
+ * @return int|bool Item's new value on success, false on failure.
*/
public function decr( $key, $offset = 1, $group = 'default' ) {
return $this->decrement( $key, $offset, $group );
}
/**
- * Remove the item from the cache.
+ * Removes the item from the cache.
*
- * Remove an item from memcached with identified by $key after $time seconds. The
- * $time parameter allows an object to be queued for deletion without immediately
- * deleting. Between the time that it is queued and the time it's deleted, add,
- * replace, and get will fail, but set will succeed.
+ * Removes an item from memcached with identified by $key after $time seconds.
+ * The $time parameter allows an object to be queued for deletion without
+ * immediately deleting. Between the time that it is queued and the time it's deleted,
+ * add, replace, and get will fail, but set will succeed.
*
- * @link http://www.php.net/manual/en/memcached.delete.php
+ * @link https://www.php.net/manual/en/memcached.delete.php
*
- * @param string $key The key under which to store the value.
- * @param string $group The group value appended to the $key.
- * @param int $time The amount of time the server will wait to delete the item in seconds.
- * @param string $server_key The key identifying the server to store the value on.
- * @param bool $by_key True to store in internal cache by key; false to not store by key
- * @return bool Returns TRUE on success or FALSE on failure.
+ * @param string $key The key under which to store the value.
+ * @param string $group The group value appended to the $key.
+ * @param int $time The amount of time the server will wait to delete the item in seconds.
+ * @param string $server_key The key identifying the server to store the value on.
+ * @param bool $by_key True to store in internal cache by key; false to not store by key.
+ * @return bool True on success, false on failure.
*/
public function delete( $key, $group = 'default', $time = 0, $server_key = '', $by_key = false ) {
$derived_key = $this->buildKey( $key, $group );
- // Remove from no_mc_groups array
+ // Remove from no_mc_groups array.
if ( in_array( $group, $this->no_mc_groups, true ) ) {
if ( isset( $this->cache[ $derived_key ] ) ) {
unset( $this->cache[ $derived_key ] );
@@ -1220,59 +1229,59 @@ class WP_Object_Cache {
}
/**
- * Remove the item from the cache by server key.
+ * Removes the item from the cache by server key.
*
- * Remove an item from memcached with identified by $key after $time seconds. The
- * $time parameter allows an object to be queued for deletion without immediately
- * deleting. Between the time that it is queued and the time it's deleted, add,
- * replace, and get will fail, but set will succeed.
+ * Removes an item from memcached with identified by $key after $time seconds.
+ * The $time parameter allows an object to be queued for deletion without
+ * immediately deleting. Between the time that it is queued and the time it's deleted,
+ * add, replace, and get will fail, but set will succeed.
*
- * @link http://www.php.net/manual/en/memcached.deletebykey.php
+ * @link https://www.php.net/manual/en/memcached.deletebykey.php
*
- * @param string $server_key The key identifying the server to store the value on.
- * @param string $key The key under which to store the value.
- * @param string $group The group value appended to the $key.
- * @param int $time The amount of time the server will wait to delete the item in seconds.
- * @return bool Returns TRUE on success or FALSE on failure.
+ * @param string $server_key The key identifying the server to store the value on.
+ * @param string $key The key under which to store the value.
+ * @param string $group The group value appended to the $key.
+ * @param int $time The amount of time the server will wait to delete the item in seconds.
+ * @return bool True on success, false on failure.
*/
public function deleteByKey( $server_key, $key, $group = 'default', $time = 0 ) {
return $this->delete( $key, $group, $time, $server_key, true );
}
/**
- * Fetch the next result.
+ * Fetches the next result.
*
- * @link http://www.php.net/manual/en/memcached.fetch.php
+ * @link https://www.php.net/manual/en/memcached.fetch.php
*
- * @return array|bool Returns the next result or FALSE on failure.
+ * @return array|false The next result on success, false on failure.
*/
public function fetch() {
return $this->m->fetch();
}
/**
- * Fetch all remaining results from the last request.
+ * Fetches all remaining results from the last request.
*
- * @link http://www.php.net/manual/en/memcached.fetchall.php
+ * @link https://www.php.net/manual/en/memcached.fetchall.php
*
- * @return array|bool Returns the results or FALSE on failure.
+ * @return array|false The results on success, false on failure.
*/
public function fetchAll() {
return $this->m->fetchAll();
}
/**
- * Invalidate all items in the cache.
+ * Invalidates all items in the cache.
*
- * @link http://www.php.net/manual/en/memcached.flush.php
+ * @link https://www.php.net/manual/en/memcached.flush.php
*
- * @param int $delay Number of seconds to wait before invalidating the items.
- * @return bool Returns TRUE on success or FALSE on failure.
+ * @param int $delay Number of seconds to wait before invalidating the items.
+ * @return bool True on success, false on failure.
*/
public function flush( $delay = 0 ) {
$result = $this->m->flush( $delay );
- // Only reset the runtime cache if memcached was properly flushed
+ // Only reset the runtime cache if memcached was properly flushed.
if ( Memcached::RES_SUCCESS === $this->getResultCode() ) {
$this->cache = array();
}
@@ -1281,36 +1290,37 @@ class WP_Object_Cache {
}
/**
- * Retrieve object from cache.
- *
- * Gets an object from cache based on $key and $group. In order to fully support the $cache_cb and $cas_token
- * parameters, the runtime cache is ignored by this function if either of those values are set. If either of
- * those values are set, the request is made directly to the memcached server for proper handling of the
- * callback and/or token. Note that the $cas_token variable cannot be directly passed to the function. The
- * variable need to be first defined with a non null value.
- *
- * If using the $cache_cb argument, the new value will always have an expiration of time of 0 (forever). This
- * is a limitation of the Memcached PECL extension.
- *
- * @link http://www.php.net/manual/en/memcached.get.php
- *
- * @param string $key The key under which to store the value.
- * @param string $group The group value appended to the $key.
- * @param bool $force Whether or not to force a cache invalidation.
- * @param null|bool $found Variable passed by reference to determine if the value was found or not.
- * @param string $server_key The key identifying the server to store the value on.
- * @param bool $by_key True to store in internal cache by key; false to not store by key
- * @param null|callable $cache_cb Read-through caching callback.
- * @param null|float $cas_token The variable to store the CAS token in.
- * @return bool|mixed Cached object value.
+ * Retrieves object from cache.
+ *
+ * Gets an object from cache based on $key and $group. In order to fully support
+ * the $cache_cb and $cas_token parameters, the runtime cache is ignored by this function
+ * if either of those values are set. In that case, the request is made directly
+ * to the memcached server for proper handling of the callback and/or token.
+ * Note that the $cas_token variable cannot be directly passed to the function.
+ * The variable needs to be first defined with a non-null value.
+ *
+ * If using the $cache_cb argument, the new value will always have an expiration
+ * of time of 0 (forever). This is a limitation of the Memcached PECL extension.
+ *
+ * @link https://www.php.net/manual/en/memcached.get.php
+ *
+ * @param string $key The key under which to store the value.
+ * @param string $group The group value appended to the $key.
+ * @param bool $force Whether or not to force a cache invalidation.
+ * @param null|bool $found Variable passed by reference to determine if the value was found or not.
+ * @param string $server_key The key identifying the server to store the value on.
+ * @param bool $by_key True to store in internal cache by key; false to not store by key.
+ * @param null|callable $cache_cb Read-through caching callback.
+ * @param null|float $cas_token The variable to store the CAS token in.
+ * @return bool|mixed Cached object value.
*/
public function get( $key, $group = 'default', $force = false, &$found = null, $server_key = '', $by_key = false, $cache_cb = null, &$cas_token = null ) {
$derived_key = $this->buildKey( $key, $group );
- // Assume object is not found
+ // Assume object is not found.
$found = false;
- // If either $cache_db, or $cas_token is set, must hit Memcached and bypass runtime cache
+ // If either $cache_db, or $cas_token is set, must hit Memcached and bypass runtime cache.
if ( func_num_args() > 6 && ! in_array( $group, $this->no_mc_groups, true ) ) {
if ( $by_key ) {
$value = $this->m->getByKey( $server_key, $derived_key, $cache_cb, $cas_token );
@@ -1341,27 +1351,28 @@ class WP_Object_Cache {
}
/**
- * Retrieve object from cache from specified server.
- *
- * Gets an object from cache based on $key, $group and $server_key. In order to fully support the $cache_cb and $cas_token
- * parameters, the runtime cache is ignored by this function if either of those values are set. If either of
- * those values are set, the request is made directly to the memcached server for proper handling of the
- * callback and/or token. Note that the $cas_token variable cannot be directly passed to the function. The
- * variable need to be first defined with a non null value.
- *
- * If using the $cache_cb argument, the new value will always have an expiration of time of 0 (forever). This
- * is a limitation of the Memcached PECL extension.
- *
- * @link http://www.php.net/manual/en/memcached.getbykey.php
- *
- * @param string $server_key The key identifying the server to store the value on.
- * @param string $key The key under which to store the value.
- * @param string $group The group value appended to the $key.
- * @param bool $force Whether or not to force a cache invalidation.
- * @param null|bool $found Variable passed by reference to determine if the value was found or not.
- * @param null|string $cache_cb Read-through caching callback.
- * @param null|float $cas_token The variable to store the CAS token in.
- * @return bool|mixed Cached object value.
+ * Retrieves object from cache from specified server.
+ *
+ * Gets an object from cache based on $key and $group, and $server_key. In order to fully support
+ * the $cache_cb and $cas_token parameters, the runtime cache is ignored by this function
+ * if either of those values are set. In that case, the request is made directly
+ * to the memcached server for proper handling of the callback and/or token.
+ * Note that the $cas_token variable cannot be directly passed to the function.
+ * The variable needs to be first defined with a non-null value.
+ *
+ * If using the $cache_cb argument, the new value will always have an expiration
+ * of time of 0 (forever). This is a limitation of the Memcached PECL extension.
+ *
+ * @link https://www.php.net/manual/en/memcached.getbykey.php
+ *
+ * @param string $server_key The key identifying the server to store the value on.
+ * @param string $key The key under which to store the value.
+ * @param string $group The group value appended to the $key.
+ * @param bool $force Whether or not to force a cache invalidation.
+ * @param null|bool $found Variable passed by reference to determine if the value was found or not.
+ * @param null|string $cache_cb Read-through caching callback.
+ * @param null|float $cas_token The variable to store the CAS token in.
+ * @return bool|mixed Cached object value.
*/
public function getByKey( $server_key, $key, $group = 'default', $force = false, &$found = null, $cache_cb = null, &$cas_token = null ) {
/**
@@ -1376,15 +1387,16 @@ class WP_Object_Cache {
}
/**
- * Request multiple keys without blocking.
+ * Requests multiple keys without blocking.
*
- * @link http://www.php.net/manual/en/memcached.getdelayed.php
+ * @link https://www.php.net/manual/en/memcached.getdelayed.php
*
- * @param string|array $keys Array or string of key(s) to request.
- * @param string|array $groups Array or string of group(s) for the key(s). See buildKeys for more on how these are handled.
- * @param bool $with_cas Whether to request CAS token values also.
- * @param null $value_cb The result callback or NULL.
- * @return bool Returns TRUE on success or FALSE on failure.
+ * @param string|array $keys Array or string of key(s) to request.
+ * @param string|array $groups Array or string of group(s) for the key(s).
+ * See buildKeys for more on how these are handled.
+ * @param bool $with_cas Whether to request CAS token values also.
+ * @param null $value_cb The result callback or null.
+ * @return bool True on success, false on failure.
*/
public function getDelayed( $keys, $groups = 'default', $with_cas = false, $value_cb = null ) {
$derived_keys = $this->buildKeys( $keys, $groups );
@@ -1392,16 +1404,17 @@ class WP_Object_Cache {
}
/**
- * Request multiple keys without blocking from a specified server.
+ * Requests multiple keys without blocking from a specified server.
*
- * @link http://www.php.net/manual/en/memcached.getdelayed.php
+ * @link https://www.php.net/manual/en/memcached.getdelayed.php
*
- * @param string $server_key The key identifying the server to store the value on.
- * @param string|array $keys Array or string of key(s) to request.
- * @param string|array $groups Array or string of group(s) for the key(s). See buildKeys for more on how these are handled.
- * @param bool $with_cas Whether to request CAS token values also.
- * @param null $value_cb The result callback or NULL.
- * @return bool Returns TRUE on success or FALSE on failure.
+ * @param string $server_key The key identifying the server to store the value on.
+ * @param string|array $keys Array or string of key(s) to request.
+ * @param string|array $groups Array or string of group(s) for the key(s).
+ * See buildKeys for more on how these are handled.
+ * @param bool $with_cas Whether to request CAS token values also.
+ * @param null $value_cb The result callback or null.
+ * @return bool True on success, false on failure.
*/
public function getDelayedByKey( $server_key, $keys, $groups = 'default', $with_cas = false, $value_cb = null ) {
$derived_keys = $this->buildKeys( $keys, $groups );
@@ -1413,22 +1426,23 @@ class WP_Object_Cache {
*
* See the buildKeys method definition to understand the $keys/$groups parameters.
*
- * @link http://www.php.net/manual/en/memcached.getmulti.php
+ * @link https://www.php.net/manual/en/memcached.getmulti.php
*
- * @param array $keys Array of keys to retrieve.
- * @param string|array $groups If string, used for all keys. If arrays, corresponds with the $keys array.
- * @param string $server_key The key identifying the server to store the value on.
- * @param null|array $cas_tokens The variable to store the CAS tokens for the found items.
- * @param int $flags The flags for the get operation.
- * @return bool|array Returns the array of found items or FALSE on failure.
+ * @param array $keys Array of keys to retrieve.
+ * @param string|array $groups If string, used for all keys.
+ * If arrays, corresponds with the $keys array.
+ * @param string $server_key The key identifying the server to store the value on.
+ * @param null|array $cas_tokens The variable to store the CAS tokens for the found items.
+ * @param int $flags The flags for the get operation.
+ * @return bool|array The array of found items on success, false on failure.
*/
public function getMulti( $keys, $groups = 'default', $server_key = '', &$cas_tokens = null, $flags = null ) {
$derived_keys = $this->buildKeys( $keys, $groups );
/**
- * If either $cas_tokens, or $flags is set, must hit Memcached and bypass runtime cache. Note that
- * this will purposely ignore no_mc_groups values as they cannot handle CAS tokens or the special
- * flags; however, if the groups of groups contains a no_mc_group, this is bypassed.
+ * If either $cas_tokens, or $flags is set, must hit Memcached and bypass runtime cache.
+ * Note that this will purposely ignore no_mc_groups values as they cannot handle CAS tokens
+ * or the special flags; however, if the groups of groups contains a no_mc_group, this is bypassed.
*/
if ( func_num_args() > 3 && ! $this->contains_no_mc_group( $groups ) ) {
if ( ! empty( $server_key ) ) {
@@ -1440,7 +1454,7 @@ class WP_Object_Cache {
$values = array();
$need_to_get = array();
- // Pull out values from runtime cache, or mark for retrieval
+ // Pull out values from runtime cache, or mark for retrieval.
foreach ( $derived_keys as $key ) {
if ( isset( $this->cache[ $key ] ) ) {
$values[ $key ] = $this->cache[ $key ];
@@ -1449,7 +1463,7 @@ class WP_Object_Cache {
}
}
- // Get those keys not found in the runtime cache
+ // Get those keys not found in the runtime cache.
if ( ! empty( $need_to_get ) ) {
if ( ! empty( $server_key ) ) {
$result = $this->m->getMultiByKey( $server_key, array_keys( $need_to_get ) );
@@ -1458,12 +1472,12 @@ class WP_Object_Cache {
}
}
- // Merge with values found in runtime cache
+ // Merge with values found in runtime cache.
if ( isset( $result ) && Memcached::RES_SUCCESS === $this->getResultCode() ) {
$values = array_merge( $values, $result );
}
- // If order should be preserved, reorder now
+ // If order should be preserved, reorder now.
if ( ! empty( $need_to_get ) && Memcached::GET_PRESERVE_ORDER === $flags ) {
$ordered_values = array();
@@ -1478,7 +1492,7 @@ class WP_Object_Cache {
}
}
- // Add the values to the runtime cache
+ // Add the values to the runtime cache.
$this->cache = array_merge( $this->cache, $values );
return $values;
@@ -1489,14 +1503,15 @@ class WP_Object_Cache {
*
* See the buildKeys method definition to understand the $keys/$groups parameters.
*
- * @link http://www.php.net/manual/en/memcached.getmultibykey.php
+ * @link https://www.php.net/manual/en/memcached.getmultibykey.php
*
- * @param string $server_key The key identifying the server to store the value on.
- * @param array $keys Array of keys to retrieve.
- * @param string|array $groups If string, used for all keys. If arrays, corresponds with the $keys array.
- * @param null|array $cas_tokens The variable to store the CAS tokens for the found items.
- * @param int $flags The flags for the get operation.
- * @return bool|array Returns the array of found items or FALSE on failure.
+ * @param string $server_key The key identifying the server to store the value on.
+ * @param array $keys Array of keys to retrieve.
+ * @param string|array $groups If string, used for all keys.
+ * If arrays, corresponds with the $keys array.
+ * @param null|array $cas_tokens The variable to store the CAS tokens for the found items.
+ * @param int $flags The flags for the get operation.
+ * @return bool|array The array of found items on success, false on failure.
*/
public function getMultiByKey( $server_key, $keys, $groups = 'default', &$cas_tokens = null, $flags = null ) {
/**
@@ -1511,23 +1526,23 @@ class WP_Object_Cache {
}
/**
- * Retrieve a Memcached option value.
+ * Retrieves a Memcached option value.
*
- * @link http://www.php.net/manual/en/memcached.getoption.php
+ * @link https://www.php.net/manual/en/memcached.getoption.php
*
- * @param int $option One of the Memcached::OPT_* constants.
- * @return mixed Returns the value of the requested option, or FALSE on error.
+ * @param int $option One of the Memcached::OPT_* constants.
+ * @return mixed The value of the requested option on success, false on failure.
*/
public function getOption( $option ) {
return $this->m->getOption( $option );
}
/**
- * Return the result code of the last option.
+ * Returns the result code of the last option.
*
- * @link http://www.php.net/manual/en/memcached.getresultcode.php
+ * @link https://www.php.net/manual/en/memcached.getresultcode.php
*
- * @return int Result code of the last Memcached operation.
+ * @return int Result code of the last Memcached operation.
*/
public function getResultCode() {
return $this->m->getResultCode();
@@ -1536,86 +1551,86 @@ class WP_Object_Cache {
/**
* Return the message describing the result of the last operation.
*
- * @link http://www.php.net/manual/en/memcached.getresultmessage.php
+ * @link https://www.php.net/manual/en/memcached.getresultmessage.php
*
- * @return string Message describing the result of the last Memcached operation.
+ * @return string Message describing the result of the last Memcached operation.
*/
public function getResultMessage() {
return $this->m->getResultMessage();
}
/**
- * Get server information by key.
+ * Gets server information by key.
*
- * @link http://www.php.net/manual/en/memcached.getserverbykey.php
+ * @link https://www.php.net/manual/en/memcached.getserverbykey.php
*
- * @param string $server_key The key identifying the server to store the value on.
- * @return array Array with host, post, and weight on success, FALSE on failure.
+ * @param string $server_key The key identifying the server to store the value on.
+ * @return array Array with host, post, and weight on success, false on failure.
*/
public function getServerByKey( $server_key ) {
return $this->m->getServerByKey( $server_key );
}
/**
- * Get the list of servers in the pool.
+ * Gets the list of servers in the pool.
*
- * @link http://www.php.net/manual/en/memcached.getserverlist.php
+ * @link https://www.php.net/manual/en/memcached.getserverlist.php
*
- * @return array The list of all servers in the server pool.
+ * @return array The list of all servers in the server pool.
*/
public function getServerList() {
return $this->m->getServerList();
}
/**
- * Get server pool statistics.
+ * Gets server pool statistics.
*
- * @link http://www.php.net/manual/en/memcached.getstats.php
+ * @link https://www.php.net/manual/en/memcached.getstats.php
*
- * @return array Array of server statistics, one entry per server.
+ * @return array Array of server statistics, one entry per server.
*/
public function getStats() {
return $this->m->getStats();
}
/**
- * Get server pool memcached version information.
+ * Gets server pool memcached version information.
*
- * @link http://www.php.net/manual/en/memcached.getversion.php
+ * @link https://www.php.net/manual/en/memcached.getversion.php
*
- * @return array Array of server versions, one entry per server.
+ * @return array Array of server versions, one entry per server.
*/
public function getVersion() {
return $this->m->getVersion();
}
/**
- * Increment a numeric item's value.
+ * Increments a numeric item's value.
*
- * @link http://www.php.net/manual/en/memcached.increment.php
+ * @link https://www.php.net/manual/en/memcached.increment.php
*
- * @param string $key The key under which to store the value.
- * @param int $offset The amount by which to increment the item's value.
- * @param string $group The group value appended to the $key.
- * @return int|bool Returns item's new value on success or FALSE on failure.
+ * @param string $key The key under which to store the value.
+ * @param int $offset The amount by which to increment the item's value.
+ * @param string $group The group value appended to the $key.
+ * @return int|bool Item's new value on success, false on failure.
*/
public function increment( $key, $offset = 1, $group = 'default' ) {
$derived_key = $this->buildKey( $key, $group );
- // Increment values in no_mc_groups
+ // Increment values in no_mc_groups.
if ( in_array( $group, $this->no_mc_groups, true ) ) {
- // Only increment if the key already exists and the number is currently 0 or greater (mimics memcached behavior)
+ // Only increment if the key already exists and the number is currently 0 or greater (mimics memcached behavior).
if ( isset( $this->cache[ $derived_key ] ) && $this->cache[ $derived_key ] >= 0 ) {
- // If numeric, add; otherwise, consider it 0 and do nothing
+ // If numeric, add; otherwise, consider it 0 and do nothing.
if ( is_numeric( $this->cache[ $derived_key ] ) ) {
$this->cache[ $derived_key ] += (int) $offset;
} else {
$this->cache[ $derived_key ] = 0;
}
- // Returned value cannot be less than 0
+ // Returned value cannot be less than 0.
if ( $this->cache[ $derived_key ] < 0 ) {
$this->cache[ $derived_key ] = 0;
}
@@ -1636,40 +1651,41 @@ class WP_Object_Cache {
}
/**
- * Synonymous with $this->incr.
+ * Alias for $this->incr().
*
- * Certain plugins expect an "incr" method on the $wp_object_cache object (e.g., Batcache). Since the original
- * version of this library matched names to the memcached methods, the "incr" method was missing. Adding this
- * method restores compatibility with plugins expecting an "incr" method.
+ * Certain plugins expect an "incr" method on the $wp_object_cache object (e.g., Batcache).
+ * Since the original version of this library matched names to the memcached methods,
+ * the "incr" method was missing. Adding this method restores compatibility with plugins
+ * expecting an "incr" method.
*
- * @param string $key The key under which to store the value.
- * @param int $offset The amount by which to increment the item's value.
- * @param string $group The group value appended to the $key.
- * @return int|bool Returns item's new value on success or FALSE on failure.
+ * @param string $key The key under which to store the value.
+ * @param int $offset The amount by which to increment the item's value.
+ * @param string $group The group value appended to the $key.
+ * @return int|bool Item's new value on success, false on failure.
*/
public function incr( $key, $offset = 1, $group = 'default' ) {
return $this->increment( $key, $offset, $group );
}
/**
- * Prepend data to an existing item.
+ * Prepends data to an existing item.
*
* This method should throw an error if it is used with compressed data. This is an expected behavior.
- * Memcached casts the value to be prepended to the initial value to the type of the initial value. Be
- * careful as this leads to unexpected behavior at times. For instance, prepending (float) 45.23 to
- * (int) 23 will result in 45, because the value is first combined (45.2323) then cast to "integer"
+ * Memcached casts the value to be prepended to the initial value to the type of the initial value.
+ * Be careful as this leads to unexpected behavior at times. For instance, prepending (float) 45.23
+ * to (int) 23 will result in 45, because the value is first combined (45.2323) then cast to "integer"
* (the original value), which will be (int) 45. Due to how memcached treats types, the behavior has been
- * mimicked in the internal cache to produce similar results and improve consistency. It is recommend
+ * mimicked in the internal cache to produce similar results and improve consistency. It is recommended
* that prepends only occur with data of the same type.
*
- * @link http://www.php.net/manual/en/memcached.prepend.php
+ * @link https://www.php.net/manual/en/memcached.prepend.php
*
- * @param string $key The key under which to store the value.
- * @param string $value Must be string as prepending mixed values is not well-defined.
- * @param string $group The group value prepended to the $key.
- * @param string $server_key The key identifying the server to store the value on.
- * @param bool $by_key True to store in internal cache by key; false to not store by key
- * @return bool Returns TRUE on success or FALSE on failure.
+ * @param string $key The key under which to store the value.
+ * @param string $value Must be string as prepending mixed values is not well-defined.
+ * @param string $group The group value prepended to the $key.
+ * @param string $server_key The key identifying the server to store the value on.
+ * @param bool $by_key True to store in internal cache by key; false to not store by key.
+ * @return bool True on success, false on failure.
*/
public function prepend( $key, $value, $group = 'default', $server_key = '', $by_key = false ) {
if ( ! is_string( $value ) && ! is_int( $value ) && ! is_float( $value ) ) {
@@ -1678,7 +1694,7 @@ class WP_Object_Cache {
$derived_key = $this->buildKey( $key, $group );
- // If group is a non-Memcached group, prepend to runtime cache value, not Memcached
+ // If group is a non-Memcached group, prepend to runtime cache value, not Memcached.
if ( in_array( $group, $this->no_mc_groups, true ) ) {
if ( ! isset( $this->cache[ $derived_key ] ) ) {
return false;
@@ -1689,14 +1705,14 @@ class WP_Object_Cache {
return true;
}
- // Append to Memcached value
+ // Append to Memcached value.
if ( $by_key ) {
$result = $this->m->prependByKey( $server_key, $derived_key, $value );
} else {
$result = $this->m->prepend( $derived_key, $value );
}
- // Store in runtime cache if add was successful
+ // Store in runtime cache if add was successful.
if ( Memcached::RES_SUCCESS === $this->getResultCode() ) {
$combined = $this->combine_values( $this->cache[ $derived_key ], $value, 'pre' );
$this->add_to_internal_cache( $derived_key, $combined );
@@ -1706,23 +1722,23 @@ class WP_Object_Cache {
}
/**
- * Append data to an existing item by server key.
+ * Appends data to an existing item by server key.
*
* This method should throw an error if it is used with compressed data. This is an expected behavior.
- * Memcached casts the value to be prepended to the initial value to the type of the initial value. Be
- * careful as this leads to unexpected behavior at times. For instance, prepending (float) 45.23 to
- * (int) 23 will result in 45, because the value is first combined (45.2323) then cast to "integer"
+ * Memcached casts the value to be prepended to the initial value to the type of the initial value.
+ * Be careful as this leads to unexpected behavior at times. For instance, prepending (float) 45.23
+ * to (int) 23 will result in 45, because the value is first combined (45.2323) then cast to "integer"
* (the original value), which will be (int) 45. Due to how memcached treats types, the behavior has been
- * mimicked in the internal cache to produce similar results and improve consistency. It is recommend
+ * mimicked in the internal cache to produce similar results and improve consistency. It is recommended
* that prepends only occur with data of the same type.
*
- * @link http://www.php.net/manual/en/memcached.prependbykey.php
+ * @link https://www.php.net/manual/en/memcached.prependbykey.php
*
- * @param string $server_key The key identifying the server to store the value on.
- * @param string $key The key under which to store the value.
- * @param string $value Must be string as prepending mixed values is not well-defined.
- * @param string $group The group value prepended to the $key.
- * @return bool Returns TRUE on success or FALSE on failure.
+ * @param string $server_key The key identifying the server to store the value on.
+ * @param string $key The key under which to store the value.
+ * @param string $value Must be string as prepending mixed values is not well-defined.
+ * @param string $group The group value prepended to the $key.
+ * @return bool True on success, false on failure.
*/
public function prependByKey( $server_key, $key, $value, $group = 'default' ) {
return $this->prepend( $key, $value, $group, $server_key, true );
@@ -1731,27 +1747,27 @@ class WP_Object_Cache {
/**
* Replaces a value in cache.
*
- * This method is similar to "add"; however, is does not successfully set a value if
- * the object's key is not already set in cache.
+ * This method is similar to "add"; however, is does not successfully set a value
+ * if the object's key is not already set in cache.
*
- * @link http://www.php.net/manual/en/memcached.replace.php
+ * @link https://www.php.net/manual/en/memcached.replace.php
*
- * @param string $server_key The key identifying the server to store the value on.
- * @param string $key The key under which to store the value.
- * @param mixed $value The value to store.
- * @param string $group The group value appended to the $key.
- * @param bool $by_key True to store in internal cache by key; false to not store by key
- * @param int $expiration The expiration time, defaults to 0.
- * @return bool Returns TRUE on success or FALSE on failure.
+ * @param string $server_key The key identifying the server to store the value on.
+ * @param string $key The key under which to store the value.
+ * @param mixed $value The value to store.
+ * @param string $group The group value appended to the $key.
+ * @param bool $by_key True to store in internal cache by key; false to not store by key.
+ * @param int $expiration The expiration time, defaults to 0.
+ * @return bool True on success, false on failure.
*/
public function replace( $key, $value, $group = 'default', $expiration = 0, $server_key = '', $by_key = false ) {
$derived_key = $this->buildKey( $key, $group );
$expiration = $this->sanitize_expiration( $expiration );
- // If group is a non-Memcached group, save to runtime cache, not Memcached
+ // If group is a non-Memcached group, save to runtime cache, not Memcached.
if ( in_array( $group, $this->no_mc_groups, true ) ) {
- // Replace won't save unless the key already exists; mimic this behavior here
+ // Replace won't save unless the key already exists; mimic this behavior here.
if ( ! isset( $this->cache[ $derived_key ] ) ) {
return false;
}
@@ -1760,14 +1776,14 @@ class WP_Object_Cache {
return true;
}
- // Save to Memcached
+ // Save to Memcached.
if ( $by_key ) {
$result = $this->m->replaceByKey( $server_key, $derived_key, $value, $expiration );
} else {
$result = $this->m->replace( $derived_key, $value, $expiration );
}
- // Store in runtime cache if add was successful
+ // Store in runtime cache if add was successful.
if ( Memcached::RES_SUCCESS === $this->getResultCode() ) {
$this->add_to_internal_cache( $derived_key, $value );
}
@@ -1778,17 +1794,17 @@ class WP_Object_Cache {
/**
* Replaces a value in cache on a specific server.
*
- * This method is similar to "addByKey"; however, is does not successfully set a value if
- * the object's key is not already set in cache.
+ * This method is similar to "addByKey"; however, is does not successfully set a value
+ * if the object's key is not already set in cache.
*
- * @link http://www.php.net/manual/en/memcached.addbykey.php
+ * @link https://www.php.net/manual/en/memcached.addbykey.php
*
- * @param string $server_key The key identifying the server to store the value on.
- * @param string $key The key under which to store the value.
- * @param mixed $value The value to store.
- * @param string $group The group value appended to the $key.
- * @param int $expiration The expiration time, defaults to 0.
- * @return bool Returns TRUE on success or FALSE on failure.
+ * @param string $server_key The key identifying the server to store the value on.
+ * @param string $key The key under which to store the value.
+ * @param mixed $value The value to store.
+ * @param string $group The group value appended to the $key.
+ * @param int $expiration The expiration time, defaults to 0.
+ * @return bool True on success, false on failure.
*/
public function replaceByKey( $server_key, $key, $value, $group = 'default', $expiration = 0 ) {
return $this->replace( $key, $value, $group, $expiration, $server_key, true );
@@ -1799,34 +1815,34 @@ class WP_Object_Cache {
*
* The value is set whether or not this key already exists in memcached.
*
- * @link http://www.php.net/manual/en/memcached.set.php
+ * @link https://www.php.net/manual/en/memcached.set.php
*
- * @param string $key The key under which to store the value.
- * @param mixed $value The value to store.
- * @param string $group The group value appended to the $key.
- * @param int $expiration The expiration time, defaults to 0.
- * @param string $server_key The key identifying the server to store the value on.
- * @param bool $by_key True to store in internal cache by key; false to not store by key
- * @return bool Returns TRUE on success or FALSE on failure.
+ * @param string $key The key under which to store the value.
+ * @param mixed $value The value to store.
+ * @param string $group The group value appended to the $key.
+ * @param int $expiration The expiration time, defaults to 0.
+ * @param string $server_key The key identifying the server to store the value on.
+ * @param bool $by_key True to store in internal cache by key; false to not store by key.
+ * @return bool True on success, false on failure.
*/
public function set( $key, $value, $group = 'default', $expiration = 0, $server_key = '', $by_key = false ) {
$derived_key = $this->buildKey( $key, $group );
$expiration = $this->sanitize_expiration( $expiration );
- // If group is a non-Memcached group, save to runtime cache, not Memcached
+ // If group is a non-Memcached group, save to runtime cache, not Memcached.
if ( in_array( $group, $this->no_mc_groups, true ) ) {
$this->add_to_internal_cache( $derived_key, $value );
return true;
}
- // Save to Memcached
+ // Save to Memcached.
if ( $by_key ) {
$result = $this->m->setByKey( $server_key, $derived_key, $value, $expiration );
} else {
$result = $this->m->set( $derived_key, $value, $expiration );
}
- // Store in runtime cache if add was successful
+ // Store in runtime cache if add was successful.
if ( Memcached::RES_SUCCESS === $this->getResultCode() ) {
$this->add_to_internal_cache( $derived_key, $value );
}
@@ -1839,21 +1855,21 @@ class WP_Object_Cache {
*
* The value is set whether or not this key already exists in memcached.
*
- * @link http://www.php.net/manual/en/memcached.setbykey.php
+ * @link https://www.php.net/manual/en/memcached.setbykey.php
*
- * @param string $server_key The key identifying the server to store the value on.
- * @param string $key The key under which to store the value.
- * @param mixed $value The value to store.
- * @param string $group The group value appended to the $key.
- * @param int $expiration The expiration time, defaults to 0.
- * @return bool Returns TRUE on success or FALSE on failure.
+ * @param string $server_key The key identifying the server to store the value on.
+ * @param string $key The key under which to store the value.
+ * @param mixed $value The value to store.
+ * @param string $group The group value appended to the $key.
+ * @param int $expiration The expiration time, defaults to 0.
+ * @return bool True on success, false on failure.
*/
public function setByKey( $server_key, $key, $value, $group = 'default', $expiration = 0 ) {
return $this->set( $key, $value, $group, $expiration, $server_key, true );
}
/**
- * Set multiple values to cache at once.
+ * Sets multiple values to cache at once.
*
* By sending an array of $items to this function, all values are saved at once to
* memcached, reducing the need for multiple requests to memcached. The $items array
@@ -1861,42 +1877,42 @@ class WP_Object_Cache {
* are merged with the $groups array/string value via buildKeys to determine the
* final key for the object.
*
- * @link http://www.php.net/manual/en/memcached.setmulti.php
+ * @link https://www.php.net/manual/en/memcached.setmulti.php
*
- * @param array $items An array of key/value pairs to store on the server.
- * @param string|array $groups Group(s) to merge with key(s) in $items.
- * @param int $expiration The expiration time, defaults to 0.
- * @param string $server_key The key identifying the server to store the value on.
- * @param bool $by_key True to store in internal cache by key; false to not store by key
- * @return bool Returns TRUE on success or FALSE on failure.
+ * @param array $items An array of key/value pairs to store on the server.
+ * @param string|array $groups Group(s) to merge with key(s) in $items.
+ * @param int $expiration The expiration time, defaults to 0.
+ * @param string $server_key The key identifying the server to store the value on.
+ * @param bool $by_key True to store in internal cache by key; false to not store by key.
+ * @return bool True on success, false on failure.
*/
public function setMulti( $items, $groups = 'default', $expiration = 0, $server_key = '', $by_key = false ) {
- // Build final keys and replace $items keys with the new keys
+ // Build final keys and replace $items keys with the new keys.
$derived_keys = $this->buildKeys( array_keys( $items ), $groups );
$expiration = $this->sanitize_expiration( $expiration );
$derived_items = array_combine( $derived_keys, $items );
- // Do not add to memcached if in no_mc_groups
+ // Do not add to memcached if in no_mc_groups.
foreach ( $derived_items as $derived_key => $value ) {
- // Get the individual item's group
+ // Get the individual item's group.
$key_pieces = explode( ':', $derived_key );
- // If group is a non-Memcached group, save to runtime cache, not Memcached
+ // If group is a non-Memcached group, save to runtime cache, not Memcached.
if ( in_array( $key_pieces[1], $this->no_mc_groups, true ) ) {
$this->add_to_internal_cache( $derived_key, $value );
unset( $derived_items[ $derived_key ] );
}
}
- // Save to memcached
+ // Save to memcached.
if ( $by_key ) {
$result = $this->m->setMultiByKey( $server_key, $derived_items, $expiration );
} else {
$result = $this->m->setMulti( $derived_items, $expiration );
}
- // Store in runtime cache if add was successful
+ // Store in runtime cache if add was successful.
if ( Memcached::RES_SUCCESS === $this->getResultCode() ) {
$this->cache = array_merge( $this->cache, $derived_items );
}
@@ -1905,7 +1921,7 @@ class WP_Object_Cache {
}
/**
- * Set multiple values to cache at once on specified server.
+ * Sets multiple values to cache at once on specified server.
*
* By sending an array of $items to this function, all values are saved at once to
* memcached, reducing the need for multiple requests to memcached. The $items array
@@ -1913,26 +1929,26 @@ class WP_Object_Cache {
* are merged with the $groups array/string value via buildKeys to determine the
* final key for the object.
*
- * @link http://www.php.net/manual/en/memcached.setmultibykey.php
+ * @link https://www.php.net/manual/en/memcached.setmultibykey.php
*
- * @param string $server_key The key identifying the server to store the value on.
- * @param array $items An array of key/value pairs to store on the server.
- * @param string|array $groups Group(s) to merge with key(s) in $items.
- * @param int $expiration The expiration time, defaults to 0.
- * @return bool Returns TRUE on success or FALSE on failure.
+ * @param string $server_key The key identifying the server to store the value on.
+ * @param array $items An array of key/value pairs to store on the server.
+ * @param string|array $groups Group(s) to merge with key(s) in $items.
+ * @param int $expiration The expiration time, defaults to 0.
+ * @return bool True on success, false on failure.
*/
public function setMultiByKey( $server_key, $items, $groups = 'default', $expiration = 0 ) {
return $this->setMulti( $items, $groups, $expiration, $server_key, true );
}
/**
- * Set a Memcached option.
+ * Sets a Memcached option.
*
- * @link http://www.php.net/manual/en/memcached.setoption.php
+ * @link https://www.php.net/manual/en/memcached.setoption.php
*
- * @param int $option Option name.
- * @param mixed $value Option value.
- * @return bool Returns TRUE on success or FALSE on failure.
+ * @param int $option Option name.
+ * @param mixed $value Option value.
+ * @return bool True on success, false on failure.
*/
public function setOption( $option, $value ) {
return $this->m->setOption( $option, $value );
@@ -1941,12 +1957,14 @@ class WP_Object_Cache {
/**
* Builds a key for the cached object using the blog_id, key, and group values.
*
- * @author Ryan Boren This function is inspired by the original WP Memcached Object cache.
- * @link http://wordpress.org/extend/plugins/memcached/
+ * This function is inspired by the original WP Memcached Object cache.
+ *
+ * @author Ryan Boren
+ * @link http://wordpress.org/extend/plugins/memcached/
*
- * @param string $key The key under which to store the value.
- * @param string $group The group value appended to the $key.
- * @return string
+ * @param string $key The key under which to store the value.
+ * @param string $group The group value appended to the $key.
+ * @return string
*/
public function buildKey( $key, $group = 'default' ) {
if ( empty( $group ) ) {
@@ -1974,14 +1992,14 @@ class WP_Object_Cache {
* than $keys, the method will return an empty array. This method is primarily a helper method for methods
* that call memcached with an array of keys.
*
- * @param string|array $keys Key(s) to merge with group(s).
- * @param string|array $groups Group(s) to merge with key(s).
- * @return array Array that combines keys and groups into a single set of memcached keys.
+ * @param string|array $keys Key(s) to merge with group(s).
+ * @param string|array $groups Group(s) to merge with key(s).
+ * @return array Array that combines keys and groups into a single set of memcached keys.
*/
public function buildKeys( $keys, $groups = 'default' ) {
$derived_keys = array();
- // If strings sent, convert to arrays for proper handling
+ // If strings sent, convert to arrays for proper handling.
if ( ! is_array( $groups ) ) {
$groups = (array) $groups;
}
@@ -1990,13 +2008,14 @@ class WP_Object_Cache {
$keys = (array) $keys;
}
- // If we have equal numbers of keys and groups, merge $keys[n] and $group[n]
+ // If we have equal numbers of keys and groups, merge $keys[n] and $group[n].
if ( count( $keys ) === count( $groups ) ) {
for ( $i = 0; $i < count( $keys ); $i++ ) {
$derived_keys[] = $this->buildKey( $keys[ $i ], $groups[ $i ] );
}
- // If more keys are received than groups, merge $keys[n] and $group[n] until no more group are left; remaining groups are 'default'
+ // If more keys are received than groups, merge $keys[n] and $group[n]
+ // until no more groups are left; remaining groups are 'default'.
} elseif ( count( $keys ) > count( $groups ) ) {
for ( $i = 0; $i < count( $keys ); $i++ ) {
if ( isset( $groups[ $i ] ) ) {
@@ -2013,14 +2032,14 @@ class WP_Object_Cache {
}
/**
- * Ensure that a proper expiration time is set.
+ * Ensures that a proper expiration time is set.
*
- * Memcached treats any value over 30 days as a timestamp. If a developer sets the expiration for greater than 30
- * days or less than the current timestamp, the timestamp is in the past and the value isn't cached. This function
- * detects values in that range and corrects them.
+ * Memcached treats any value over 30 days as a timestamp. If a developer sets the expiration
+ * for greater than 30 days or less than the current timestamp, the timestamp is in the past
+ * and the value isn't cached. This function detects values in that range and corrects them.
*
- * @param string|int $expiration The dirty expiration time.
- * @return string|int The sanitized expiration time.
+ * @param string|int $expiration The dirty expiration time.
+ * @return string|int The sanitized expiration time.
*/
public function sanitize_expiration( $expiration ) {
if ( $expiration > $this->thirty_days && $expiration <= $this->now ) {
@@ -2037,22 +2056,22 @@ class WP_Object_Cache {
* by memcached. In both cases, whichever value is the original value in the combined value
* will dictate the type of the combined value.
*
- * @param mixed $original Original value that dictates the combined type.
- * @param mixed $pended Value to combine with original value.
- * @param string $direction Either 'pre' or 'app'.
- * @return mixed Combined value casted to the type of the first value.
+ * @param mixed $original Original value that dictates the combined type.
+ * @param mixed $pended Value to combine with original value.
+ * @param string $direction Either 'pre' or 'app'.
+ * @return mixed Combined value casted to the type of the first value.
*/
public function combine_values( $original, $pended, $direction ) {
$type = gettype( $original );
- // Combine the values based on direction of the "pend"
+ // Combine the values based on direction of the "pend".
if ( 'pre' === $direction ) {
$combined = $pended . $original;
} else {
$combined = $original . $pended;
}
- // Cast type of combined value
+ // Cast type of combined value.
settype( $combined, $type );
return $combined;
@@ -2061,8 +2080,8 @@ class WP_Object_Cache {
/**
* Simple wrapper for saving object to the internal cache.
*
- * @param string $derived_key Key to save value under.
- * @param mixed $value Object value.
+ * @param string $derived_key Key to save value under.
+ * @param mixed $value Object value.
*/
public function add_to_internal_cache( $derived_key, $value ) {
if ( is_object( $value ) ) {
@@ -2075,8 +2094,8 @@ class WP_Object_Cache {
/**
* Determines if a no_mc_group exists in a group of groups.
*
- * @param mixed $groups The groups to search.
- * @return bool True if a no_mc_group is present; false if a no_mc_group is not present.
+ * @param mixed $groups The groups to search.
+ * @return bool True if a no_mc_group is present; false if a no_mc_group is not present.
*/
public function contains_no_mc_group( $groups ) {
if ( is_scalar( $groups ) ) {
@@ -2097,13 +2116,15 @@ class WP_Object_Cache {
}
/**
- * Add global groups.
+ * Adds global groups.
*
- * @author Ryan Boren This function comes straight from the original WP Memcached Object cache
- * @link http://wordpress.org/extend/plugins/memcached/
+ * This function comes straight from the original WP Memcached Object cache.
*
- * @param array $groups Array of groups.
- * @return void
+ * @author Ryan Boren
+ * @link http://wordpress.org/extend/plugins/memcached/
+ *
+ * @param array $groups Array of groups.
+ * @return void
*/
public function add_global_groups( $groups ) {
if ( ! is_array( $groups ) ) {
@@ -2115,13 +2136,15 @@ class WP_Object_Cache {
}
/**
- * Add non-persistent groups.
+ * Adds non-persistent groups.
*
- * @author Ryan Boren This function comes straight from the original WP Memcached Object cache
- * @link http://wordpress.org/extend/plugins/memcached/
+ * This function comes straight from the original WP Memcached Object cache.
*
- * @param array $groups Array of groups.
- * @return void
+ * @author Ryan Boren
+ * @link http://wordpress.org/extend/plugins/memcached/
+ *
+ * @param array $groups Array of groups.
+ * @return void
*/
public function add_non_persistent_groups( $groups ) {
if ( ! is_array( $groups ) ) {
@@ -2133,11 +2156,11 @@ class WP_Object_Cache {
}
/**
- * Get a value specifically from the internal, run-time cache, not memcached.
+ * Gets a value specifically from the internal, run-time cache, not memcached.
*
- * @param int|string $key Key value.
- * @param int|string $group Group that the value belongs to.
- * @return bool|mixed Value on success; false on failure.
+ * @param int|string $key Key value.
+ * @param int|string $group Group that the value belongs to.
+ * @return bool|mixed Value on success, false on failure.
*/
public function get_from_runtime_cache( $key, $group ) {
$derived_key = $this->buildKey( $key, $group );
@@ -2150,9 +2173,9 @@ class WP_Object_Cache {
}
/**
- * Switch blog prefix, which changes the cache that is accessed.
+ * Switches blog prefix, which changes the cache that is accessed.
*
- * @param int $blog_id Blog to switch to.
+ * @param int $blog_id Blog to switch to.
* @return void
*/
public function switch_to_blog( $blog_id ) {