Object cache · 30 November 2026

Why a WordPress transient is not saving with a Redis object cache

You call set_transient(), it returns, and the next request finds nothing. With a persistent object cache there are five common reasons, and none of them raises an error. Work through them in this order.

By Shane Rounce · 5 minute read

The problem: the write returns and the value is gone

A transient is cached data with an expiry: the result of a remote lookup, a slow query, a rendered fragment. When one does not stick, the symptoms are indirect. A remote API is called on every page view. An admin screen stays slow. A cron job repeats work it should have done once.

Nothing fails loudly, because a missing transient is a normal state. WordPress simply builds the value again. So the first job is to prove whether the value is being stored at all.

The one test that settles it

Follow a single real transient from a write in one request to a read in another:

wp transient set arc_probe hello 300
wp transient get arc_probe

Then read it from the web side, signed out, with a temporary snippet in a must-use plugin:

add_action( 'template_redirect', function () {
    if ( isset( $_GET['probe'] ) ) {
        header( 'X-Probe: ' . var_export( get_transient( 'arc_probe' ), true ) );
    }
} );
curl -sI 'https://example.com/?probe=1' | grep -i x-probe

Now reverse it: write from a web request, read with WP-CLI. If all four directions work, your transient store is sound and the fault is in the code that uses it. If one direction fails, the list below tells you which cause to look at. Remove the snippet when you have finished.

Cause 1: you are looking in the wrong place

Without a persistent object cache, transients live in the wp_options table. With one, they live in the object cache and are never written to the database. Searching wp_options for _transient_ and finding nothing does not mean the transient was lost.

wp cache type

If that names your Redis drop-in, look in Redis, not MySQL.

Cause 2: the value is too big

Object caches protect Redis with a maximum value size. In Ace Redis Cache the default is 65536 bytes, and 32768 on a shop. A larger value is not stored. The call returns, and the next read is a miss.

Check the size of what you are saving:

wp eval 'echo strlen( maybe_serialize( my_expensive_thing() ) ), PHP_EOL;'

If it is over the limit, compress it, split it, or store it as a file. I go through those options in how long should a Redis key live.

Cause 3: the request type is not allowed to persist

A careful object cache does not let every request write shared data. Signed-in, admin and basket requests can hold values that are wrong for everyone else, so they are often kept to an in-request cache that vanishes when the request ends.

That is right for personal state and wrong for reusable background data. A version check fetched during an admin request is the same for everybody, and throwing it away means fetching it again on the next admin page.

These are two separate decisions and they should be made separately. ARC keeps transients shared even on admin and signed-in requests, subject to its exclusions and size checks, while still keeping session state out of Redis. If you maintain your own drop-in, narrow the allowance to the groups that are truly shared instead of opening everything.

Cause 4: command-line PHP and web PHP do not agree

Cron jobs and WP-CLI often run a different PHP from the one that serves pages: a different version, a different configuration file, different extensions. Two things go wrong.

  • They do not reach the same Redis. Compare wp eval 'var_dump( wp_using_ext_object_cache() );' with the same check on the web side.
  • They write different formats. If the cache picks a serialiser by what is installed, and one side has an extension the other lacks, each side writes values the other cannot read. The key is there. The value is unreadable, so it is treated as a miss.
php --version
php --ini
php -m | grep -i -E 'redis|igbinary'

Run those as the user and with the binary your scheduler really uses. A shell's default php tells you about that shell only.

The lasting fix is to choose the format deliberately. ARC's object cache uses PHP's own serialisation on every runtime and wraps each value in a versioned envelope, so a value in a format it does not recognise is a clean miss and is rebuilt, never half read.

Cause 5: false means two things

get_transient() returns false for "nothing stored". If the value you cached is itself false, an empty result from an API for instance, every read looks like a miss and the expensive call runs every time.

Store something that cannot be confused with a miss:

$found = get_transient( 'lookup_' . $id );
if ( false === $found ) {
    $result = my_remote_lookup( $id );
    set_transient( 'lookup_' . $id, [ 'value' => $result ], HOUR_IN_SECONDS );
} else {
    $result = $found['value'];
}

Two things that are not faults

  • A transient can go early. The expiry is a maximum. Redis may evict a key under memory pressure, and a cache flush removes it. Code that uses a transient must always be able to rebuild it.
  • A long expiry may be shortened. A cache with a lifetime cap stores a week-long transient for less. That is deliberate, and anything still in use is simply stored again.

Quick reference

SymptomLikely causeCheck
Not in wp_optionsA persistent object cache is activewp cache type
Works for small values onlyValue size limitMeasure the serialised size
Set in wp-admin, gone on the next pageAdmin requests do not persistThe four-way test above
Cron writes it, the site cannot read itDifferent PHP or serialiserphp --ini and php -m on both sides
The remote call runs every timeThe cached value is falseWrap the value in an array

For how transients fit with the rest of the object cache, see page cache and object cache. The object cache wiki page lists the groups ARC keeps in Redis, and troubleshooting covers the drop-in itself. Common questions are answered on the questions page.

All notes Get the latest release