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 |
Property | Type | Description | |
---|---|---|---|
$daemon | Holds the cache daemon. | ||
$engine | Holds the cache engine. |
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. |
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 |
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. |
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. |
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. |
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. |
public addServers ( array $servers ) : boolean | ||
$servers | array | Array of server to register. |
return | boolean | True on success; false on failure. |
public add_global_groups ( array $groups ) : void | ||
$groups | array | Array of groups. |
return | void |
public add_non_persistent_groups ( array $groups ) : void | ||
$groups | array | Array of groups. |
return | void |
public add_to_internal_cache ( string $derived_key, mixed $value ) | ||
$derived_key | string | Key to save value under. |
$value | mixed | Object value. |
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. |
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. |
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. |
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. |
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. |
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. |
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. |
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. |
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. |
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. |
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. |
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. |
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. |
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. |
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. |
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. |
public getResultCode ( ) : integer | ||
return | integer | Result code of the last cache operation. |
public getResultMessage ( ) : string | ||
return | string | Message describing the result of the last cache operation. |
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. |
public getServerList ( ) : array | ||
return | array | The list of all servers in the server pool. |
public getVersion ( ) : array | ||
return | array | Array of server versions, one entry per server. |
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. |
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. |
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. |
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. |
public preserveOrder ( mixed $flags = null ) : boolean | ||
$flags | mixed | |
return | boolean |
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. |
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. |
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. |
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. |
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. |
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. |
public switch_to_blog ( integer $blog_id ) : void | ||
$blog_id | integer | Blog to switch to. |
return | void |
public string $blog_prefix | ||
return | string |
public string $cache_key_salt | ||
return | string |
public array $global_groups_extended | ||
return | array |
public string $global_prefix | ||
return | string |
public array $no_mc_groups | ||
return | array |
public type $no_remote_groups | ||
return | type |
public int $preserve_order | ||
return | integer |
public Memcached $servers_global | ||
return | Memcached |
public int $success_code | ||
return | integer |