You are using transient API which works storing data on wp_options
table by default. That means that additional database queries will be performed to set the transient and to get the transient. With your code the number of queries should be less for non-logged in users in second and subsequent visits when the transient exists and it is valid.
If you use a persistent cache plugin (or you configure persistent cache at your own) the transient API will use WP_Object_Cache allowing the cached data be stored in memory instead of database, so there won’t be extra database queries.
Summary: using wp_cache functions will store cached data on memory and it is not persistent by default. In the other hand, transient API is persistent always and it use database by default. If you configure persistent cache, transient API and WP_Object_Cache return same results as transient API will use WP_Object_Cache.
Related Posts:
- Should I use Transient API to store HTML String, or Object?
- Using a wildcard with delete_transient()
- How to purge all transient caches?
- Transient / object cache maximum key length [duplicate]
- How to purge all transient caches?
- Transients are not expiring as expected in simple custom plugin
- How to store or cache custom shopping cart data for every user’s session
- How to decode wordpress transient cache stored in database?
- Hook an action when a transient is deleted ? Can’t get it to work!
- After having installed APC Object Cache Backend transients stopped working
- Should I use transients for these API call results?
- How to create a transient that persists the data for the whole duration of the expiration, even when object cache is enabled?
- W3 total cache – cache refresh programmatically [closed]
- How does object caching work?
- Caching: APC vs APCu vs OPcache
- Best way to show Dynamic Content on a Cached WordPress Site?
- Is define(‘WP_CACHE’, true) needed for object caching?
- Prevent WordPress from sending Cache-control http header
- Optimize apache for WP use
- Is get_option() faster than accessing get_transient()?
- Cache remote (HTTP) request with Transients API
- Is there any danger in deleting all transients?
- Pros and Cons for high “expire time” on wp-super-cache or w3-total-cache? [closed]
- Limit cache size from W3 Total Cache [closed]
- Best practices for using the transients API
- Does a query executed through wpdb class get cached?
- Using transients in conjunction with memcached
- Configuring WordPress for Amazon CloudFront Caching?
- Caching: Force fresh content for logged-in users (potentially by adding a query variable to the URL)
- Multiple WordPress sites eat up alot of RAM
- What exactly is an advanced object cache?
- Storing posts social counters by using transient api
- Will I see a performance hit if I use native API calls like get_the_title() instead of $post->post_title?
- WordPress Browser Cache with W3-Total-Cache doesn’t show new posts [closed]
- Nginx + WordPress + HHVM: Why isn’t Batcache working? Would Varnish help even more?
- Does a low traffic WordPress site need a caching plugin and a CDN
- Automatically Refresh WordPress Stylesheet
- wp_cache_set() or wp_cache_add()
- How to use cache with simplepie
- Can I force get_option to go back to the DB instead of cache?
- WordPress transients for a shortcode
- Which WordPress pages/URLs should never be cached?
- How to archive a wordpress site (make it read only)
- Stale cache handling with a persistent object cache
- Is priming a Transient Cache possible?
- Varnish + W3 Total Page Cache [closed]
- Are there any server requirements for WordPress transients to work properly?
- Should the caching of WordPress menus be specific to each page?
- Writing a cache manifest file for a WordPress blog (app cache, offline web applications)
- Transients vs CRON +Custom Fields: Caching Data Per Post
- Transient not working for custom loops
- W3 Total Cache doesn’t detect memcached [closed]
- Settings to get the most out of W3 Total Cache
- How to force content refresh of a page that has been loaded previously by the user? [closed]
- Help Pinpointing Source of Caching Issue
- How to clear cache without a plugin [closed]
- can’t see live version of style.css – is it web server caching?
- Want to enforce the visitor to load the new version of your stylesheets and scripts [closed]
- Can someone explain WordPress caching, and what’s the best in my scenario?
- Speed up WordPress
- wp-super-cache exclude file from caching
- wp_transients | wp_object_cache VS SESSIONS & Cookies?
- APC object caching in combination Batcache/memcached page caching?
- Transients API and multisite
- Should the page cache be refreshed often? [closed]
- WordPress caching in development
- Plugin a specific cache functionality?
- What is difference between ‘Page Cache’ and ‘Object Cache’ in WordPress?
- W3 total Cache – Site with query strings
- Possible to configure nginx to ignore cache for logged in users in certain roles only?
- Check if a user is connected and get is ID without fully loading wordpress
- Transient caching for wp query
- Should I enable FastCGI on WordPress?
- Get the timout value of a saved transient?
- Programmatically insert hierarchical terms & set terms for post causes glitch? [duplicate]
- Will caching WordPress affect session variables, custom filed updates and displaying images from a non wordpress table?
- Getting soft 404 errors (200 status) when caching plugins are enabled
- How to totally disable cache in WordPress?
- Automatically enabled caching in some hosting companies w/o visible plugin (Must use plugin)
- Database Cache and Object Cache Difference?
- Register script version not showing
- W3 Total Cache plugin integration
- Transient API and caching Plugins
- How to cache posts based on $_GET? Option name is too long? Options / transients
- WordPress Caching – Transients API or “update_user_meta ” Cronjob?
- When use a cache system with WordPress
- server load. $_SERVER[‘REMOTE_ADDR’] and $_SERVER[‘HTTP_HOST’] [closed]
- Optimizing Jetpack for WordPress [closed]
- Is it possible to save an entire piece of rendered HTML in a transient?
- Execute a piece of code also when the cached version of a page is served
- Clearing cached plugin data if it is using an external object cache
- Method to make definitively static an abandoned WP blog
- How do I fetch feed info from cache instead of directly from feed?
- pass-protected pages and posts not protected after enter them 1 time
- Can a WordPress blog be entirely hosted on a CDN if cached?
- Static HTML page caching for large website [closed]
- Transient feeds and caching error
- Transient loop issue
- To have WordPress interact with memcached it must be installed as a PHP extension?
- WordPress caching issue