SlideShare ist ein Scribd-Unternehmen logo
1 von 24
Lightweight use of
transients
Phil Marx
@JustPhilMarx
www.nerdtalk.de / phil.marx@gmail.com
Works with WordPress since v2.x
2
WHAT ARE
TRANSIENTS?
A short roundup
3
1
“WordPress Transients API […]
offers a simple and standardized
way of storing cached data in the
database temporarily […]
44
https://codex.wordpress.org/Transients_API
Examples for Transients
▰Results of complex queries
▰Results of remote calls
▰Complex aggregations of different values
5
Advantage: Simple usage
▰set_transient() – sets a transient
▻ set_transient( $transient, $value, $expiration );
▰get_transient() – gets a transient
▻ get_transient( $transient );
▰delete_transient() – deletes a transient
▻ delete_transient( $transient );
6
Transients are designed to expire
▰set_transient() – sets a transient
▻ set_transient( $transient, $value, $expiration );
▰get_transient() – gets a transient
▻ get_transient( $transient );
▰delete_transient() – deletes a transient
▻ delete_transient( $transient );
7
“WordPress Transients API […]
offers a simple and standardized
way of storing cached data in the
database temporarily by giving it
a […] timeframe after which it will
expire and be deleted.
88
https://codex.wordpress.org/Transients_API
WORKAROUND DELETION
9
2
Downsides of deletion
▰Leads to database fragmentation
▻Can cause slow database performance
▰A new dataset is created for the same content
▻Just… why?!
10
What codex recommends
if(false===$value=get_transient('value’))) {
// this code runs when there is no valid
transient set
}
https://codex.wordpress.org/Transients_API
11
My approach to a lightweight use of transients
▰Set a expiration time in a far away future
▰Set an own timeout and update!
12
If a transient exists, this function will update the
transient's expiration time.
https://codex.wordpress.org/Function_Reference/set_transient
Code example
// Setting my own timeout
$timeout_transient = 60 * 5;
$stream = get_transient('streaminglive');
// Fallback if transient was deleted before expiration
if (!is_object($stream)) $stream = new stdClass;
// I'll save the last check into a variable "last_check" (see below) -
if the transient is expired based on my timeout, renew it
if (!isset($stream->last_check) || $timeout_stream < (time() -
$stream->last_check)) {
// Do whatever you need to get/update your data
$stream->last_check = time();
/* Attention: - The timeout of the transient is much more than my
personal timeout - set_transient checks, if there is a valid transient
and will update it instead of creating a new one */
set_transient('streaminglive', $stream, 60 * 60);
}
13
14
Expired transients are only deleted, if they‘re requested again
CLEAN UP YOUR OWN
TRANSIENTS!
Just. Do. It!
15
3
Causes for not requesting transients anymore
▰Adding unique identifier to transient key
▻(Session ID, time(), some hashes, …)
▰Forget deletion when deactivating
plugins/themes
16
Expired and orphaned transients need to be deleted
manually
▰Plugins
▻ „Delete expired transients“
▰SQL Queries
▻Only useful in combination with cronjobs /
WP-Cron
17
“▰We deleted about 143,513
rows of transient entries bringing
the wp_options table from 8Gb
to 200mb
18
https://theeventscalendar.com/support/forums/topic/large-number-of-transients-in-wp_options-table/
“▰In wp_options was about 7000
rows (1,5 Gb). […]
At the moment 672 rows (2,6
Mb).
19
https://theeventscalendar.com/support/forums/topic/large-number-of-transients-in-wp_options-table/
DON’T LET THE USER DO YOUR WORK!
Don‘t be that guy!
▰Tidy up after deactivation of your theme /
plugin
▻ delete_transient( $transient );
▰Use WP Cron event to delete orphaned
transients
▻delete-transients-by-prefix.php (GitHub)
21
SUMMARY
Be lightweight!
22
Be lightweight!
▰Add your own timeout
▰Think if you need unique identifier which are for
temporary usage
▰Clean up your transients
23
24
THANKS!Any questions?
You can find me at
@JustPhilMarx / nerdtalk.de
phil.marx@gmail.com
Thanks to
- SlidesCarnival for Slides template and Icons (CC BY 4.0)
- Alexandru Zdrobău for girl photo (CC0)

Weitere ähnliche Inhalte

Was ist angesagt?

AnyMQ, Hippie, and the real-time web
AnyMQ, Hippie, and the real-time webAnyMQ, Hippie, and the real-time web
AnyMQ, Hippie, and the real-time webclkao
 
Commencer avec le TDD
Commencer avec le TDDCommencer avec le TDD
Commencer avec le TDDEric Hogue
 
Vagrant + Rouster at salesforce.com - PuppetConf 2013
Vagrant + Rouster at salesforce.com - PuppetConf 2013Vagrant + Rouster at salesforce.com - PuppetConf 2013
Vagrant + Rouster at salesforce.com - PuppetConf 2013Puppet
 
Guarding Your Code Against Bugs with Continuous Testing
Guarding Your Code Against Bugs with Continuous TestingGuarding Your Code Against Bugs with Continuous Testing
Guarding Your Code Against Bugs with Continuous TestingEric Hogue
 
Common Performance Pitfalls in Odoo apps
Common Performance Pitfalls in Odoo appsCommon Performance Pitfalls in Odoo apps
Common Performance Pitfalls in Odoo appsOdoo
 
Continuous testing In PHP
Continuous testing In PHPContinuous testing In PHP
Continuous testing In PHPEric Hogue
 
Func dyn column_set.c
Func dyn column_set.cFunc dyn column_set.c
Func dyn column_set.calbertinous
 
Nagios Conference 2013 - Sheeri Cabral - Alerting With MySQL and Nagios
Nagios Conference 2013 - Sheeri Cabral - Alerting With MySQL and NagiosNagios Conference 2013 - Sheeri Cabral - Alerting With MySQL and Nagios
Nagios Conference 2013 - Sheeri Cabral - Alerting With MySQL and NagiosNagios
 

Was ist angesagt? (9)

Learning Dtrace
Learning DtraceLearning Dtrace
Learning Dtrace
 
AnyMQ, Hippie, and the real-time web
AnyMQ, Hippie, and the real-time webAnyMQ, Hippie, and the real-time web
AnyMQ, Hippie, and the real-time web
 
Commencer avec le TDD
Commencer avec le TDDCommencer avec le TDD
Commencer avec le TDD
 
Vagrant + Rouster at salesforce.com - PuppetConf 2013
Vagrant + Rouster at salesforce.com - PuppetConf 2013Vagrant + Rouster at salesforce.com - PuppetConf 2013
Vagrant + Rouster at salesforce.com - PuppetConf 2013
 
Guarding Your Code Against Bugs with Continuous Testing
Guarding Your Code Against Bugs with Continuous TestingGuarding Your Code Against Bugs with Continuous Testing
Guarding Your Code Against Bugs with Continuous Testing
 
Common Performance Pitfalls in Odoo apps
Common Performance Pitfalls in Odoo appsCommon Performance Pitfalls in Odoo apps
Common Performance Pitfalls in Odoo apps
 
Continuous testing In PHP
Continuous testing In PHPContinuous testing In PHP
Continuous testing In PHP
 
Func dyn column_set.c
Func dyn column_set.cFunc dyn column_set.c
Func dyn column_set.c
 
Nagios Conference 2013 - Sheeri Cabral - Alerting With MySQL and Nagios
Nagios Conference 2013 - Sheeri Cabral - Alerting With MySQL and NagiosNagios Conference 2013 - Sheeri Cabral - Alerting With MySQL and Nagios
Nagios Conference 2013 - Sheeri Cabral - Alerting With MySQL and Nagios
 

Ähnlich wie Lightweight use of transients

Speed Things Up with Transients
Speed Things Up with TransientsSpeed Things Up with Transients
Speed Things Up with TransientsCliff Seal
 
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
 
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
 
Artimon - Apache Flume (incubating) NYC Meetup 20111108
Artimon - Apache Flume (incubating) NYC Meetup 20111108Artimon - Apache Flume (incubating) NYC Meetup 20111108
Artimon - Apache Flume (incubating) NYC Meetup 20111108Mathias Herberts
 
Dynamic Tracing of your AMP web site
Dynamic Tracing of your AMP web siteDynamic Tracing of your AMP web site
Dynamic Tracing of your AMP web siteSriram Natarajan
 
Optimizing Autovacuum: PostgreSQL's vacuum cleaner
Optimizing Autovacuum: PostgreSQL's vacuum cleanerOptimizing Autovacuum: PostgreSQL's vacuum cleaner
Optimizing Autovacuum: PostgreSQL's vacuum cleanerSamaySharma10
 
Say YES to Premature Optimizations
Say YES to Premature OptimizationsSay YES to Premature Optimizations
Say YES to Premature OptimizationsMaude Lemaire
 
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
 
Bottom to Top Stack Optimization with LAMP
Bottom to Top Stack Optimization with LAMPBottom to Top Stack Optimization with LAMP
Bottom to Top Stack Optimization with LAMPkatzgrau
 
Bottom to Top Stack Optimization - CICON2011
Bottom to Top Stack Optimization - CICON2011Bottom to Top Stack Optimization - CICON2011
Bottom to Top Stack Optimization - CICON2011CodeIgniter Conference
 
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
 
Configure, Debug and Install OpenStack Trove
Configure, Debug and Install OpenStack TroveConfigure, Debug and Install OpenStack Trove
Configure, Debug and Install OpenStack TroveRama Krishna B
 
Becoming a SOC2 Ruby Shop - Montreal.rb November, 5, 2022 Ruby Meetup
Becoming a SOC2 Ruby Shop - Montreal.rb November, 5, 2022 Ruby MeetupBecoming a SOC2 Ruby Shop - Montreal.rb November, 5, 2022 Ruby Meetup
Becoming a SOC2 Ruby Shop - Montreal.rb November, 5, 2022 Ruby MeetupAndy Maleh
 
Mail server on Ubuntu Server 12.04 (Postfix, Courier, SSL, SpamAssassin, Clam...
Mail server on Ubuntu Server 12.04 (Postfix, Courier, SSL, SpamAssassin, Clam...Mail server on Ubuntu Server 12.04 (Postfix, Courier, SSL, SpamAssassin, Clam...
Mail server on Ubuntu Server 12.04 (Postfix, Courier, SSL, SpamAssassin, Clam...Mohd Khairulazam
 
Timely Year Two: Lessons Learned Building a Scalable Metrics Analytic System
Timely Year Two: Lessons Learned Building a Scalable Metrics Analytic SystemTimely Year Two: Lessons Learned Building a Scalable Metrics Analytic System
Timely Year Two: Lessons Learned Building a Scalable Metrics Analytic SystemAccumulo Summit
 
Cassandra Summit 2014: Monitor Everything!
Cassandra Summit 2014: Monitor Everything!Cassandra Summit 2014: Monitor Everything!
Cassandra Summit 2014: Monitor Everything!DataStax Academy
 

Ähnlich wie Lightweight use of transients (20)

Speed Things Up with Transients
Speed Things Up with TransientsSpeed Things Up with Transients
Speed Things Up with Transients
 
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
 
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
 
Tt subtemplates-caching
Tt subtemplates-cachingTt subtemplates-caching
Tt subtemplates-caching
 
Artimon - Apache Flume (incubating) NYC Meetup 20111108
Artimon - Apache Flume (incubating) NYC Meetup 20111108Artimon - Apache Flume (incubating) NYC Meetup 20111108
Artimon - Apache Flume (incubating) NYC Meetup 20111108
 
Dynamic Tracing of your AMP web site
Dynamic Tracing of your AMP web siteDynamic Tracing of your AMP web site
Dynamic Tracing of your AMP web site
 
Optimizing Autovacuum: PostgreSQL's vacuum cleaner
Optimizing Autovacuum: PostgreSQL's vacuum cleanerOptimizing Autovacuum: PostgreSQL's vacuum cleaner
Optimizing Autovacuum: PostgreSQL's vacuum cleaner
 
Say YES to Premature Optimizations
Say YES to Premature OptimizationsSay YES to Premature Optimizations
Say YES to Premature Optimizations
 
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
 
Bottom to Top Stack Optimization with LAMP
Bottom to Top Stack Optimization with LAMPBottom to Top Stack Optimization with LAMP
Bottom to Top Stack Optimization with LAMP
 
Bottom to Top Stack Optimization - CICON2011
Bottom to Top Stack Optimization - CICON2011Bottom to Top Stack Optimization - CICON2011
Bottom to Top Stack Optimization - CICON2011
 
Terraform at Scale
Terraform at ScaleTerraform at Scale
Terraform at Scale
 
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...
 
Solr @ Etsy - Apache Lucene Eurocon
Solr @ Etsy - Apache Lucene EuroconSolr @ Etsy - Apache Lucene Eurocon
Solr @ Etsy - Apache Lucene Eurocon
 
Configure, Debug and Install OpenStack Trove
Configure, Debug and Install OpenStack TroveConfigure, Debug and Install OpenStack Trove
Configure, Debug and Install OpenStack Trove
 
A22 Introduction to DTrace by Kyle Hailey
A22 Introduction to DTrace by Kyle HaileyA22 Introduction to DTrace by Kyle Hailey
A22 Introduction to DTrace by Kyle Hailey
 
Becoming a SOC2 Ruby Shop - Montreal.rb November, 5, 2022 Ruby Meetup
Becoming a SOC2 Ruby Shop - Montreal.rb November, 5, 2022 Ruby MeetupBecoming a SOC2 Ruby Shop - Montreal.rb November, 5, 2022 Ruby Meetup
Becoming a SOC2 Ruby Shop - Montreal.rb November, 5, 2022 Ruby Meetup
 
Mail server on Ubuntu Server 12.04 (Postfix, Courier, SSL, SpamAssassin, Clam...
Mail server on Ubuntu Server 12.04 (Postfix, Courier, SSL, SpamAssassin, Clam...Mail server on Ubuntu Server 12.04 (Postfix, Courier, SSL, SpamAssassin, Clam...
Mail server on Ubuntu Server 12.04 (Postfix, Courier, SSL, SpamAssassin, Clam...
 
Timely Year Two: Lessons Learned Building a Scalable Metrics Analytic System
Timely Year Two: Lessons Learned Building a Scalable Metrics Analytic SystemTimely Year Two: Lessons Learned Building a Scalable Metrics Analytic System
Timely Year Two: Lessons Learned Building a Scalable Metrics Analytic System
 
Cassandra Summit 2014: Monitor Everything!
Cassandra Summit 2014: Monitor Everything!Cassandra Summit 2014: Monitor Everything!
Cassandra Summit 2014: Monitor Everything!
 

Mehr von Phil Marx

New Ranking Metrics by Google
New Ranking Metrics by GoogleNew Ranking Metrics by Google
New Ranking Metrics by GooglePhil Marx
 
Die neuen Bewertungskriterien von Google ab 05 / 2021
Die neuen Bewertungskriterien von Google ab 05 / 2021Die neuen Bewertungskriterien von Google ab 05 / 2021
Die neuen Bewertungskriterien von Google ab 05 / 2021Phil Marx
 
Podcasting unter WordPress
Podcasting unter WordPressPodcasting unter WordPress
Podcasting unter WordPressPhil Marx
 
DSGVO und WordPress
 DSGVO und WordPress DSGVO und WordPress
DSGVO und WordPressPhil Marx
 
Aus Englisch mach Deutsch
Aus Englisch mach DeutschAus Englisch mach Deutsch
Aus Englisch mach DeutschPhil Marx
 
Evernote - Dein virtuelles Gedächtnis - a.k.a. das unterschätzte Tool
Evernote - Dein virtuelles Gedächtnis - a.k.a. das unterschätzte ToolEvernote - Dein virtuelles Gedächtnis - a.k.a. das unterschätzte Tool
Evernote - Dein virtuelles Gedächtnis - a.k.a. das unterschätzte ToolPhil Marx
 

Mehr von Phil Marx (6)

New Ranking Metrics by Google
New Ranking Metrics by GoogleNew Ranking Metrics by Google
New Ranking Metrics by Google
 
Die neuen Bewertungskriterien von Google ab 05 / 2021
Die neuen Bewertungskriterien von Google ab 05 / 2021Die neuen Bewertungskriterien von Google ab 05 / 2021
Die neuen Bewertungskriterien von Google ab 05 / 2021
 
Podcasting unter WordPress
Podcasting unter WordPressPodcasting unter WordPress
Podcasting unter WordPress
 
DSGVO und WordPress
 DSGVO und WordPress DSGVO und WordPress
DSGVO und WordPress
 
Aus Englisch mach Deutsch
Aus Englisch mach DeutschAus Englisch mach Deutsch
Aus Englisch mach Deutsch
 
Evernote - Dein virtuelles Gedächtnis - a.k.a. das unterschätzte Tool
Evernote - Dein virtuelles Gedächtnis - a.k.a. das unterschätzte ToolEvernote - Dein virtuelles Gedächtnis - a.k.a. das unterschätzte Tool
Evernote - Dein virtuelles Gedächtnis - a.k.a. das unterschätzte Tool
 

Kürzlich hochgeladen

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
 
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
 
Microsoft Azure Arc Customer Deck Microsoft
Microsoft Azure Arc Customer Deck MicrosoftMicrosoft Azure Arc Customer Deck Microsoft
Microsoft Azure Arc Customer Deck MicrosoftAanSulistiyo
 
Trump Diapers Over Dems t shirts Sweatshirt
Trump Diapers Over Dems t shirts SweatshirtTrump Diapers Over Dems t shirts Sweatshirt
Trump Diapers Over Dems t shirts Sweatshirtrahman018755
 
"Boost Your Digital Presence: Partner with a Leading SEO Agency"
"Boost Your Digital Presence: Partner with a Leading SEO Agency""Boost Your Digital Presence: Partner with a Leading SEO Agency"
"Boost Your Digital Presence: Partner with a Leading SEO Agency"growthgrids
 
Story Board.pptxrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr
Story Board.pptxrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrStory Board.pptxrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr
Story Board.pptxrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrHenryBriggs2
 
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 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
 
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
 
Busty Desi⚡Call Girls in Vasundhara Ghaziabad >༒8448380779 Escort Service
Busty Desi⚡Call Girls in Vasundhara Ghaziabad >༒8448380779 Escort ServiceBusty Desi⚡Call Girls in Vasundhara Ghaziabad >༒8448380779 Escort Service
Busty Desi⚡Call Girls in Vasundhara Ghaziabad >༒8448380779 Escort ServiceDelhi Call girls
 
20240507 QFM013 Machine Intelligence Reading List April 2024.pdf
20240507 QFM013 Machine Intelligence Reading List April 2024.pdf20240507 QFM013 Machine Intelligence Reading List April 2024.pdf
20240507 QFM013 Machine Intelligence Reading List April 2024.pdfMatthew Sinclair
 
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
 
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
 
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
 
Wadgaon Sheri $ Call Girls Pune 10k @ I'm VIP Independent Escorts Girls 80057...
Wadgaon Sheri $ Call Girls Pune 10k @ I'm VIP Independent Escorts Girls 80057...Wadgaon Sheri $ Call Girls Pune 10k @ I'm VIP Independent Escorts Girls 80057...
Wadgaon Sheri $ Call Girls Pune 10k @ I'm VIP Independent Escorts Girls 80057...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
 
best call girls in Hyderabad Finest Escorts Service 📞 9352988975 📞 Available ...
best call girls in Hyderabad Finest Escorts Service 📞 9352988975 📞 Available ...best call girls in Hyderabad Finest Escorts Service 📞 9352988975 📞 Available ...
best call girls in Hyderabad Finest Escorts Service 📞 9352988975 📞 Available ...kajalverma014
 
APNIC Updates presented by Paul Wilson at ARIN 53
APNIC Updates presented by Paul Wilson at ARIN 53APNIC Updates presented by Paul Wilson at ARIN 53
APNIC Updates presented by Paul Wilson at ARIN 53APNIC
 
20240508 QFM014 Elixir Reading List April 2024.pdf
20240508 QFM014 Elixir Reading List April 2024.pdf20240508 QFM014 Elixir Reading List April 2024.pdf
20240508 QFM014 Elixir Reading List April 2024.pdfMatthew Sinclair
 

Kürzlich hochgeladen (20)

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...
 
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...
 
Microsoft Azure Arc Customer Deck Microsoft
Microsoft Azure Arc Customer Deck MicrosoftMicrosoft Azure Arc Customer Deck Microsoft
Microsoft Azure Arc Customer Deck Microsoft
 
Trump Diapers Over Dems t shirts Sweatshirt
Trump Diapers Over Dems t shirts SweatshirtTrump Diapers Over Dems t shirts Sweatshirt
Trump Diapers Over Dems t shirts Sweatshirt
 
"Boost Your Digital Presence: Partner with a Leading SEO Agency"
"Boost Your Digital Presence: Partner with a Leading SEO Agency""Boost Your Digital Presence: Partner with a Leading SEO Agency"
"Boost Your Digital Presence: Partner with a Leading SEO Agency"
 
Story Board.pptxrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr
Story Board.pptxrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrStory Board.pptxrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr
Story Board.pptxrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr
 
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 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...
 
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
 
Busty Desi⚡Call Girls in Vasundhara Ghaziabad >༒8448380779 Escort Service
Busty Desi⚡Call Girls in Vasundhara Ghaziabad >༒8448380779 Escort ServiceBusty Desi⚡Call Girls in Vasundhara Ghaziabad >༒8448380779 Escort Service
Busty Desi⚡Call Girls in Vasundhara Ghaziabad >༒8448380779 Escort Service
 
20240507 QFM013 Machine Intelligence Reading List April 2024.pdf
20240507 QFM013 Machine Intelligence Reading List April 2024.pdf20240507 QFM013 Machine Intelligence Reading List April 2024.pdf
20240507 QFM013 Machine Intelligence Reading List April 2024.pdf
 
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...
 
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...
 
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...
 
Wadgaon Sheri $ Call Girls Pune 10k @ I'm VIP Independent Escorts Girls 80057...
Wadgaon Sheri $ Call Girls Pune 10k @ I'm VIP Independent Escorts Girls 80057...Wadgaon Sheri $ Call Girls Pune 10k @ I'm VIP Independent Escorts Girls 80057...
Wadgaon Sheri $ Call Girls Pune 10k @ I'm VIP Independent Escorts Girls 80057...
 
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
 
best call girls in Hyderabad Finest Escorts Service 📞 9352988975 📞 Available ...
best call girls in Hyderabad Finest Escorts Service 📞 9352988975 📞 Available ...best call girls in Hyderabad Finest Escorts Service 📞 9352988975 📞 Available ...
best call girls in Hyderabad Finest Escorts Service 📞 9352988975 📞 Available ...
 
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...
 
APNIC Updates presented by Paul Wilson at ARIN 53
APNIC Updates presented by Paul Wilson at ARIN 53APNIC Updates presented by Paul Wilson at ARIN 53
APNIC Updates presented by Paul Wilson at ARIN 53
 
20240508 QFM014 Elixir Reading List April 2024.pdf
20240508 QFM014 Elixir Reading List April 2024.pdf20240508 QFM014 Elixir Reading List April 2024.pdf
20240508 QFM014 Elixir Reading List April 2024.pdf
 

Lightweight use of transients

  • 2. Phil Marx @JustPhilMarx www.nerdtalk.de / phil.marx@gmail.com Works with WordPress since v2.x 2
  • 4. “WordPress Transients API […] offers a simple and standardized way of storing cached data in the database temporarily […] 44 https://codex.wordpress.org/Transients_API
  • 5. Examples for Transients ▰Results of complex queries ▰Results of remote calls ▰Complex aggregations of different values 5
  • 6. Advantage: Simple usage ▰set_transient() – sets a transient ▻ set_transient( $transient, $value, $expiration ); ▰get_transient() – gets a transient ▻ get_transient( $transient ); ▰delete_transient() – deletes a transient ▻ delete_transient( $transient ); 6
  • 7. Transients are designed to expire ▰set_transient() – sets a transient ▻ set_transient( $transient, $value, $expiration ); ▰get_transient() – gets a transient ▻ get_transient( $transient ); ▰delete_transient() – deletes a transient ▻ delete_transient( $transient ); 7
  • 8. “WordPress Transients API […] offers a simple and standardized way of storing cached data in the database temporarily by giving it a […] timeframe after which it will expire and be deleted. 88 https://codex.wordpress.org/Transients_API
  • 10. Downsides of deletion ▰Leads to database fragmentation ▻Can cause slow database performance ▰A new dataset is created for the same content ▻Just… why?! 10
  • 11. What codex recommends if(false===$value=get_transient('value’))) { // this code runs when there is no valid transient set } https://codex.wordpress.org/Transients_API 11
  • 12. My approach to a lightweight use of transients ▰Set a expiration time in a far away future ▰Set an own timeout and update! 12 If a transient exists, this function will update the transient's expiration time. https://codex.wordpress.org/Function_Reference/set_transient
  • 13. Code example // Setting my own timeout $timeout_transient = 60 * 5; $stream = get_transient('streaminglive'); // Fallback if transient was deleted before expiration if (!is_object($stream)) $stream = new stdClass; // I'll save the last check into a variable "last_check" (see below) - if the transient is expired based on my timeout, renew it if (!isset($stream->last_check) || $timeout_stream < (time() - $stream->last_check)) { // Do whatever you need to get/update your data $stream->last_check = time(); /* Attention: - The timeout of the transient is much more than my personal timeout - set_transient checks, if there is a valid transient and will update it instead of creating a new one */ set_transient('streaminglive', $stream, 60 * 60); } 13
  • 14. 14 Expired transients are only deleted, if they‘re requested again
  • 15. CLEAN UP YOUR OWN TRANSIENTS! Just. Do. It! 15 3
  • 16. Causes for not requesting transients anymore ▰Adding unique identifier to transient key ▻(Session ID, time(), some hashes, …) ▰Forget deletion when deactivating plugins/themes 16
  • 17. Expired and orphaned transients need to be deleted manually ▰Plugins ▻ „Delete expired transients“ ▰SQL Queries ▻Only useful in combination with cronjobs / WP-Cron 17
  • 18. “▰We deleted about 143,513 rows of transient entries bringing the wp_options table from 8Gb to 200mb 18 https://theeventscalendar.com/support/forums/topic/large-number-of-transients-in-wp_options-table/
  • 19. “▰In wp_options was about 7000 rows (1,5 Gb). […] At the moment 672 rows (2,6 Mb). 19 https://theeventscalendar.com/support/forums/topic/large-number-of-transients-in-wp_options-table/
  • 20. DON’T LET THE USER DO YOUR WORK!
  • 21. Don‘t be that guy! ▰Tidy up after deactivation of your theme / plugin ▻ delete_transient( $transient ); ▰Use WP Cron event to delete orphaned transients ▻delete-transients-by-prefix.php (GitHub) 21
  • 23. Be lightweight! ▰Add your own timeout ▰Think if you need unique identifier which are for temporary usage ▰Clean up your transients 23
  • 24. 24 THANKS!Any questions? You can find me at @JustPhilMarx / nerdtalk.de phil.marx@gmail.com Thanks to - SlidesCarnival for Slides template and Icons (CC BY 4.0) - Alexandru Zdrobău for girl photo (CC0)

Hinweis der Redaktion

  1. No expiration needed  but then it‘s autoloaded (don‘t want!)
  2. - Each time a new ID is generated – BIGINT is nice, but not expanding them to the limits is nicer
  3. - A transient can expire before expiration date