Commit 2bc477bd authored by Erick Hitter's avatar Erick Hitter
Browse files

Remove methods held over from original Memcache plugin, but that aren't part...

Remove methods held over from original Memcache plugin, but that aren't part of Core's object cache implementation.

While some do have equivalents in Redis, others don't. For now, aim for something streamlined and the extras can come later.
parent bcb2fe9d
......@@ -18,77 +18,6 @@ function wp_cache_add( $key, $value, $group = '', $expiration = 0 ) {
return $wp_object_cache->add( $key, $value, $group, $expiration );
}
/**
* Adds a value to cache on a specific server.
*
* Using a server_key value, the object can be stored on a specified server as opposed
* to a random server in the stack. Note that this method will add the key/value to the
* _cache object as part of the runtime cache. It will add it to an array for the
* specified server_key.
*
* @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.
*/
function wp_cache_add_by_key( $server_key, $key, $value, $group = '', $expiration = 0 ) {
global $wp_object_cache;
return $wp_object_cache->addByKey( $server_key, $key, $value, $group, $expiration );
}
/**
* Append 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
* the same type.
*
* @link http://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.
*/
function wp_cache_append( $key, $value, $group = '' ) {
global $wp_object_cache;
return $wp_object_cache->append( $key, $value, $group );
}
/**
* Append 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
* the same type.
*
* @link http://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.
*/
function wp_cache_append_by_key( $server_key, $key, $value, $group = '' ) {
global $wp_object_cache;
return $wp_object_cache->appendByKey( $server_key, $key, $value, $group );
}
/**
* Closes the cache.
*
......@@ -162,53 +91,6 @@ function wp_cache_delete( $key, $group = '', $time = 0 ) {
return $wp_object_cache->delete( $key, $group, $time );
}
/**
* Remove 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.
*
* @link http://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.
*/
function wp_cache_delete_by_key( $server_key, $key, $group = '', $time = 0 ) {
global $wp_object_cache;
return $wp_object_cache->deleteByKey( $server_key, $key, $group, $time );
}
/**
* Fetch the next result.
*
* @link http://www.php.net/manual/en/memcached.fetch.php
*
* @return array|bool Returns the next result or FALSE otherwise.
*/
function wp_cache_fetch() {
global $wp_object_cache;
return $wp_object_cache->fetch();
}
/**
* Fetch all remaining results from the last request.
*
* @return array|bool Returns the results or FALSE on failure.
*/
function wp_cache_fetch_all() {
global $wp_object_cache;
return $wp_object_cache->fetchAll();
}
/**
* Invalidate all items in the cache.
*
......@@ -225,243 +107,28 @@ function wp_cache_flush( $delay = 0 ) {
/**
* 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 $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
* Gets an object from cache based on $key and $group.
*
* @param string $key The key under which to store the value.
* @param string $group The group value appended to the $key.
* @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 = '', $cache_cb = null, &$cas_token = null ) {
global $wp_object_cache;
/**
* Handles situations where the $force argument for the wp_cache_get function in core may be used. It is only
* used once in all of WP Core and since the function does not do anything with it, it is pointless to support.
* I'm catching the issue here to avoid conflicts.
*/
if ( true === $cache_cb )
$cache_cb = null;
if ( func_num_args() > 2 )
return $wp_object_cache->get( $key, $group, '', false, $cache_cb, $cas_token );
else
return $wp_object_cache->get( $key, $group );
}
/**
* 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 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 = '', $cache_cb = null, &$cas_token = null ) {
global $wp_object_cache;
if ( func_num_args() > 3 )
return $wp_object_cache->getByKey( $server_key, $key, $group, $cache_cb, $cas_token );
else
return $wp_object_cache->getByKey( $server_key, $key, $group );
}
/**
* Request multiple keys without blocking.
*
* @link http://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 build_keys 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.
*/
function wp_cache_get_delayed( $keys, $groups = '', $with_cas = false, $value_cb = null ) {
global $wp_object_cache;
return $wp_object_cache->getDelayed( $keys, $groups, $with_cas, $value_cb );
}
/**
* Request multiple keys without blocking from a specified server.
*
* @link http://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 build_keys 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.
*/
function wp_cache_get_delayed_by_key( $server_key, $keys, $groups = '', $with_cas = false, $value_cb = null ) {
global $wp_object_cache;
return $wp_object_cache->getDelayedByKey( $server_key, $keys, $groups, $with_cas, $value_cb );
}
/**
* Gets multiple values from memcached in one request.
*
* See the build_keys method definition to understand the $keys/$groups parameters.
*
* @link http://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.
*/
function wp_cache_get_multi( $keys, $groups = '', &$cas_tokens = null, $flags = null ) {
global $wp_object_cache;
if ( func_num_args() > 2 )
return $wp_object_cache->getMulti( $keys, $groups, '', $cas_tokens, $flags );
else
return $wp_object_cache->getMulti( $keys, $groups );
}
/**
* Gets multiple values from memcached in one request by specified server key.
*
* See the build_keys method definition to understand the $keys/$groups parameters.
*
* @link http://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.
*/
function wp_cache_get_multi_by_key( $server_key, $keys, $groups = '', &$cas_tokens = null, $flags = null ) {
global $wp_object_cache;
if ( func_num_args() > 3 )
return $wp_object_cache->getMultiByKey( $server_key, $keys, $groups, $cas_tokens, $flags );
else
return $wp_object_cache->getMultiByKey( $server_key, $keys, $groups );
}
/**
* Retrieve a Memcached option value.
*
* @link http://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.
*/
function wp_cache_get_option( $option ) {
global $wp_object_cache;
return $wp_object_cache->getOption( $option );
}
/**
* Return the result code of the last option.
*
* @link http://www.php.net/manual/en/memcached.getresultcode.php
*
* @return int Result code of the last Memcached operation.
*/
function wp_cache_get_result_code() {
global $wp_object_cache;
return $wp_object_cache->getResultCode();
}
/**
* Return the message describing the result of the last operation.
*
* @link http://www.php.net/manual/en/memcached.getresultmessage.php
*
* @return string Message describing the result of the last Memcached operation.
*/
function wp_cache_get_result_message() {
global $wp_object_cache;
return $wp_object_cache->getResultMessage();
}
/**
* Get server information by key.
*
* @link http://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.
*/
function wp_cache_get_server_by_key( $server_key ) {
function wp_cache_get( $key, $group = '' ) {
global $wp_object_cache;
return $wp_object_cache->getServerByKey( $server_key );
}
/**
* Get the list of servers in the pool.
*
* @link http://www.php.net/manual/en/memcached.getserverlist.php
*
* @return array The list of all servers in the server pool.
*/
function wp_cache_get_server_list() {
global $wp_object_cache;
return $wp_object_cache->getServerList();
return $wp_object_cache->get( $key, $group );
}
/**
* Get server pool statistics.
*
* @link http://www.php.net/manual/en/memcached.getstats.php
*
* @return array Array of server statistics, one entry per server.
*/
function wp_cache_get_stats() {
global $wp_object_cache;
return $wp_object_cache->getStats();
}
/**
* Get server pool memcached version information.
*
* @link http://www.php.net/manual/en/memcached.getversion.php
*
* @return array Array of server versions, one entry per server.
*/
function wp_cache_get_version() {
global $wp_object_cache;
return $wp_object_cache->getVersion();
return $wp_object_cache->stats();
}
/**
......@@ -499,57 +166,6 @@ function wp_cache_incr( $key, $offset = 1, $group = '' ) {
return wp_cache_increment( $key, $offset, $group );
}
/**
* Prepend 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"
* (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
* that prepends only occur with data of the same type.
*
* @link http://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.
*/
function wp_cache_prepend( $key, $value, $group = '' ) {
global $wp_object_cache;
return $wp_object_cache->prepend( $key, $value, $group );
}
/**
* Append 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"
* (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
* that prepends only occur with data of the same type.
*
* @link http://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.
*/
function wp_cache_prepend_by_key( $server_key, $key, $value, $group = '' ) {
global $wp_object_cache;
return $wp_object_cache->prependByKey( $server_key, $key, $value, $group );
}
/**
* Replaces a value in cache.
*
......@@ -571,28 +187,6 @@ function wp_cache_replace( $key, $value, $group = '', $expiration = 0 ) {
return $wp_object_cache->replace( $key, $value, $group, $expiration );
}
/**
* 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.
*
* @link http://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.
*/
function wp_cache_replace_by_key( $server_key, $key, $value, $group = '', $expiration = 0 ) {
global $wp_object_cache;
return $wp_object_cache->replaceByKey( $server_key, $key, $value, $group, $expiration );
}
/**
* Sets a value in cache.
*
......@@ -613,86 +207,6 @@ function wp_cache_set( $key, $value, $group = '', $expiration = 0 ) {
return $wp_object_cache->set( $key, $value, $group, $expiration );
}
/**
* Sets a value in cache.
*
* The value is set whether or not this key already exists in memcached.
*
* @link http://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.
*/
function wp_cache_set_by_key( $server_key, $key, $value, $group = '', $expiration = 0 ) {
global $wp_object_cache;
return $wp_object_cache->setByKey( $server_key, $key, $value, $group, $expiration );
}
/**
* Set 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
* keys and values are what are stored to memcached. The keys in the $items array
* are merged with the $groups array/string value via build_keys 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.
*/
function wp_cache_set_multi( $items, $groups = '', $expiration = 0 ) {
global $wp_object_cache;
return $wp_object_cache->setMulti( $items, $groups, $expiration );
}
/**
* Set 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
* keys and values are what are stored to memcached. The keys in the $items array
* are merged with the $groups array/string value via build_keys 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.
*/
function wp_cache_set_multi_by_key( $server_key, $items, $groups = 'default', $expiration = 0 ) {
global $wp_object_cache;
return $wp_object_cache->setMultiByKey( $server_key, $items, $groups, $expiration );
}
/**
* Set a Memcached option.
*
* @link http://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.
*/
function wp_cache_set_option( $option, $value ) {
global $wp_object_cache;
return $wp_object_cache->setOption( $option, $value );
}
/**
* Sets up Object Cache Global and assigns it.
*
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment