PHP Class WP_Spider_Cache_Object_Base

WordPress's Object Cache is used to save on trips to the database. It stores all of the cache data to memory and makes the cache contents available by using a key, which is used to name and later retrieve cached data. This Object Cache replaces WordPress's built in runtime cache by placing it in the wp-content folder, and is loaded via wp-settings.php.
Show file Open project: stuttter/wp-spider-cache Class Usage Examples

Public Properties

Property Type Description
$blog_prefix string Prefix used for non-global groups.
$cache array Holds the non-cached objects.
$cache_key_salt string Salt to prefix all keys with
$daemon_class_name Holds the cache daemon class name.
$engine_class_name Holds the cache engine class name.
$global_groups array List of global groups.
$global_groups_extended array List of additionally supported, non-core, known, persistent, global cache-groups. This array is merged with $global_groups on construct.
$global_prefix string Prefix used for global groups.
$no_mc_groups array List of groups not saved to cache.
$no_remote_groups type List of groups to only look locally for
$preserve_order integer Should order be preserved?
$servers array Hold the server details.
$servers_fallback Holds the fallback servers.
$servers_global Memcached Holds the cache servers.
$success_code integer Result code that determines successful cache interaction

Protected Properties

Property Type Description
$daemon Holds the cache daemon.
$engine Holds the cache engine.

Public Methods

Method Description
__call ( $name, $args = [] )
__construct ( null $persistent_id = null ) Instantiate the class.
add ( string $key, mixed $value, string $group = 'default', integer $expiration, string $server_key = '', boolean $byKey = false ) : boolean Adds a value to cache.
addByKey ( string $server_key, string $key, mixed $value, string $group = 'default', integer $expiration ) : boolean Adds a value to cache on a specific server.
addServer ( string $host, integer $port, integer $weight ) : boolean Add a single server to the list of cache servers.
addServers ( array $servers ) : boolean Adds an array of servers to the pool.
add_global_groups ( array $groups ) : void Add global groups.
add_non_persistent_groups ( array $groups ) : void Add non-persistent groups.
add_to_internal_cache ( string $derived_key, mixed $value ) Simple wrapper for saving object to the internal cache.
append ( string $key, mixed $value, string $group = 'default', string $server_key = '', boolean $byKey = false ) : boolean Append data to an existing item.
appendByKey ( string $server_key, string $key, mixed $value, string $group = 'default' ) : boolean Append data to an existing item by server key.
buildKey ( string $key, string $group = 'default' ) : string Builds a key for the cached object using the blog_id, key, and group values.
buildKeys ( string | array $keys, string | array $groups = 'default' ) : array Creates an array of keys from passed key(s) and group(s).
cas ( float $cas_token, string $key, mixed $value, string $group = 'default', integer $expiration, string $server_key = '', boolean $byKey = false ) : boolean Performs a "check and set" to store data.
casByKey ( float $cas_token, string $server_key, string $key, mixed $value, string $group = 'default', integer $expiration ) : boolean Performs a "check and set" to store data with a server key.
close ( ) : boolean Close a cache server connection
combine_values ( mixed $original, mixed $pended, string $direction ) : mixed Concatenates two values and casts to type of the first value.
connect ( string $server = '127.0.0.1', integer $port = 11211 ) : boolean Connect directly to a cache server
contains_no_mc_group ( mixed $groups ) : boolean Determines if a no_mc_group exists in a group of groups.
decr ( string $key, integer $offset = 1, string $group = 'default' ) : integer | boolean Decrement a numeric item's value.
decrement ( string $key, integer $offset = 1, string $group = 'default' ) : integer | boolean Decrement a numeric item's value.
delete ( string $key, string $group = 'default', integer $time, string $server_key = '', boolean $byKey = false ) : boolean Remove the item from the cache.
deleteByKey ( string $server_key, string $key, string $group = 'default', integer $time ) : boolean Remove the item from the cache by server key.
fetch ( ) : array | boolean Fetch the next result.
fetchAll ( ) : array | boolean Fetch all remaining results from the last request.
flush ( integer $delay ) : boolean Invalidate all items in the cache.
get ( string $key, string $group = 'default', boolean $force = false, null | boolean &$found = null, string $server_key = '', boolean $byKey = false, null | callable $cache_cb = null, null | float &$cas_token = null ) : boolean | mixed Retrieve object from cache.
getByKey ( string $server_key, string $key, string $group = 'default', boolean $force = false, null | boolean &$found = null, null | string $cache_cb = null, null | float &$cas_token = null ) : boolean | mixed Retrieve object from cache from specified server.
getDelayed ( string | array $keys, string | array $groups = 'default', boolean $with_cas = false, null $value_cb = null ) : boolean Request multiple keys without blocking.
getDelayedByKey ( string $server_key, string | array $keys, string | array $groups = 'default', boolean $with_cas = false, null $value_cb = null ) : boolean Request multiple keys without blocking from a specified server.
getExtendedStats ( string $type, string $slab_id, integer $limit = 100 ) : array Get extended server pool statistics.
getMulti ( array $keys, string | array $groups = 'default', string $server_key = '', null | array &$cas_tokens = null, integer $flags = null ) : boolean | array Gets multiple values from cache daemon in one request.
getMultiByKey ( string $server_key, array $keys, string | array $groups = 'default', null | array &$cas_tokens = null, integer $flags = null ) : boolean | array Gets multiple values from cache daemon in one request by specified server key.
getOption ( integer $option ) : mixed Retrieve a daemon option value.
getResultCode ( ) : integer Return the result code of the last option.
getResultMessage ( ) : string Return the message describing the result of the last operation.
getServerByKey ( string $server_key ) : array Get server information by key.
getServerList ( ) : array Get the list of servers in the pool.
getStats ( ) : array Get server pool statistics.
getVersion ( ) : array Get server pool cache version information.
get_from_runtime_cache ( integer | string $key, integer | string $group ) : boolean | mixed Get a value specifically from the internal, run-time cache, not persistent cache.
incr ( string $key, integer $offset = 1, string $group = 'default' ) : integer | boolean Synonymous with $this->incr.
increment ( string $key, integer $offset = 1, string $group = 'default' ) : integer | boolean Increment a numeric item's value.
prepend ( string $key, string $value, string $group = 'default', string $server_key = '', boolean $byKey = false ) : boolean Prepend data to an existing item.
prependByKey ( string $server_key, string $key, string $value, string $group = 'default' ) : boolean Append data to an existing item by server key.
preserveOrder ( mixed $flags = null ) : boolean Should order of items be preserved
replace ( string $key, mixed $value, string $group = 'default', integer $expiration, string $server_key = '', boolean $byKey = false ) : boolean Replaces a value in cache.
replaceByKey ( string $server_key, string $key, mixed $value, string $group = 'default', integer $expiration ) : boolean Replaces a value in cache on a specific server.
sanitize_expiration ( string | integer $expiration ) : string | integer Ensure that a proper expiration time is set.
set ( string $key, mixed $value, string $group = 'default', integer $expiration, string $server_key = '', boolean $byKey = false ) : boolean Sets a value in cache.
setByKey ( string $server_key, string $key, mixed $value, string $group = 'default', integer $expiration ) : boolean Sets a value in cache on a specific server.
setMulti ( array $items, string | array $groups = 'default', integer $expiration, string $server_key = '', boolean $byKey = false ) : boolean Set multiple values to cache at once.
setMultiByKey ( string $server_key, array $items, string | array $groups = 'default', integer $expiration ) : boolean Set multiple values to cache at once on specified server.
setOption ( integer $option, mixed $value ) : boolean Set a cache engine option.
success ( ) : boolean Was the most recent result successful?
switch_to_blog ( integer $blog_id ) : void Switch blog prefix, which changes the cache that is accessed.

Private Methods

Method Description
set_daemon ( integer $persistent_id ) Set the daemon
set_engine ( ) Set the engine
set_prefixes ( ) Set global and site prefixes
set_salt ( ) This approach is borrowed from Sivel and Boren. Use the salt for easy cache invalidation and for multiple single WordPress installations on the same server.
set_servers ( ) Add servers

Method Details

__call() public method

public __call ( $name, $args = [] )

__construct() public method

Instantiates the class and returns adds the servers specified in the $memcached_servers global array.
public __construct ( null $persistent_id = null )
$persistent_id null To create an instance that persists between requests, use persistent_id to specify a unique ID for the instance.

add() public method

If the specified key already exists, the value is not stored and the function returns false.
public add ( string $key, mixed $value, string $group = 'default', integer $expiration, string $server_key = '', boolean $byKey = false ) : boolean
$key string The key under which to store the value.
$value mixed The value to store.
$group string The group value appended to the $key.
$expiration integer The expiration time, defaults to 0.
$server_key string The key identifying the server to store the value on.
$byKey boolean True to store in internal cache by key; false to not store by key
return boolean Returns true on success or false on failure.

addByKey() public method

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.
public addByKey ( string $server_key, string $key, mixed $value, string $group = 'default', integer $expiration ) : boolean
$server_key string The key identifying the server to store the value on.
$key string The key under which to store the value.
$value mixed The value to store.
$group string The group value appended to the $key.
$expiration integer The expiration time, defaults to 0.
return boolean Returns true on success or false on failure.

addServer() public method

Add a single server to the list of cache servers.
public addServer ( string $host, integer $port, integer $weight ) : boolean
$host string The hostname of the server.
$port integer The port on which is running.
$weight integer The weight of the server relative to the total weight of all the servers in the pool.
return boolean Returns true on success or false on failure.

addServers() public method

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 ) );
public addServers ( array $servers ) : boolean
$servers array Array of server to register.
return boolean True on success; false on failure.

add_global_groups() public method

Add global groups.
Author: Ryan Boren This function comes straight from the original Memcached plugin
public add_global_groups ( array $groups ) : void
$groups array Array of groups.
return void

add_non_persistent_groups() public method

Add non-persistent groups.
Author: Ryan Boren This function comes straight from the original Memcached plugin
public add_non_persistent_groups ( array $groups ) : void
$groups array Array of groups.
return void

add_to_internal_cache() public method

Simple wrapper for saving object to the internal cache.
public add_to_internal_cache ( string $derived_key, mixed $value )
$derived_key string Key to save value under.
$value mixed Object value.

append() public method

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.
public append ( string $key, mixed $value, string $group = 'default', string $server_key = '', boolean $byKey = false ) : boolean
$key string The key under which to store the value.
$value mixed Must be string as appending mixed values is not well-defined.
$group string The group value appended to the $key.
$server_key string The key identifying the server to store the value on.
$byKey boolean True to store in internal cache by key; false to not store by key
return boolean Returns true on success or false on failure.

appendByKey() public method

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.
public appendByKey ( string $server_key, string $key, mixed $value, string $group = 'default' ) : boolean
$server_key string The key identifying the server to store the value on.
$key string The key under which to store the value.
$value mixed Must be string as appending mixed values is not well-defined
$group string The group value appended to the $key.
return boolean Returns true on success or false on failure.

buildKey() public method

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 Memcached plugin.
public buildKey ( string $key, string $group = 'default' ) : string
$key string The key under which to store the value.
$group string The group value appended to the $key.
return string

buildKeys() public method

This function takes a string or array of key(s) and group(s) and combines them into a single dimensional array that merges the keys and groups. If the same number of keys and groups exist, the final keys will append $groups[n] to $keys[n]. If there are more keys than groups and the $groups parameter is an array, $keys[n] will be combined with $groups[n] until $groups runs out of values. 'default' will be used for remaining values. If $keys is an array and $groups is a string, all final values will append $groups to $keys[n]. If both values are strings, they will be combined into a single string. Note that if more $groups are received than $keys, the method will return an empty array. This method is primarily a helper method for methods that call cache with an array of keys.
public buildKeys ( string | array $keys, string | array $groups = 'default' ) : array
$keys string | array Key(s) to merge with group(s).
$groups string | array Group(s) to merge with key(s).
return array Array that combines keys and groups into a single set of cache keys.

cas() public method

The set will be successful only if the no other request has updated the value since it was fetched since this request.
public cas ( float $cas_token, string $key, mixed $value, string $group = 'default', integer $expiration, string $server_key = '', boolean $byKey = false ) : boolean
$cas_token float Unique value associated with the existing item. Generated by memcached.
$key string The key under which to store the value.
$value mixed The value to store.
$group string The group value appended to the $key.
$expiration integer The expiration time, defaults to 0.
$server_key string The key identifying the server to store the value on.
$byKey boolean True to store in internal cache by key; false to not store by key
return boolean Returns true on success or false on failure.

casByKey() public method

The set will be successful only if the no other request has updated the value since it was fetched by this request.
public casByKey ( float $cas_token, string $server_key, string $key, mixed $value, string $group = 'default', integer $expiration ) : boolean
$cas_token float Unique value associated with the existing item. Generated by memcached.
$server_key string The key identifying the server to store the value on.
$key string The key under which to store the value.
$value mixed The value to store.
$group string The group value appended to the $key.
$expiration integer The expiration time, defaults to 0.
return boolean Returns true on success or false on failure.

close() public method

Close a cache server connection
public close ( ) : boolean
return boolean Returns true on success or false on failure.

combine_values() public method

This is used in append and prepend operations to match how these functions are handled by cache. In both cases, whichever value is the original value in the combined value will dictate the type of the combined value.
public combine_values ( mixed $original, mixed $pended, string $direction ) : mixed
$original mixed Original value that dictates the combined type.
$pended mixed Value to combine with original value.
$direction string Either 'pre' or 'app'.
return mixed Combined value casted to the type of the first value.

connect() public method

Connect directly to a cache server
public connect ( string $server = '127.0.0.1', integer $port = 11211 ) : boolean
$server string The host where the daemon is listening for connections
$port integer The port where the daemon is listening for connections
return boolean Returns true on success or false on failure.

contains_no_mc_group() public method

Determines if a no_mc_group exists in a group of groups.
public contains_no_mc_group ( mixed $groups ) : boolean
$groups mixed The groups to search.
return boolean True if a no_mc_group is present; false if a no_mc_group is not present.

decr() public method

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.
public decr ( string $key, integer $offset = 1, string $group = 'default' ) : integer | boolean
$key string The key under which to store the value.
$offset integer The amount by which to decrement the item's value.
$group string The group value appended to the $key.
return integer | boolean Returns item's new value on success or false on failure.

decrement() public method

Decrement a numeric item's value.
public decrement ( string $key, integer $offset = 1, string $group = 'default' ) : integer | boolean
$key string The key under which to store the value.
$offset integer The amount by which to decrement the item's value.
$group string The group value appended to the $key.
return integer | boolean Returns item's new value on success or false on failure.

delete() public method

Remove an item from cache 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.
public delete ( string $key, string $group = 'default', integer $time, string $server_key = '', boolean $byKey = false ) : boolean
$key string The key under which to store the value.
$group string The group value appended to the $key.
$time integer The amount of time the server will wait to delete the item in seconds.
$server_key string The key identifying the server to store the value on.
$byKey boolean True to store in internal cache by key; false to not store by key
return boolean Returns true on success or false on failure.

deleteByKey() public method

Remove an item from cache 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.
public deleteByKey ( string $server_key, string $key, string $group = 'default', integer $time ) : boolean
$server_key string The key identifying the server to store the value on.
$key string The key under which to store the value.
$group string The group value appended to the $key.
$time integer The amount of time the server will wait to delete the item in seconds.
return boolean Returns true on success or false on failure.

fetch() public method

Fetch the next result.
public fetch ( ) : array | boolean
return array | boolean Returns the next result or false on failure.

fetchAll() public method

Fetch all remaining results from the last request.
public fetchAll ( ) : array | boolean
return array | boolean Returns the results or false on failure.

flush() public method

Invalidate all items in the cache.
public flush ( integer $delay ) : boolean
$delay integer Number of seconds to wait before invalidating the items.
return boolean Returns true on success or false on failure.

get() public method

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 cache 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.
public get ( string $key, string $group = 'default', boolean $force = false, null | boolean &$found = null, string $server_key = '', boolean $byKey = false, null | callable $cache_cb = null, null | float &$cas_token = null ) : boolean | mixed
$key string The key under which to store the value.
$group string The group value appended to the $key.
$force boolean Whether or not to force a cache invalidation.
$found null | boolean Variable passed by reference to determine if the value was found or not.
$server_key string The key identifying the server to store the value on.
$byKey boolean True to store in internal cache by key; false to not store by key
$cache_cb null | callable Read-through caching callback.
$cas_token null | float The variable to store the CAS token in.
return boolean | mixed Cached object value.

getByKey() public method

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 cache 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.
public getByKey ( string $server_key, string $key, string $group = 'default', boolean $force = false, null | boolean &$found = null, null | string $cache_cb = null, null | float &$cas_token = null ) : boolean | mixed
$server_key string The key identifying the server to store the value on.
$key string The key under which to store the value.
$group string The group value appended to the $key.
$force boolean Whether or not to force a cache invalidation.
$found null | boolean Variable passed by reference to determine if the value was found or not.
$cache_cb null | string Read-through caching callback.
$cas_token null | float The variable to store the CAS token in.
return boolean | mixed Cached object value.

getDelayed() public method

Request multiple keys without blocking.
public getDelayed ( string | array $keys, string | array $groups = 'default', boolean $with_cas = false, null $value_cb = null ) : boolean
$keys string | array Array or string of key(s) to request.
$groups string | array Array or string of group(s) for the key(s). See buildKeys for more on how these are handled.
$with_cas boolean Whether to request CAS token values also.
$value_cb null The result callback or null.
return boolean Returns true on success or false on failure.

getDelayedByKey() public method

Request multiple keys without blocking from a specified server.
public getDelayedByKey ( string $server_key, string | array $keys, string | array $groups = 'default', boolean $with_cas = false, null $value_cb = null ) : boolean
$server_key string The key identifying the server to store the value on.
$keys string | array Array or string of key(s) to request.
$groups string | array Array or string of group(s) for the key(s). See buildKeys for more on how these are handled.
$with_cas boolean Whether to request CAS token values also.
$value_cb null The result callback or null.
return boolean Returns true on success or false on failure.

getExtendedStats() public method

Get extended server pool statistics.
public getExtendedStats ( string $type, string $slab_id, integer $limit = 100 ) : array
$type string The type of statistics to retrieve
$slab_id string The name of the slab to retrieve
$limit integer
return array

getMulti() public method

See the buildKeys method definition to understand the $keys/$groups parameters.
public getMulti ( array $keys, string | array $groups = 'default', string $server_key = '', null | array &$cas_tokens = null, integer $flags = null ) : boolean | array
$keys array Array of keys to retrieve.
$groups string | array If string, used for all keys. If arrays, corresponds with the $keys array.
$server_key string The key identifying the server to store the value on.
$cas_tokens null | array The variable to store the CAS tokens for the found items.
$flags integer The flags for the get operation.
return boolean | array Returns the array of found items or false on failure.

getMultiByKey() public method

See the buildKeys method definition to understand the $keys/$groups parameters.
public getMultiByKey ( string $server_key, array $keys, string | array $groups = 'default', null | array &$cas_tokens = null, integer $flags = null ) : boolean | array
$server_key string The key identifying the server to store the value on.
$keys array Array of keys to retrieve.
$groups string | array If string, used for all keys. If arrays, corresponds with the $keys array.
$cas_tokens null | array The variable to store the CAS tokens for the found items.
$flags integer The flags for the get operation.
return boolean | array Returns the array of found items or false on failure.

getOption() public method

Retrieve a daemon option value.
public getOption ( integer $option ) : mixed
$option integer One of the Memcached::OPT_* constants.
return mixed Returns the value of the requested option, or false on error.

getResultCode() public method

Return the result code of the last option.
public getResultCode ( ) : integer
return integer Result code of the last cache operation.

getResultMessage() public method

Return the message describing the result of the last operation.
public getResultMessage ( ) : string
return string Message describing the result of the last cache operation.

getServerByKey() public method

Get server information by key.
public getServerByKey ( string $server_key ) : array
$server_key string The key identifying the server to store the value on.
return array Array with host, post, and weight on success, false on failure.

getServerList() public method

Get the list of servers in the pool.
public getServerList ( ) : array
return array The list of all servers in the server pool.

getStats() public method

Get server pool statistics.
public getStats ( ) : array
return array Array of server statistics, one entry per server.

getVersion() public method

Get server pool cache version information.
public getVersion ( ) : array
return array Array of server versions, one entry per server.

get_from_runtime_cache() public method

Get a value specifically from the internal, run-time cache, not persistent cache.
public get_from_runtime_cache ( integer | string $key, integer | string $group ) : boolean | mixed
$key integer | string Key value.
$group integer | string Group that the value belongs to.
return boolean | mixed Value on success; false on failure.

incr() public method

Certain plugins expect an "incr" method on the $wp_object_cache object (e.g., Spider-Cache). 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.
public incr ( string $key, integer $offset = 1, string $group = 'default' ) : integer | boolean
$key string The key under which to store the value.
$offset integer The amount by which to increment the item's value.
$group string The group value appended to the $key.
return integer | boolean Returns item's new value on success or false on failure.

increment() public method

Increment a numeric item's value.
public increment ( string $key, integer $offset = 1, string $group = 'default' ) : integer | boolean
$key string The key under which to store the value.
$offset integer The amount by which to increment the item's value.
$group string The group value appended to the $key.
return integer | boolean Returns item's new value on success or false on failure.

prepend() public method

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.
public prepend ( string $key, string $value, string $group = 'default', string $server_key = '', boolean $byKey = false ) : boolean
$key string The key under which to store the value.
$value string Must be string as prepending mixed values is not well-defined.
$group string The group value prepended to the $key.
$server_key string The key identifying the server to store the value on.
$byKey boolean True to store in internal cache by key; false to not store by key
return boolean Returns true on success or false on failure.

prependByKey() public method

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.
public prependByKey ( string $server_key, string $key, string $value, string $group = 'default' ) : boolean
$server_key string The key identifying the server to store the value on.
$key string The key under which to store the value.
$value string Must be string as prepending mixed values is not well-defined.
$group string The group value prepended to the $key.
return boolean Returns true on success or false on failure.

preserveOrder() public method

Should order of items be preserved
Since: 2.2.0
public preserveOrder ( mixed $flags = null ) : boolean
$flags mixed
return boolean

replace() public method

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.
public replace ( string $key, mixed $value, string $group = 'default', integer $expiration, string $server_key = '', boolean $byKey = false ) : boolean
$key string The key under which to store the value.
$value mixed The value to store.
$group string The group value appended to the $key.
$expiration integer The expiration time, defaults to 0.
$server_key string The key identifying the server to store the value on.
$byKey boolean True to store in internal cache by key; false to not store by key
return boolean Returns true on success or false on failure.

replaceByKey() public method

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.
public replaceByKey ( string $server_key, string $key, mixed $value, string $group = 'default', integer $expiration ) : boolean
$server_key string The key identifying the server to store the value on.
$key string The key under which to store the value.
$value mixed The value to store.
$group string The group value appended to the $key.
$expiration integer The expiration time, defaults to 0.
return boolean Returns true on success or false on failure.

sanitize_expiration() public method

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.
public sanitize_expiration ( string | integer $expiration ) : string | integer
$expiration string | integer The dirty expiration time.
return string | integer The sanitized expiration time.

set() public method

