PHP Класс 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.
Показать файл Открыть проект Примеры использования класса

Открытые свойства

Свойство Тип Описание
$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)

Свойство Тип Описание
$daemon Holds the cache daemon.
$engine Holds the cache engine.

Открытые методы

Метод Описание
__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.

Приватные методы

Метод Описание
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

Описание методов

__call() публичный Метод

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

__construct() публичный Метод

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() публичный Метод

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
Результат boolean Returns true on success or false on failure.

addByKey() публичный Метод

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.
Результат boolean Returns true on success or false on failure.

addServer() публичный Метод

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.
Результат boolean Returns true on success or false on failure.

addServers() публичный Метод

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.
Результат boolean True on success; false on failure.

add_global_groups() публичный Метод

Add global groups.
Автор: Ryan Boren This function comes straight from the original Memcached plugin
public add_global_groups ( array $groups ) : void
$groups array Array of groups.
Результат void

add_non_persistent_groups() публичный Метод

Add non-persistent groups.
Автор: Ryan Boren This function comes straight from the original Memcached plugin
public add_non_persistent_groups ( array $groups ) : void
$groups array Array of groups.
Результат void

add_to_internal_cache() публичный Метод

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() публичный Метод

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
Результат boolean Returns true on success or false on failure.

appendByKey() публичный Метод

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.
Результат boolean Returns true on success or false on failure.

buildKey() публичный Метод

Builds a key for the cached object using the blog_id, key, and group values.
Автор: 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.
Результат string

buildKeys() публичный Метод

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).
Результат array Array that combines keys and groups into a single set of cache keys.

cas() публичный Метод

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
Результат boolean Returns true on success or false on failure.

casByKey() публичный Метод

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.
Результат boolean Returns true on success or false on failure.

close() публичный Метод

Close a cache server connection
public close ( ) : boolean
Результат boolean Returns true on success or false on failure.

combine_values() публичный Метод

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'.
Результат mixed Combined value casted to the type of the first value.

connect() публичный Метод

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
Результат boolean Returns true on success or false on failure.

contains_no_mc_group() публичный Метод

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.
Результат boolean True if a no_mc_group is present; false if a no_mc_group is not present.

decr() публичный Метод

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.
Результат integer | boolean Returns item's new value on success or false on failure.

decrement() публичный Метод

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.
Результат integer | boolean Returns item's new value on success or false on failure.

delete() публичный Метод

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
Результат boolean Returns true on success or false on failure.

deleteByKey() публичный Метод

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.
Результат boolean Returns true on success or false on failure.

fetch() публичный Метод

Fetch the next result.
public fetch ( ) : array | boolean
Результат array | boolean Returns the next result or false on failure.

fetchAll() публичный Метод

Fetch all remaining results from the last request.
public fetchAll ( ) : array | boolean
Результат array | boolean Returns the results or false on failure.

flush() публичный Метод

Invalidate all items in the cache.
public flush ( integer $delay ) : boolean
$delay integer Number of seconds to wait before invalidating the items.
Результат boolean Returns true on success or false on failure.

get() публичный Метод

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.
Результат boolean | mixed Cached object value.

getByKey() публичный Метод

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.
Результат boolean | mixed Cached object value.

getDelayed() публичный Метод

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.
Результат boolean Returns true on success or false on failure.

getDelayedByKey() публичный Метод

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.
Результат boolean Returns true on success or false on failure.

getExtendedStats() публичный Метод

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
Результат array

getMulti() публичный Метод

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.
Результат boolean | array Returns the array of found items or false on failure.

getMultiByKey() публичный Метод

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.
Результат boolean | array Returns the array of found items or false on failure.

getOption() публичный Метод

Retrieve a daemon option value.
public getOption ( integer $option ) : mixed
$option integer One of the Memcached::OPT_* constants.
Результат mixed Returns the value of the requested option, or false on error.

getResultCode() публичный Метод

Return the result code of the last option.
public getResultCode ( ) : integer
Результат integer Result code of the last cache operation.

