Title: Object cache
Author: WordPress VIP Documentation
Published: September 11, 2020
Last modified: July 22, 2025

---

 1. [Caching](https://docs.wpvip.com/caching/)
 2. Object cache

#  Object cache

The WordPress Object Cache is the second layer of caching that is encountered by
requests that pass through [the page cache](https://docs.wpvip.com/caching/page-cache/)
and are routed to the origin servers. The Object Cache can be used to store the 
results of routine or expensive operations in memory so that subsequent requests
can quickly access them. The Object Cache is commonly used for saving the results
of database queries, remote `HTTP` requests, and any other operations that may be
especially costly.

Each WordPress environment is provisioned with its own siloed Memcached cluster 
for persistently caching application-level data. The WordPress Object Cache is automatically
configured to use these instances so that cache operations are routed to memory 
instead of the database.

The best candidates for caching are any data that will take longer to make than 
it takes to retrieve from the cache, such as slow database queries and remote calls.
Keep in mind that cache operations are done over a local network, so there is some
latency. Doing many cache operations during a request can add significant response
time to the page.

Please note the following:

 * Cache entries must be kept under 1MB in size.
 * The hit rate for an environment’s object cache, as well as for its operations
   by type, can be reviewed in [the **Insights & Metrics** panel of the VIP Dashboard](https://docs.wpvip.com/performance/insights-metrics/).
 * A breakdown of the Object Cache operations on a page can be viewed in [the Object Cache panel of Query Monitor](https://docs.wpvip.com/performance/query-monitor/#3-object-cache),
   including the amount of time spent to retrieve the data and the total size of
   all objects currently stored in memory.

## Transients

[Transients](https://developer.wordpress.org/apis/transients/) are saved to the 
object cache on the VIP Platform instead of using the `wp_options` database table.
The **WordPress Transients API** can still be used. However, functions like `set_transient()`
and `get_transient()` are actually wrappers for their corresponding [`wp_cache_*` functions](https://developer.wordpress.org/reference/classes/wp_object_cache/#wp_cache_-functions)
such as `wp_set_cache()` and `wp_get_cache()`.

Transients can be managed using the `[wp transient](https://developer.wordpress.org/cli/commands/transient/)`
WP-CLI commands, as long as the the transient name is known. However the `[wp transient list](https://developer.wordpress.org/cli/commands/transient/list/)`
command [does not work as expected](https://github.com/wp-cli/cache-command/issues/61)
since it queries the database. Instead it will output an empty table and a warning.

Likewise, any plugins or custom code that query the database directly for transients
will fail to retrieve the transient.

## `wp_cache` functions

WordPress’ [`wp_cache_*` functions](https://developer.wordpress.org/reference/classes/wp_object_cache/#wp_cache_-functions)
can be used to add, set, get, delete, or replace cache objects in the persistent
storage managed by Memcached. Memcached will evict cache objects when they expire
or when the object cache is full.

Memcached employs a [Least Recently Used](https://memcached.org/blog/modern-lru/)(
LRU) algorithm to manage the cache storage. The LRU determines which object(s)—if
any—should be evicted from the object cache when a new object is being added.

The `wp_cache_add` and `wp_cache_set` functions default to no expiration. When a
cache object has no expiration, it will persist indefinitely until either evicted
by the LRU algorithm or when it is updated or deleted by another `wp_cache_*` function.

For more information about object caching in WordPress, review [WP Cache Functions in WordPress.org’s Developer Reference](https://developer.wordpress.org/reference/classes/wp_object_cache/#wp_cache-functions).

Last updated: July 22, 2025