SlideShare ist ein Scribd-Unternehmen logo
1 von 13
Downloaden Sie, um offline zu lesen
Introduction to the
WordPress Transients API
Subtitle goes here if needed
Presenter
Topher DeRosia
@topher1kenobe
Date
20 July, 2019
What is a Transient, and where would I use it?
Time consuming queries
Meta queries are slow. Meta queries comparing against multiple fields
are even slower. We can cache the results in a transient.
Remote data fetched via the HTTP API
Using the HTTP API you can fetch data from a remote server. But
what if that server goes down? What about latency? We can cache
the results in a transient.
tran·sient /ˈtranSHənt,ˈtranzēənt/
adjective: transient
1. lasting only for a short time; impermanent. "a transient cold spell"
2. In WordPress, a bit of data cached for an indeterminate amount of time
How do transients work?
• Each transient has a name
• When you need the data, check to see if it exists
• If it does, use it.
• If it doesn’t, generate the data and set it for next time
Where are transients stored?
• I don’t care
• It doesn’t matter
• WordPress takes care of it for you
No, really, where are transients stored?
• First WordPress looks for a real, system level, caching module like
memcached, Redis, APC, Varnish, etc. These are very very fast, and
much prefered.
• Failing that, transients are store in the WordPress options table. Yes, this
is still a database call, but a simple, speedy one.
• You don’t have to do anything to set this up, WordPress magically handles
it.
How is this magic accomplished?
• WordPress provides functions to set, get, and delete transients. Setting
one that already exists updates it.
• Using these function you simply ask for the data you want. If it’s not there
you build it and store it for next time.
Behold the horrible query.
$args = [
'post_status'=> 'publish',
'post_type' => 'coaches',
'orderby' => 'date',
'no_found_rows' => true,
'meta_query' => [
[
['key'] = 'ecpt_sold';
['value'] = 'on';
['compare'] = 'NOT EXISTS';
],
],
'meta_query' => [
[
['key'] = 'ecpt_featured';
['value'] = 'on';
['compare'] = 'EXISTS';
],
],
];
$coaches_query = new WP_Query( $args );
Behold the transient code.
// create the transient name
$transient_name = 'coaches';
// try getting the transient.
$coaches = get_transient( $transient_name );
// if the get works properly, I should have an object in $coaches.
// If not, run the query.
if( ! is_object( $coaches ) ) {
// run horrible query here
$coaches_query = new WP_Query( $args );
// save the results of the query with a 12 hour timeout
$save_query = set_transient( $transient_name, $coaches_query, HOUR_IN_SECONDS * 12 );
$coaches = $coaches_query;
}
// now $coaches will always hold an object full of Coach
But wait! What about changes?
// delete featured coaches transient on coach save
function delete_coach_transient( $post_id ) {
// First we want to make sure that this is a real save, not simply an auto save
if ( ! wp_is_post_revision( $post_id ) ) {
// now we declare our custom content type, because we only want to run this on the save of this type
$slug = 'coaches';
// this is where we actually make sure we're on the right type.
$_POST += array( "{$slug}_edit_nonce" => '' );
if ( $slug != $_POST['post_type'] ) {
return;
}
// assuming we're on the proper type, set the transient name
$transient_name = 'coaches';
// now delete the actual transient
delete_transient($transient_name);
}
// end delete_featured_transient
}
// now we hook that function into save_post and it's all set
add_action('save_post','delete_coach_transient');
Important things to remember
• You can store just about anything in a transient
• Transients are ethereal. Lots of things can delete them, never assume
they’re there just because you set them. ALWAYS TEST
• Think about when and how to invalidate them. Otherwise you’re stuck with
cached content
Resources
• Pippin’s Transients Manager
https://wordpress.org/plugins/transients-manager/
• Delete Expired Transients
https://wordpress.org/plugins/delete-expired-transients/
• Query Monitor
https://wordpress.org/plugins/query-monitor/
Thank You
Twitter: @topher1kenobe
Make WordPress Slack: topher1kenobe
Email: topher@bigcommerce.com

Weitere ähnliche Inhalte

Was ist angesagt?

The Best (and Worst) of Django
The Best (and Worst) of DjangoThe Best (and Worst) of Django
The Best (and Worst) of DjangoJacob Kaplan-Moss
 
In-depth changes to Drupal 8 javascript
In-depth changes to Drupal 8 javascriptIn-depth changes to Drupal 8 javascript
In-depth changes to Drupal 8 javascriptThéodore Biadala
 
Django REST Framework
Django REST FrameworkDjango REST Framework
Django REST FrameworkLoad Impact
 
Django multi-tier
Django multi-tierDjango multi-tier
Django multi-tiersmirolo
 
Google compute presentation puppet conf
Google compute presentation puppet confGoogle compute presentation puppet conf
Google compute presentation puppet confbodepd
 
Djangocon 2014 angular + django
Djangocon 2014 angular + djangoDjangocon 2014 angular + django
Djangocon 2014 angular + djangoNina Zakharenko
 
Automated testing with RSpec
Automated testing with RSpecAutomated testing with RSpec
Automated testing with RSpecNascenia IT
 
Single Page Web Apps As WordPress Admin Interfaces Using AngularJS & The Word...
Single Page Web Apps As WordPress Admin Interfaces Using AngularJS & The Word...Single Page Web Apps As WordPress Admin Interfaces Using AngularJS & The Word...
Single Page Web Apps As WordPress Admin Interfaces Using AngularJS & The Word...Caldera Labs
 
Sprout core and performance
Sprout core and performanceSprout core and performance
Sprout core and performanceYehuda Katz
 
jQuery - 10 Time-Savers You (Maybe) Don't Know
jQuery - 10 Time-Savers You (Maybe) Don't KnowjQuery - 10 Time-Savers You (Maybe) Don't Know
jQuery - 10 Time-Savers You (Maybe) Don't Knowgirish82
 
Rspec API Documentation
Rspec API DocumentationRspec API Documentation
Rspec API DocumentationSmartLogic
 
Working with WP_Query in WordPress
Working with WP_Query in WordPressWorking with WP_Query in WordPress
Working with WP_Query in WordPresstopher1kenobe
 
Gazelle - Plack Handler for performance freaks #yokohamapm
Gazelle - Plack Handler for performance freaks #yokohamapmGazelle - Plack Handler for performance freaks #yokohamapm
Gazelle - Plack Handler for performance freaks #yokohamapmMasahiro Nagano
 
Wordpress plugin development tips
Wordpress plugin development tipsWordpress plugin development tips
Wordpress plugin development tipsMindfire Solutions
 
Quick MySQL performance check
Quick MySQL performance checkQuick MySQL performance check
Quick MySQL performance checkTom Diederich
 
Euruko 2009 - DataObjects
Euruko 2009 - DataObjectsEuruko 2009 - DataObjects
Euruko 2009 - DataObjectsDirkjan Bussink
 
Jquery Best Practices
Jquery Best PracticesJquery Best Practices
Jquery Best Practicesbrinsknaps
 
RSpec User Stories
RSpec User StoriesRSpec User Stories
RSpec User Storiesrahoulb
 
N:1 Replication meets MHA
N:1 Replication meets MHAN:1 Replication meets MHA
N:1 Replication meets MHAdo_aki
 

Was ist angesagt? (20)

The Best (and Worst) of Django
The Best (and Worst) of DjangoThe Best (and Worst) of Django
The Best (and Worst) of Django
 
In-depth changes to Drupal 8 javascript
In-depth changes to Drupal 8 javascriptIn-depth changes to Drupal 8 javascript
In-depth changes to Drupal 8 javascript
 
Django REST Framework
Django REST FrameworkDjango REST Framework
Django REST Framework
 
Django multi-tier
Django multi-tierDjango multi-tier
Django multi-tier
 
Google compute presentation puppet conf
Google compute presentation puppet confGoogle compute presentation puppet conf
Google compute presentation puppet conf
 
Djangocon 2014 angular + django
Djangocon 2014 angular + djangoDjangocon 2014 angular + django
Djangocon 2014 angular + django
 
Puppet modules for Fun and Profit
Puppet modules for Fun and ProfitPuppet modules for Fun and Profit
Puppet modules for Fun and Profit
 
Automated testing with RSpec
Automated testing with RSpecAutomated testing with RSpec
Automated testing with RSpec
 
Single Page Web Apps As WordPress Admin Interfaces Using AngularJS & The Word...
Single Page Web Apps As WordPress Admin Interfaces Using AngularJS & The Word...Single Page Web Apps As WordPress Admin Interfaces Using AngularJS & The Word...
Single Page Web Apps As WordPress Admin Interfaces Using AngularJS & The Word...
 
Sprout core and performance
Sprout core and performanceSprout core and performance
Sprout core and performance
 
jQuery - 10 Time-Savers You (Maybe) Don't Know
jQuery - 10 Time-Savers You (Maybe) Don't KnowjQuery - 10 Time-Savers You (Maybe) Don't Know
jQuery - 10 Time-Savers You (Maybe) Don't Know
 
Rspec API Documentation
Rspec API DocumentationRspec API Documentation
Rspec API Documentation
 
Working with WP_Query in WordPress
Working with WP_Query in WordPressWorking with WP_Query in WordPress
Working with WP_Query in WordPress
 
Gazelle - Plack Handler for performance freaks #yokohamapm
Gazelle - Plack Handler for performance freaks #yokohamapmGazelle - Plack Handler for performance freaks #yokohamapm
Gazelle - Plack Handler for performance freaks #yokohamapm
 
Wordpress plugin development tips
Wordpress plugin development tipsWordpress plugin development tips
Wordpress plugin development tips
 
Quick MySQL performance check
Quick MySQL performance checkQuick MySQL performance check
Quick MySQL performance check
 
Euruko 2009 - DataObjects
Euruko 2009 - DataObjectsEuruko 2009 - DataObjects
Euruko 2009 - DataObjects
 
Jquery Best Practices
Jquery Best PracticesJquery Best Practices
Jquery Best Practices
 
RSpec User Stories
RSpec User StoriesRSpec User Stories
RSpec User Stories
 
N:1 Replication meets MHA
N:1 Replication meets MHAN:1 Replication meets MHA
N:1 Replication meets MHA
 

Ähnlich wie Introduction to the WordPress Transients API

Best Practices in Plugin Development (WordCamp Seattle)
Best Practices in Plugin Development (WordCamp Seattle)Best Practices in Plugin Development (WordCamp Seattle)
Best Practices in Plugin Development (WordCamp Seattle)andrewnacin
 
Transients are good for you - WordCamp London 2016
Transients are good for you - WordCamp London 2016Transients are good for you - WordCamp London 2016
Transients are good for you - WordCamp London 2016Boiteaweb
 
Intro to advanced caching in WordPress
Intro to advanced caching in WordPressIntro to advanced caching in WordPress
Intro to advanced caching in WordPressMaor Chasen
 
WordCamp San Francisco 2011: Transients, Caching, and the Complexities of Mul...
WordCamp San Francisco 2011: Transients, Caching, and the Complexities of Mul...WordCamp San Francisco 2011: Transients, Caching, and the Complexities of Mul...
WordCamp San Francisco 2011: Transients, Caching, and the Complexities of Mul...andrewnacin
 
Options, and Transients, and Theme Mods — Oh my!
Options, and Transients, and Theme Mods — Oh my!Options, and Transients, and Theme Mods — Oh my!
Options, and Transients, and Theme Mods — Oh my!Konstantin Obenland
 
Temporary Cache Assistance (Transients API): WordCamp Birmingham 2014
Temporary Cache Assistance (Transients API): WordCamp Birmingham 2014Temporary Cache Assistance (Transients API): WordCamp Birmingham 2014
Temporary Cache Assistance (Transients API): WordCamp Birmingham 2014Cliff Seal
 
Temporary Cache Assistance (Transients API): WordCamp Phoenix 2014
Temporary Cache Assistance (Transients API): WordCamp Phoenix 2014Temporary Cache Assistance (Transients API): WordCamp Phoenix 2014
Temporary Cache Assistance (Transients API): WordCamp Phoenix 2014Cliff Seal
 
Speed Things Up with Transients
Speed Things Up with TransientsSpeed Things Up with Transients
Speed Things Up with TransientsCliff Seal
 
Php Security3895
Php Security3895Php Security3895
Php Security3895Aung Khant
 
10 Things Every Plugin Developer Should Know (WordCamp Atlanta 2013)
10 Things Every Plugin Developer Should Know (WordCamp Atlanta 2013)10 Things Every Plugin Developer Should Know (WordCamp Atlanta 2013)
10 Things Every Plugin Developer Should Know (WordCamp Atlanta 2013)arcware
 
Php Code Audits (PHP UK 2010)
Php Code Audits (PHP UK 2010)Php Code Audits (PHP UK 2010)
Php Code Audits (PHP UK 2010)Damien Seguy
 
jQuery Anti-Patterns for Performance & Compression
jQuery Anti-Patterns for Performance & CompressionjQuery Anti-Patterns for Performance & Compression
jQuery Anti-Patterns for Performance & CompressionPaul Irish
 
You don’t know query - WordCamp UK Edinburgh 2012
You don’t know query - WordCamp UK Edinburgh 2012You don’t know query - WordCamp UK Edinburgh 2012
You don’t know query - WordCamp UK Edinburgh 2012l3rady
 
WordPress as an application framework
WordPress as an application frameworkWordPress as an application framework
WordPress as an application frameworkDustin Filippini
 
Sql storeprocedure
Sql storeprocedureSql storeprocedure
Sql storeprocedureftz 420
 
You Don't Know Query - WordCamp Portland 2011
You Don't Know Query - WordCamp Portland 2011You Don't Know Query - WordCamp Portland 2011
You Don't Know Query - WordCamp Portland 2011andrewnacin
 
jQuery Anti-Patterns for Performance
jQuery Anti-Patterns for PerformancejQuery Anti-Patterns for Performance
jQuery Anti-Patterns for PerformanceAndrás Kovács
 

Ähnlich wie Introduction to the WordPress Transients API (20)

Best Practices in Plugin Development (WordCamp Seattle)
Best Practices in Plugin Development (WordCamp Seattle)Best Practices in Plugin Development (WordCamp Seattle)
Best Practices in Plugin Development (WordCamp Seattle)
 
Transients are good for you - WordCamp London 2016
Transients are good for you - WordCamp London 2016Transients are good for you - WordCamp London 2016
Transients are good for you - WordCamp London 2016
 
Intro to advanced caching in WordPress
Intro to advanced caching in WordPressIntro to advanced caching in WordPress
Intro to advanced caching in WordPress
 
WordCamp San Francisco 2011: Transients, Caching, and the Complexities of Mul...
WordCamp San Francisco 2011: Transients, Caching, and the Complexities of Mul...WordCamp San Francisco 2011: Transients, Caching, and the Complexities of Mul...
WordCamp San Francisco 2011: Transients, Caching, and the Complexities of Mul...
 
Options, and Transients, and Theme Mods — Oh my!
Options, and Transients, and Theme Mods — Oh my!Options, and Transients, and Theme Mods — Oh my!
Options, and Transients, and Theme Mods — Oh my!
 
Php security3895
Php security3895Php security3895
Php security3895
 
PHP Security
PHP SecurityPHP Security
PHP Security
 
Temporary Cache Assistance (Transients API): WordCamp Birmingham 2014
Temporary Cache Assistance (Transients API): WordCamp Birmingham 2014Temporary Cache Assistance (Transients API): WordCamp Birmingham 2014
Temporary Cache Assistance (Transients API): WordCamp Birmingham 2014
 
Temporary Cache Assistance (Transients API): WordCamp Phoenix 2014
Temporary Cache Assistance (Transients API): WordCamp Phoenix 2014Temporary Cache Assistance (Transients API): WordCamp Phoenix 2014
Temporary Cache Assistance (Transients API): WordCamp Phoenix 2014
 
Speed Things Up with Transients
Speed Things Up with TransientsSpeed Things Up with Transients
Speed Things Up with Transients
 
PHP Unit Testing
PHP Unit TestingPHP Unit Testing
PHP Unit Testing
 
Php Security3895
Php Security3895Php Security3895
Php Security3895
 
10 Things Every Plugin Developer Should Know (WordCamp Atlanta 2013)
10 Things Every Plugin Developer Should Know (WordCamp Atlanta 2013)10 Things Every Plugin Developer Should Know (WordCamp Atlanta 2013)
10 Things Every Plugin Developer Should Know (WordCamp Atlanta 2013)
 
Php Code Audits (PHP UK 2010)
Php Code Audits (PHP UK 2010)Php Code Audits (PHP UK 2010)
Php Code Audits (PHP UK 2010)
 
jQuery Anti-Patterns for Performance & Compression
jQuery Anti-Patterns for Performance & CompressionjQuery Anti-Patterns for Performance & Compression
jQuery Anti-Patterns for Performance & Compression
 
You don’t know query - WordCamp UK Edinburgh 2012
You don’t know query - WordCamp UK Edinburgh 2012You don’t know query - WordCamp UK Edinburgh 2012
You don’t know query - WordCamp UK Edinburgh 2012
 
WordPress as an application framework
WordPress as an application frameworkWordPress as an application framework
WordPress as an application framework
 
Sql storeprocedure
Sql storeprocedureSql storeprocedure
Sql storeprocedure
 
You Don't Know Query - WordCamp Portland 2011
You Don't Know Query - WordCamp Portland 2011You Don't Know Query - WordCamp Portland 2011
You Don't Know Query - WordCamp Portland 2011
 
jQuery Anti-Patterns for Performance
jQuery Anti-Patterns for PerformancejQuery Anti-Patterns for Performance
jQuery Anti-Patterns for Performance
 

Mehr von topher1kenobe

How To Increase Ecommerce Conversions
How To Increase Ecommerce ConversionsHow To Increase Ecommerce Conversions
How To Increase Ecommerce Conversionstopher1kenobe
 
Build Ecommerce Sites With Confidence (Demystifying Ecommerce), WordCamp Los ...
Build Ecommerce Sites With Confidence (Demystifying Ecommerce), WordCamp Los ...Build Ecommerce Sites With Confidence (Demystifying Ecommerce), WordCamp Los ...
Build Ecommerce Sites With Confidence (Demystifying Ecommerce), WordCamp Los ...topher1kenobe
 
Build Ecommerce Sites With Confidence (Demystifying Ecommerce)
Build Ecommerce Sites With Confidence (Demystifying Ecommerce)Build Ecommerce Sites With Confidence (Demystifying Ecommerce)
Build Ecommerce Sites With Confidence (Demystifying Ecommerce)topher1kenobe
 
6 Ecommerce Trends Altering the Ecommerce Landscape, and changing which strat...
6 Ecommerce Trends Altering the Ecommerce Landscape, and changing which strat...6 Ecommerce Trends Altering the Ecommerce Landscape, and changing which strat...
6 Ecommerce Trends Altering the Ecommerce Landscape, and changing which strat...topher1kenobe
 
Talking to Other Sites with the WP HTTP API
Talking to Other Sites with the WP HTTP APITalking to Other Sites with the WP HTTP API
Talking to Other Sites with the WP HTTP APItopher1kenobe
 
What’s a REST API and why should I care?
What’s a REST API and why should I care?What’s a REST API and why should I care?
What’s a REST API and why should I care?topher1kenobe
 
HeroPress: A Case Study
HeroPress: A Case StudyHeroPress: A Case Study
HeroPress: A Case Studytopher1kenobe
 
Custom Database Queries in WordPress
Custom Database Queries in WordPressCustom Database Queries in WordPress
Custom Database Queries in WordPresstopher1kenobe
 
Introduction to WordPress Child Theming, WordCamp Kansas City, 2015
Introduction to WordPress Child Theming, WordCamp Kansas City, 2015Introduction to WordPress Child Theming, WordCamp Kansas City, 2015
Introduction to WordPress Child Theming, WordCamp Kansas City, 2015topher1kenobe
 
Intro to Plugin Development, Miami WordCamp, 2015
Intro to Plugin Development, Miami WordCamp, 2015Intro to Plugin Development, Miami WordCamp, 2015
Intro to Plugin Development, Miami WordCamp, 2015topher1kenobe
 
Introduction to WordPress Plugin Development, WordCamp North Canton, 2015
Introduction to WordPress Plugin Development, WordCamp North Canton, 2015Introduction to WordPress Plugin Development, WordCamp North Canton, 2015
Introduction to WordPress Plugin Development, WordCamp North Canton, 2015topher1kenobe
 
WordCamp Ann Arbor 2014: Site Caching, From Nothing to Everything
WordCamp Ann Arbor 2014: Site Caching, From Nothing to EverythingWordCamp Ann Arbor 2014: Site Caching, From Nothing to Everything
WordCamp Ann Arbor 2014: Site Caching, From Nothing to Everythingtopher1kenobe
 
Command Line Awesome, WordCamp Grand Rapids 2014
Command Line Awesome, WordCamp Grand Rapids 2014Command Line Awesome, WordCamp Grand Rapids 2014
Command Line Awesome, WordCamp Grand Rapids 2014topher1kenobe
 

Mehr von topher1kenobe (13)

How To Increase Ecommerce Conversions
How To Increase Ecommerce ConversionsHow To Increase Ecommerce Conversions
How To Increase Ecommerce Conversions
 
Build Ecommerce Sites With Confidence (Demystifying Ecommerce), WordCamp Los ...
Build Ecommerce Sites With Confidence (Demystifying Ecommerce), WordCamp Los ...Build Ecommerce Sites With Confidence (Demystifying Ecommerce), WordCamp Los ...
Build Ecommerce Sites With Confidence (Demystifying Ecommerce), WordCamp Los ...
 
Build Ecommerce Sites With Confidence (Demystifying Ecommerce)
Build Ecommerce Sites With Confidence (Demystifying Ecommerce)Build Ecommerce Sites With Confidence (Demystifying Ecommerce)
Build Ecommerce Sites With Confidence (Demystifying Ecommerce)
 
6 Ecommerce Trends Altering the Ecommerce Landscape, and changing which strat...
6 Ecommerce Trends Altering the Ecommerce Landscape, and changing which strat...6 Ecommerce Trends Altering the Ecommerce Landscape, and changing which strat...
6 Ecommerce Trends Altering the Ecommerce Landscape, and changing which strat...
 
Talking to Other Sites with the WP HTTP API
Talking to Other Sites with the WP HTTP APITalking to Other Sites with the WP HTTP API
Talking to Other Sites with the WP HTTP API
 
What’s a REST API and why should I care?
What’s a REST API and why should I care?What’s a REST API and why should I care?
What’s a REST API and why should I care?
 
HeroPress: A Case Study
HeroPress: A Case StudyHeroPress: A Case Study
HeroPress: A Case Study
 
Custom Database Queries in WordPress
Custom Database Queries in WordPressCustom Database Queries in WordPress
Custom Database Queries in WordPress
 
Introduction to WordPress Child Theming, WordCamp Kansas City, 2015
Introduction to WordPress Child Theming, WordCamp Kansas City, 2015Introduction to WordPress Child Theming, WordCamp Kansas City, 2015
Introduction to WordPress Child Theming, WordCamp Kansas City, 2015
 
Intro to Plugin Development, Miami WordCamp, 2015
Intro to Plugin Development, Miami WordCamp, 2015Intro to Plugin Development, Miami WordCamp, 2015
Intro to Plugin Development, Miami WordCamp, 2015
 
Introduction to WordPress Plugin Development, WordCamp North Canton, 2015
Introduction to WordPress Plugin Development, WordCamp North Canton, 2015Introduction to WordPress Plugin Development, WordCamp North Canton, 2015
Introduction to WordPress Plugin Development, WordCamp North Canton, 2015
 
WordCamp Ann Arbor 2014: Site Caching, From Nothing to Everything
WordCamp Ann Arbor 2014: Site Caching, From Nothing to EverythingWordCamp Ann Arbor 2014: Site Caching, From Nothing to Everything
WordCamp Ann Arbor 2014: Site Caching, From Nothing to Everything
 
Command Line Awesome, WordCamp Grand Rapids 2014
Command Line Awesome, WordCamp Grand Rapids 2014Command Line Awesome, WordCamp Grand Rapids 2014
Command Line Awesome, WordCamp Grand Rapids 2014
 

Kürzlich hochgeladen

Al Barsha Night Partner +0567686026 Call Girls Dubai
Al Barsha Night Partner +0567686026 Call Girls  DubaiAl Barsha Night Partner +0567686026 Call Girls  Dubai
Al Barsha Night Partner +0567686026 Call Girls DubaiEscorts Call Girls
 
VIP Call Girls Himatnagar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Himatnagar 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Himatnagar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Himatnagar 7001035870 Whatsapp Number, 24/07 Bookingdharasingh5698
 
All Time Service Available Call Girls Mg Road 👌 ⏭️ 6378878445
All Time Service Available Call Girls Mg Road 👌 ⏭️ 6378878445All Time Service Available Call Girls Mg Road 👌 ⏭️ 6378878445
All Time Service Available Call Girls Mg Road 👌 ⏭️ 6378878445ruhi
 
Pune Airport ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready...
Pune Airport ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready...Pune Airport ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready...
Pune Airport ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready...tanu pandey
 
Real Escorts in Al Nahda +971524965298 Dubai Escorts Service
Real Escorts in Al Nahda +971524965298 Dubai Escorts ServiceReal Escorts in Al Nahda +971524965298 Dubai Escorts Service
Real Escorts in Al Nahda +971524965298 Dubai Escorts ServiceEscorts Call Girls
 
Nanded City ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready ...
Nanded City ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready ...Nanded City ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready ...
Nanded City ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready ...tanu pandey
 
( Pune ) VIP Baner Call Girls 🎗️ 9352988975 Sizzling | Escorts | Girls Are Re...
( Pune ) VIP Baner Call Girls 🎗️ 9352988975 Sizzling | Escorts | Girls Are Re...( Pune ) VIP Baner Call Girls 🎗️ 9352988975 Sizzling | Escorts | Girls Are Re...
( Pune ) VIP Baner Call Girls 🎗️ 9352988975 Sizzling | Escorts | Girls Are Re...nilamkumrai
 
Real Men Wear Diapers T Shirts sweatshirt
Real Men Wear Diapers T Shirts sweatshirtReal Men Wear Diapers T Shirts sweatshirt
Real Men Wear Diapers T Shirts sweatshirtrahman018755
 
( Pune ) VIP Pimpri Chinchwad Call Girls 🎗️ 9352988975 Sizzling | Escorts | G...
( Pune ) VIP Pimpri Chinchwad Call Girls 🎗️ 9352988975 Sizzling | Escorts | G...( Pune ) VIP Pimpri Chinchwad Call Girls 🎗️ 9352988975 Sizzling | Escorts | G...
( Pune ) VIP Pimpri Chinchwad Call Girls 🎗️ 9352988975 Sizzling | Escorts | G...nilamkumrai
 
Sarola * Female Escorts Service in Pune | 8005736733 Independent Escorts & Da...
Sarola * Female Escorts Service in Pune | 8005736733 Independent Escorts & Da...Sarola * Female Escorts Service in Pune | 8005736733 Independent Escorts & Da...
Sarola * Female Escorts Service in Pune | 8005736733 Independent Escorts & Da...SUHANI PANDEY
 
Ganeshkhind ! Call Girls Pune - 450+ Call Girl Cash Payment 8005736733 Neha T...
Ganeshkhind ! Call Girls Pune - 450+ Call Girl Cash Payment 8005736733 Neha T...Ganeshkhind ! Call Girls Pune - 450+ Call Girl Cash Payment 8005736733 Neha T...
Ganeshkhind ! Call Girls Pune - 450+ Call Girl Cash Payment 8005736733 Neha T...SUHANI PANDEY
 
VIP Model Call Girls NIBM ( Pune ) Call ON 8005736733 Starting From 5K to 25K...
VIP Model Call Girls NIBM ( Pune ) Call ON 8005736733 Starting From 5K to 25K...VIP Model Call Girls NIBM ( Pune ) Call ON 8005736733 Starting From 5K to 25K...
VIP Model Call Girls NIBM ( Pune ) Call ON 8005736733 Starting From 5K to 25K...SUHANI PANDEY
 
Katraj ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready For S...
Katraj ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready For S...Katraj ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready For S...
Katraj ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready For S...tanu pandey
 
VIP Model Call Girls Hadapsar ( Pune ) Call ON 9905417584 Starting High Prof...
VIP Model Call Girls Hadapsar ( Pune ) Call ON 9905417584 Starting  High Prof...VIP Model Call Girls Hadapsar ( Pune ) Call ON 9905417584 Starting  High Prof...
VIP Model Call Girls Hadapsar ( Pune ) Call ON 9905417584 Starting High Prof...singhpriety023
 
Wagholi & High Class Call Girls Pune Neha 8005736733 | 100% Gennuine High Cla...
Wagholi & High Class Call Girls Pune Neha 8005736733 | 100% Gennuine High Cla...Wagholi & High Class Call Girls Pune Neha 8005736733 | 100% Gennuine High Cla...
Wagholi & High Class Call Girls Pune Neha 8005736733 | 100% Gennuine High Cla...SUHANI PANDEY
 
VVIP Pune Call Girls Sinhagad WhatSapp Number 8005736733 With Elite Staff And...
VVIP Pune Call Girls Sinhagad WhatSapp Number 8005736733 With Elite Staff And...VVIP Pune Call Girls Sinhagad WhatSapp Number 8005736733 With Elite Staff And...
VVIP Pune Call Girls Sinhagad WhatSapp Number 8005736733 With Elite Staff And...SUHANI PANDEY
 
Pirangut | Call Girls Pune Phone No 8005736733 Elite Escort Service Available...
Pirangut | Call Girls Pune Phone No 8005736733 Elite Escort Service Available...Pirangut | Call Girls Pune Phone No 8005736733 Elite Escort Service Available...
Pirangut | Call Girls Pune Phone No 8005736733 Elite Escort Service Available...SUHANI PANDEY
 
Lucknow ❤CALL GIRL 88759*99948 ❤CALL GIRLS IN Lucknow ESCORT SERVICE❤CALL GIRL
Lucknow ❤CALL GIRL 88759*99948 ❤CALL GIRLS IN Lucknow ESCORT SERVICE❤CALL GIRLLucknow ❤CALL GIRL 88759*99948 ❤CALL GIRLS IN Lucknow ESCORT SERVICE❤CALL GIRL
Lucknow ❤CALL GIRL 88759*99948 ❤CALL GIRLS IN Lucknow ESCORT SERVICE❤CALL GIRLimonikaupta
 
💚😋 Bilaspur Escort Service Call Girls, 9352852248 ₹5000 To 25K With AC💚😋
💚😋 Bilaspur Escort Service Call Girls, 9352852248 ₹5000 To 25K With AC💚😋💚😋 Bilaspur Escort Service Call Girls, 9352852248 ₹5000 To 25K With AC💚😋
💚😋 Bilaspur Escort Service Call Girls, 9352852248 ₹5000 To 25K With AC💚😋nirzagarg
 

Kürzlich hochgeladen (20)

Al Barsha Night Partner +0567686026 Call Girls Dubai
Al Barsha Night Partner +0567686026 Call Girls  DubaiAl Barsha Night Partner +0567686026 Call Girls  Dubai
Al Barsha Night Partner +0567686026 Call Girls Dubai
 
