The Complete Guide to the WordPress Transients API

Originally published at: http://www.sitepoint.com/complete-guide-wordpress-transients-api/

WordPress has supported the Transients API since version 2.8 but still many WordPress developers are unaware of its existence and uses. In a nutshell, WordPress Transients API lets us store key-value pairs of data with an expiration time.

In this tutorial, we will cover how to use this API in depth. We will also see how it’s different from Options API, how it interacts with the WordPress caching system and few of its use cases.

Options API vs Transients API

Most WordPress developers are aware of WordPress Options API. Options API lets us store key-value pairs of data permanently in the database. What many WordPress developers don’t realise is that Options API implements a caching layer (i.e. WordPress Object Cache) to cache the options. If a persistent cache is not enabled then a new caching session is created on every HTTP request otherwise the persistent cache is used by Options API.

Continue reading this article on SitePoint

I think you might be interested in this:

WordPress transients done The ezWay. Centralize your transients and treat them more like methods / functions.

The main advantages are you keep your transients in a single place so they are much easier to maintain, and when needing a given transient you simply use a :get(), the checking etc, is automatically handled by the class. In a way, it’s kinda like having global super transients :slight_smile:

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.