The value is set whether or not this key already exists in cache.
public set ( string $key, mixed $value, string $group = 'default', integer $expiration, string $server_key = '', boolean $byKey = false ) : boolean
$key string The key under which to store the value.
$value mixed The value to store.
$group string The group value appended to the $key.
$expiration integer The expiration time, defaults to 0.
$server_key string The key identifying the server to store the value on.
$byKey boolean True to store in internal cache by key; false to not store by key
return boolean Returns true on success or false on failure.

setByKey() public method

The value is set whether or not this key already exists in cache.
public setByKey ( string $server_key, string $key, mixed $value, string $group = 'default', integer $expiration ) : boolean
$server_key string The key identifying the server to store the value on.
$key string The key under which to store the value.
$value mixed The value to store.
$group string The group value appended to the $key.
$expiration integer The expiration time, defaults to 0.
return boolean Returns true on success or false on failure.

setMulti() public method

By sending an array of $items to this function, all values are saved at once to cache, reducing the need for multiple requests to cache. The $items array keys and values are what are stored to cache. The keys in the $items array are merged with the $groups array/string value via buildKeys to determine the final key for the object.
public setMulti ( array $items, string | array $groups = 'default', integer $expiration, string $server_key = '', boolean $byKey = false ) : boolean
$items array An array of key/value pairs to store on the server.
$groups string | array Group(s) to merge with key(s) in $items.
$expiration integer The expiration time, defaults to 0.
$server_key string The key identifying the server to store the value on.
$byKey boolean True to store in internal cache by key; false to not store by key
return boolean Returns true on success or false on failure.

setMultiByKey() public method

By sending an array of $items to this function, all values are saved at once to cache, reducing the need for multiple requests to cache. The $items array keys and values are what are stored to cache. The keys in the $items array are merged with the $groups array/string value via buildKeys to determine the final key for the object.
public setMultiByKey ( string $server_key, array $items, string | array $groups = 'default', integer $expiration ) : boolean
$server_key string The key identifying the server to store the value on.
$items array An array of key/value pairs to store on the server.
$groups string | array Group(s) to merge with key(s) in $items.
$expiration integer The expiration time, defaults to 0.
return boolean Returns true on success or false on failure.

setOption() public method

Set a cache engine option.
public setOption ( integer $option, mixed $value ) : boolean
$option integer Option name.
$value mixed Option value.
return boolean Returns true on success or false on failure.

success() public method

Was the most recent result successful?
public success ( ) : boolean
return boolean

switch_to_blog() public method

Switch blog prefix, which changes the cache that is accessed.
public switch_to_blog ( integer $blog_id ) : void
$blog_id integer Blog to switch to.
return void

Property Details

$blog_prefix public property

Prefix used for non-global groups.
public string $blog_prefix
return string

$cache public property

Holds the non-cached objects.
public array $cache
return array

$cache_key_salt public property

Salt to prefix all keys with
public string $cache_key_salt
return string

$daemon protected property

Holds the cache daemon.
protected $daemon

$daemon_class_name public property

Holds the cache daemon class name.
public $daemon_class_name

$engine protected property

Holds the cache engine.
protected $engine

$engine_class_name public property

Holds the cache engine class name.
public $engine_class_name

$global_groups public property

List of global groups.
public array $global_groups
return array

$global_groups_extended public property

List of additionally supported, non-core, known, persistent, global cache-groups. This array is merged with $global_groups on construct.
public array $global_groups_extended
return array

$global_prefix public property

Prefix used for global groups.
public string $global_prefix
return string

$no_mc_groups public property

List of groups not saved to cache.
public array $no_mc_groups
return array

$no_remote_groups public property

List of groups to only look locally for
public type $no_remote_groups
return type

$preserve_order public property

Should order be preserved?
public int $preserve_order
return integer

$servers public property

Hold the server details.
public array $servers
return array

$servers_fallback public property

Holds the fallback servers.
public $servers_fallback

$servers_global public property

Holds the cache servers.
public Memcached $servers_global
return Memcached

$success_code public property

Result code that determines successful cache interaction
public int $success_code
return integer