Skip to main content

wp cache get

Overview

Retrieve a single cached value by its key and group. Use this to inspect what WordPress has stored in memory for a specific cache entry — invaluable for debugging stale data, plugin caching behavior, and verifying cache warming.

What It Does

wp cache get calls wp_cache_get() and outputs the stored value. If the key doesn't exist, it returns a "no cache key found" error.

Syntax

wp cache get <key> [<group>]

Arguments

ArgumentDescription
KEYThe cache key to retrieve
GROUPCache group (namespace) — optional, defaults to default

Basic Usage

Get a cached option value

wp cache get alloptions options

Get from the default group

wp cache get my_custom_cache_key

Get a post cache entry

wp cache get 42 posts

Common Cache Groups

GroupHolds
optionsWordPress options (alloptions, etc.)
postsPost objects by ID
usersUser objects
termsTerm objects
transientTransient values
site-transientNetwork-wide transients
countsComment/post counts

Real-World Scenarios

Scenario 1: Inspect if a plugin's cache entry exists

wp cache get "woocommerce_product_count" "counts"

Scenario 2: Debug stale options

# Check if alloptions is cached
wp cache get alloptions options
# If value shows old URL → cache is stale → flush
wp cache flush

Scenario 3: Verify a custom cache key after setting

wp cache set my_key "hello world" default 3600
wp cache get my_key default
# Output: hello world

Troubleshooting

ProblemCauseFix
Error: Object cache returned a non-boolean valueCache missKey doesn't exist yet — check if it was set
Output is emptyCache expired or no persistent backendCheck wp cache type
Returns stale dataCache not flushed after updateRun wp cache flush

Quick Reference

wp cache get <key>                   # Default group
wp cache get <key> <group> # Specific group
wp cache get alloptions options # Inspect options cache

Next Steps