2. WHAT ARE TRANSIENTS?
Transients allow you to store non time
sensitive data for a specified time
period.
After this time period has expired you
will fetch an updated version of the
data being stored.
3. PRACTICAL TRANSIENT
USAGE
• Twitter / Facebook / social media feed
• A popular articles widget
• Recent articles widget
• Non time sensitive database queries
• Expensive non time sensitive PHP routines
• Other non time sensitive API calls
(flickr, YouTube, etc)
• Instead of cron?
4. 3 FUNCTIONS TO RULE THEM
ALL
1. get_transient()
2. set_transient()
3. delete_transient()
5. WHAT CAN WE STORE IN
TRANSIENTS?
• Strings / HTML
• Arrays / Objects (auto serialized)
6. TIME TO CODE /
If( false === ( $api_data = get_transient( ‘my_api_call’ ) ) ){
// generate the transient data
$api_data = some_api_call();
// save the transient data
set_transient( ‘api_data’, $api_data, 60 * 60 * 24 );
}
// do stuff with transient data ( $api_data )