Title: wp cache
Published: February 5, 2018
Last modified: June 23, 2026

---

# 󠀁[wp cache <command>](https://developer.wordpress.org/cli/commands/cache/)󠁿

Adds, removes, fetches, and flushes the WP Object Cache object.

## In this article

 * [Examples](https://developer.wordpress.org/cli/commands/cache/?output_format=md#examples)
 * [Subcommands](https://developer.wordpress.org/cli/commands/cache/?output_format=md#subcommands)

[ Back to top](https://developer.wordpress.org/cli/commands/cache/?output_format=md#wp--skip-link--target)

 [ ⌊GitHub⌉ ](https://github.com/wp-cli/cache-command)

 [ View Open Issues (0) ](https://github.com/login?return_to=%2Fissues%3Fq%3Dlabel%3Acommand%3Acache+sort%3Aupdated-desc+org%3Awp-cli+is%3Aopen)
[ View Closed Issues (35) ](https://github.com/login?return_to=%2Fissues%3Fq%3Dlabel%3Acommand%3Acache+sort%3Aupdated-desc+org%3Awp-cli+is%3Aclosed)
[Create New Issue](https://github.com/wp-cli/cache-command/issues/new)

By default, the WP Object Cache exists in PHP memory for the length of the request(
and is emptied at the end). Use a persistent object cache drop-in to persist the
object cache between requests. [Read the codex article](https://developer.wordpress.org/reference/classes/wp_object_cache)
for more detail.

### 󠀁[Examples](https://developer.wordpress.org/cli/commands/cache/?output_format=md#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
    ```

### 󠀁[Subcommands](https://developer.wordpress.org/cli/commands/cache/?output_format=md#subcommands)󠁿

| Name | Description | 
| [wp cache add](https://developer.wordpress.org/cli/commands/cache/add/) |

Adds a value to the object cache.

  | 
| [wp cache decr](https://developer.wordpress.org/cli/commands/cache/decr/) |

Decrements a value in the object cache.

  | 
| [wp cache delete](https://developer.wordpress.org/cli/commands/cache/delete/) |

Removes a value from the object cache.

  | 
| [wp cache flush](https://developer.wordpress.org/cli/commands/cache/flush/) |

Flushes the object cache.

  | 
| [wp cache flush-group](https://developer.wordpress.org/cli/commands/cache/flush-group/) |

Removes all cache items in a group, if the object cache implementation supports it.

  | 
| [wp cache get](https://developer.wordpress.org/cli/commands/cache/get/) |

Gets a value from the object cache.

  | 
| [wp cache incr](https://developer.wordpress.org/cli/commands/cache/incr/) |

Increments a value in the object cache.

  | 
| [wp cache patch](https://developer.wordpress.org/cli/commands/cache/patch/) |

Update a nested value from the cache.

  | 
| [wp cache pluck](https://developer.wordpress.org/cli/commands/cache/pluck/) |

Get a nested value from the cache.

  | 
| [wp cache replace](https://developer.wordpress.org/cli/commands/cache/replace/) |

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

  | 
| [wp cache set](https://developer.wordpress.org/cli/commands/cache/set/) |

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

  | 
| [wp cache supports](https://developer.wordpress.org/cli/commands/cache/supports/) |

Determines whether the object cache implementation supports a particular feature.

  | 
| [wp cache type](https://developer.wordpress.org/cli/commands/cache/type/) |

Attempts to determine which object cache is being used.

  |

 _Command documentation is regenerated at every release. To add or update an example,
please submit a pull request against the corresponding part of the codebase._