getResultMessage() публичный Метод

Return the message describing the result of the last operation.
public getResultMessage ( ) : string
Результат string Message describing the result of the last cache operation.

getServerByKey() публичный Метод

Get server information by key.
public getServerByKey ( string $server_key ) : array
$server_key string The key identifying the server to store the value on.
Результат array Array with host, post, and weight on success, false on failure.

getServerList() публичный Метод

Get the list of servers in the pool.
public getServerList ( ) : array
Результат array The list of all servers in the server pool.

getStats() публичный Метод

Get server pool statistics.
public getStats ( ) : array
Результат array Array of server statistics, one entry per server.

getVersion() публичный Метод

Get server pool cache version information.
public getVersion ( ) : array
Результат array Array of server versions, one entry per server.

get_from_runtime_cache() публичный Метод

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.
Результат boolean | mixed Value on success; false on failure.

incr() публичный Метод

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.
Результат integer | boolean Returns item's new value on success or false on failure.

increment() публичный Метод

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.
Результат integer | boolean Returns item's new value on success or false on failure.

prepend() публичный Метод

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
Результат boolean Returns true on success or false on failure.

prependByKey() публичный Метод

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.
Результат boolean Returns true on success or false on failure.

preserveOrder() публичный Метод

Should order of items be preserved
С версии: 2.2.0
public preserveOrder ( mixed $flags = null ) : boolean
$flags mixed
Результат boolean

replace() публичный Метод

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
Результат boolean Returns true on success or false on failure.

replaceByKey() публичный Метод

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.
Результат boolean Returns true on success or false on failure.

sanitize_expiration() публичный Метод

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.
Результат string | integer The sanitized expiration time.

set() публичный Метод

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
Результат boolean Returns true on success or false on failure.

setByKey() публичный Метод

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.
Результат boolean Returns true on success or false on failure.

setMulti() публичный Метод

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
Результат boolean Returns true on success or false on failure.

setMultiByKey() публичный Метод

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.
Результат boolean Returns true on success or false on failure.

setOption() публичный Метод

Set a cache engine option.
public setOption ( integer $option, mixed $value ) : boolean
$option integer Option name.
$value mixed Option value.
Результат boolean Returns true on success or false on failure.

success() публичный Метод

Was the most recent result successful?
public success ( ) : boolean
Результат boolean

switch_to_blog() публичный Метод

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.
Результат void

Описание свойств

$blog_prefix публичное свойство

Prefix used for non-global groups.
public string $blog_prefix
Результат string

$cache публичное свойство

Holds the non-cached objects.
public array $cache
Результат array

$cache_key_salt публичное свойство

Salt to prefix all keys with
public string $cache_key_salt
Результат string

$daemon защищенное свойство

Holds the cache daemon.
protected $daemon

$daemon_class_name публичное свойство

Holds the cache daemon class name.
public $daemon_class_name

$engine защищенное свойство

Holds the cache engine.
protected $engine

$engine_class_name публичное свойство

Holds the cache engine class name.
public $engine_class_name

$global_groups публичное свойство

List of global groups.
public array $global_groups
Результат array

$global_groups_extended публичное свойство

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
Результат array

$global_prefix публичное свойство

Prefix used for global groups.
public string $global_prefix
Результат string

$no_mc_groups публичное свойство

List of groups not saved to cache.
public array $no_mc_groups
Результат array

$no_remote_groups публичное свойство

List of groups to only look locally for
public type $no_remote_groups
Результат type

$preserve_order публичное свойство

Should order be preserved?
public int $preserve_order
Результат integer

$servers публичное свойство

Hold the server details.
public array $servers
Результат array

$servers_fallback публичное свойство

Holds the fallback servers.
public $servers_fallback

$servers_global публичное свойство

Holds the cache servers.
public Memcached $servers_global
Результат Memcached

$success_code публичное свойство

Result code that determines successful cache interaction
public int $success_code
Результат integer