wp cache

In this article we are going to learn how to use WP cache command.

By default, the WP Object Cache exists in PHP memory for the length of the request (and is emptied at the end).

Commands List Commands List

wp cache add <key> <value> [<group>] [<expiration>]
wp cache decr <key> [<offset>] [<group>]
wp cache delete <key> [<group>]
wp cache flush
wp cache get <key> [<group>]
wp cache incr <key> [<offset>] [<group>]
wp cache replace <key> <value> [<group>] [<expiration>]
wp cache set <key> <value> [<group>] [<expiration>]
wp cache type

Use a persistent object cache drop-in to persist the object cache between requests.

Read the codex article for more detail.

EXAMPLES EXAMPLES

# Set cache.
$ wp cache set my_key my_value my_group 300
Success: Set object 'my_key' in group 'my_group'.

# Get cache.
$ wp cache get my_key my_group
my_value

Top ↑

SUBCOMMANDS SUBCOMMANDS

Name Description
wp cache add

Adds a value to the object cache.

wp cache decr

Decrements a value in the object cache.

wp cache delete

Removes a value from the object cache.

wp cache flush

Flushes the object cache.

wp cache get

Gets a value from the object cache.

wp cache incr

Increments a value in the object cache.

wp cache replace

Replaces a value in the object cache, if the value already exists.

wp cache set

Sets a value to the object cache, regardless of whether it already exists.

wp cache type

Attempts to determine which object cache is being used.

Scroll to Top
%d bloggers like this: