PHP Class Cache_Command, wp-cli

Inheritance: extends WP_CLI_Command
Mostrar archivo Open project: wp-cli/wp-cli

Public Methods

Method Description
add ( $args, $assoc_args ) Add a value to the object cache.
decr ( $args, $assoc_args ) Decrement a value in the object cache.
delete ( $args, $assoc_args ) Remove a value from the object cache.
flush ( $args, $assoc_args ) Flush the object cache.
get ( $args, $assoc_args ) Get a value from the object cache.
incr ( $args, $assoc_args ) Increment a value in the object cache.
replace ( $args, $assoc_args ) Replace a value in the object cache, if the value already exists.
set ( $args, $assoc_args ) Set a value to the object cache, regardless of whether it already exists.
type ( $args, $assoc_args ) Attempts to determine which object cache is being used.

Method Details

add() public method

Errors if a value already exists for the key, which means the value can't be added. ## OPTIONS : Cache key. : Value to add to the key. [] : Method for grouping data within the cache which allows the same key to be used across groups. [] : Define how long to keep the value, in seconds. 0 means as long as possible. --- default: 0 --- ## EXAMPLES # Add cache. $ wp cache add my_key my_group my_value 300 Success: Added object 'my_key' in group 'my_value'.
public add ( $args, $assoc_args )

decr() public method

Errors if the value can't be decremented. ## OPTIONS : Cache key. [] : The amount by which to decrement the item's value. Default is 1. [] : Method for grouping data within the cache which allows the same key to be used across groups. ## EXAMPLES # Decrease cache value. $ wp cache decr my_key 2 my_group 48
public decr ( $args, $assoc_args )

delete() public method

Errors if the value can't be deleted. ## OPTIONS : Cache key. [] : Method for grouping data within the cache which allows the same key to be used across groups. ## EXAMPLES # Delete cache. $ wp cache delete my_key my_group Success: Object deleted.
public delete ( $args, $assoc_args )

flush() public method

For WordPress multisite instances using a persistent object cache, flushing the object cache will typically flush the cache for all sites. Beware of the performance impact when flushing the object cache in production. Errors if the object cache can't be flushed. ## EXAMPLES # Flush cache. $ wp cache flush Success: The cache was flushed.
public flush ( $args, $assoc_args )

get() public method

Errors if the value doesn't exist. ## OPTIONS : Cache key. [] : Method for grouping data within the cache which allows the same key to be used across groups. ## EXAMPLES # Get cache. $ wp cache get my_key my_group my_value
public get ( $args, $assoc_args )

incr() public method

Errors if the value can't be incremented. ## OPTIONS : Cache key. [] : The amount by which to increment the item's value. Default is 1. [] : Method for grouping data within the cache which allows the same key to be used across groups. ## EXAMPLES # Increase cache value. $ wp cache incr my_key 2 my_group 50
public incr ( $args, $assoc_args )

replace() public method

Errors if the value can't be replaced. ## OPTIONS : Cache key. : Value to replace. [] : Method for grouping data within the cache which allows the same key to be used across groups. [] : Define how long to keep the value, in seconds. 0 means as long as possible. --- default: 0 --- ## EXAMPLES # Replace cache. $ wp cache replace my_key new_value my_group Success: Replaced object 'my_key' in group 'my_group'.
public replace ( $args, $assoc_args )

set() public method

Errors if the value can't be set. ## OPTIONS : Cache key. : Value to set on the key. [] : Method for grouping data within the cache which allows the same key to be used across groups. [] : Define how long to keep the value, in seconds. 0 means as long as possible. --- default: 0 --- ## EXAMPLES # Set cache. $ wp cache set my_key my_value my_group 300 Success: Set object 'my_key' in group 'my_group'.
public set ( $args, $assoc_args )

type() public method

Note that the guesses made by this function are based on the WP_Object_Cache classes that define the 3rd party object cache extension. Changes to those classes could render problems with this function's ability to determine which object cache is being used. ## EXAMPLES # Check cache type. $ wp cache type Default
public type ( $args, $assoc_args )