VIP Call Girls Himatnagar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Himatnagar 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Himatnagar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Himatnagar 7001035870 Whatsapp Number, 24/07 Booking
 
All Time Service Available Call Girls Mg Road 👌 ⏭️ 6378878445
All Time Service Available Call Girls Mg Road 👌 ⏭️ 6378878445All Time Service Available Call Girls Mg Road 👌 ⏭️ 6378878445
All Time Service Available Call Girls Mg Road 👌 ⏭️ 6378878445
 
Pune Airport ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready...
Pune Airport ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready...Pune Airport ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready...
Pune Airport ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready...
 
Real Escorts in Al Nahda +971524965298 Dubai Escorts Service
Real Escorts in Al Nahda +971524965298 Dubai Escorts ServiceReal Escorts in Al Nahda +971524965298 Dubai Escorts Service
Real Escorts in Al Nahda +971524965298 Dubai Escorts Service
 
Nanded City ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready ...
Nanded City ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready ...Nanded City ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready ...
Nanded City ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready ...
 
( Pune ) VIP Baner Call Girls 🎗️ 9352988975 Sizzling | Escorts | Girls Are Re...
( Pune ) VIP Baner Call Girls 🎗️ 9352988975 Sizzling | Escorts | Girls Are Re...( Pune ) VIP Baner Call Girls 🎗️ 9352988975 Sizzling | Escorts | Girls Are Re...
( Pune ) VIP Baner Call Girls 🎗️ 9352988975 Sizzling | Escorts | Girls Are Re...
 
Real Men Wear Diapers T Shirts sweatshirt
Real Men Wear Diapers T Shirts sweatshirtReal Men Wear Diapers T Shirts sweatshirt
Real Men Wear Diapers T Shirts sweatshirt
 
( Pune ) VIP Pimpri Chinchwad Call Girls 🎗️ 9352988975 Sizzling | Escorts | G...
( Pune ) VIP Pimpri Chinchwad Call Girls 🎗️ 9352988975 Sizzling | Escorts | G...( Pune ) VIP Pimpri Chinchwad Call Girls 🎗️ 9352988975 Sizzling | Escorts | G...
( Pune ) VIP Pimpri Chinchwad Call Girls 🎗️ 9352988975 Sizzling | Escorts | G...
 
Sarola * Female Escorts Service in Pune | 8005736733 Independent Escorts & Da...
Sarola * Female Escorts Service in Pune | 8005736733 Independent Escorts & Da...Sarola * Female Escorts Service in Pune | 8005736733 Independent Escorts & Da...
Sarola * Female Escorts Service in Pune | 8005736733 Independent Escorts & Da...
 
Ganeshkhind ! Call Girls Pune - 450+ Call Girl Cash Payment 8005736733 Neha T...
Ganeshkhind ! Call Girls Pune - 450+ Call Girl Cash Payment 8005736733 Neha T...Ganeshkhind ! Call Girls Pune - 450+ Call Girl Cash Payment 8005736733 Neha T...
Ganeshkhind ! Call Girls Pune - 450+ Call Girl Cash Payment 8005736733 Neha T...
 
VIP Model Call Girls NIBM ( Pune ) Call ON 8005736733 Starting From 5K to 25K...
VIP Model Call Girls NIBM ( Pune ) Call ON 8005736733 Starting From 5K to 25K...VIP Model Call Girls NIBM ( Pune ) Call ON 8005736733 Starting From 5K to 25K...
VIP Model Call Girls NIBM ( Pune ) Call ON 8005736733 Starting From 5K to 25K...
 
Katraj ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready For S...
Katraj ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready For S...Katraj ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready For S...
Katraj ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready For S...
 
VIP Model Call Girls Hadapsar ( Pune ) Call ON 9905417584 Starting High Prof...
VIP Model Call Girls Hadapsar ( Pune ) Call ON 9905417584 Starting  High Prof...VIP Model Call Girls Hadapsar ( Pune ) Call ON 9905417584 Starting  High Prof...
VIP Model Call Girls Hadapsar ( Pune ) Call ON 9905417584 Starting High Prof...
 
Wagholi & High Class Call Girls Pune Neha 8005736733 | 100% Gennuine High Cla...
Wagholi & High Class Call Girls Pune Neha 8005736733 | 100% Gennuine High Cla...Wagholi & High Class Call Girls Pune Neha 8005736733 | 100% Gennuine High Cla...
Wagholi & High Class Call Girls Pune Neha 8005736733 | 100% Gennuine High Cla...
 
VVIP Pune Call Girls Sinhagad WhatSapp Number 8005736733 With Elite Staff And...
VVIP Pune Call Girls Sinhagad WhatSapp Number 8005736733 With Elite Staff And...VVIP Pune Call Girls Sinhagad WhatSapp Number 8005736733 With Elite Staff And...
VVIP Pune Call Girls Sinhagad WhatSapp Number 8005736733 With Elite Staff And...
 
Pirangut | Call Girls Pune Phone No 8005736733 Elite Escort Service Available...
Pirangut | Call Girls Pune Phone No 8005736733 Elite Escort Service Available...Pirangut | Call Girls Pune Phone No 8005736733 Elite Escort Service Available...
Pirangut | Call Girls Pune Phone No 8005736733 Elite Escort Service Available...
 
Lucknow ❤CALL GIRL 88759*99948 ❤CALL GIRLS IN Lucknow ESCORT SERVICE❤CALL GIRL
Lucknow ❤CALL GIRL 88759*99948 ❤CALL GIRLS IN Lucknow ESCORT SERVICE❤CALL GIRLLucknow ❤CALL GIRL 88759*99948 ❤CALL GIRLS IN Lucknow ESCORT SERVICE❤CALL GIRL
Lucknow ❤CALL GIRL 88759*99948 ❤CALL GIRLS IN Lucknow ESCORT SERVICE❤CALL GIRL
 
valsad Escorts Service ☎️ 6378878445 ( Sakshi Sinha ) High Profile Call Girls...
valsad Escorts Service ☎️ 6378878445 ( Sakshi Sinha ) High Profile Call Girls...valsad Escorts Service ☎️ 6378878445 ( Sakshi Sinha ) High Profile Call Girls...
valsad Escorts Service ☎️ 6378878445 ( Sakshi Sinha ) High Profile Call Girls...
 
💚😋 Bilaspur Escort Service Call Girls, 9352852248 ₹5000 To 25K With AC💚😋
💚😋 Bilaspur Escort Service Call Girls, 9352852248 ₹5000 To 25K With AC💚😋💚😋 Bilaspur Escort Service Call Girls, 9352852248 ₹5000 To 25K With AC💚😋
💚😋 Bilaspur Escort Service Call Girls, 9352852248 ₹5000 To 25K With AC💚😋
 

Introduction to the WordPress Transients API

  • 1. Introduction to the WordPress Transients API Subtitle goes here if needed Presenter Topher DeRosia @topher1kenobe Date 20 July, 2019
  • 2. What is a Transient, and where would I use it? Time consuming queries Meta queries are slow. Meta queries comparing against multiple fields are even slower. We can cache the results in a transient. Remote data fetched via the HTTP API Using the HTTP API you can fetch data from a remote server. But what if that server goes down? What about latency? We can cache the results in a transient. tran·sient /ˈtranSHənt,ˈtranzēənt/ adjective: transient 1. lasting only for a short time; impermanent. "a transient cold spell" 2. In WordPress, a bit of data cached for an indeterminate amount of time
  • 3. How do transients work? • Each transient has a name • When you need the data, check to see if it exists • If it does, use it. • If it doesn’t, generate the data and set it for next time
  • 4. Where are transients stored? • I don’t care • It doesn’t matter • WordPress takes care of it for you
  • 5. No, really, where are transients stored? • First WordPress looks for a real, system level, caching module like memcached, Redis, APC, Varnish, etc. These are very very fast, and much prefered. • Failing that, transients are store in the WordPress options table. Yes, this is still a database call, but a simple, speedy one. • You don’t have to do anything to set this up, WordPress magically handles it.
  • 6. How is this magic accomplished? • WordPress provides functions to set, get, and delete transients. Setting one that already exists updates it. • Using these function you simply ask for the data you want. If it’s not there you build it and store it for next time.
  • 7.
  • 8. Behold the horrible query. $args = [ 'post_status'=> 'publish', 'post_type' => 'coaches', 'orderby' => 'date', 'no_found_rows' => true, 'meta_query' => [ [ ['key'] = 'ecpt_sold'; ['value'] = 'on'; ['compare'] = 'NOT EXISTS'; ], ], 'meta_query' => [ [ ['key'] = 'ecpt_featured'; ['value'] = 'on'; ['compare'] = 'EXISTS'; ], ], ]; $coaches_query = new WP_Query( $args );
  • 9. Behold the transient code. // create the transient name $transient_name = 'coaches'; // try getting the transient. $coaches = get_transient( $transient_name ); // if the get works properly, I should have an object in $coaches. // If not, run the query. if( ! is_object( $coaches ) ) { // run horrible query here $coaches_query = new WP_Query( $args ); // save the results of the query with a 12 hour timeout $save_query = set_transient( $transient_name, $coaches_query, HOUR_IN_SECONDS * 12 ); $coaches = $coaches_query; } // now $coaches will always hold an object full of Coach
  • 10. But wait! What about changes? // delete featured coaches transient on coach save function delete_coach_transient( $post_id ) { // First we want to make sure that this is a real save, not simply an auto save if ( ! wp_is_post_revision( $post_id ) ) { // now we declare our custom content type, because we only want to run this on the save of this type $slug = 'coaches'; // this is where we actually make sure we're on the right type. $_POST += array( "{$slug}_edit_nonce" => '' ); if ( $slug != $_POST['post_type'] ) { return; } // assuming we're on the proper type, set the transient name $transient_name = 'coaches'; // now delete the actual transient delete_transient($transient_name); } // end delete_featured_transient } // now we hook that function into save_post and it's all set add_action('save_post','delete_coach_transient');
  • 11. Important things to remember • You can store just about anything in a transient • Transients are ethereal. Lots of things can delete them, never assume they’re there just because you set them. ALWAYS TEST • Think about when and how to invalidate them. Otherwise you’re stuck with cached content
  • 12. Resources • Pippin’s Transients Manager https://wordpress.org/plugins/transients-manager/ • Delete Expired Transients https://wordpress.org/plugins/delete-expired-transients/ • Query Monitor https://wordpress.org/plugins/query-monitor/
  • 13. Thank You Twitter: @topher1kenobe Make WordPress Slack: topher1kenobe Email: topher@bigcommerce.com