SlideShare a Scribd company logo
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)

More Related Content

What's hot

Learning Dtrace
Learning DtraceLearning Dtrace
Learning Dtrace
JeongHun Byeon
 
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 TDD
Eric 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 2013
Puppet
 
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
Eric Hogue
 
Common Performance Pitfalls in Odoo apps
Common Performance Pitfalls in Odoo appsCommon Performance Pitfalls in Odoo apps
Common Performance Pitfalls in Odoo apps
Odoo
 
Continuous testing In PHP
Continuous testing In PHPContinuous testing In PHP
Continuous testing In PHP
Eric 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 Nagios
Nagios
 

What's hot (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
 

Similar to Lightweight use of transients

Speed Things Up with Transients
Speed Things Up with TransientsSpeed Things Up with Transients
Speed Things Up with Transients
Cliff 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 2016
Boiteaweb
 
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
Cliff 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 20111108
Mathias 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 site
Sriram Natarajan
 
Optimizing Autovacuum: PostgreSQL's vacuum cleaner
Optimizing Autovacuum: PostgreSQL's vacuum cleanerOptimizing Autovacuum: PostgreSQL's vacuum cleaner
Optimizing Autovacuum: PostgreSQL's vacuum cleaner
SamaySharma10
 
Say YES to Premature Optimizations
Say YES to Premature OptimizationsSay YES to Premature Optimizations
Say YES to Premature Optimizations
Maude 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 2014
Cliff Seal
 
Bottom to Top Stack Optimization - CICON2011
Bottom to Top Stack Optimization - CICON2011Bottom to Top Stack Optimization - CICON2011
Bottom to Top Stack Optimization - CICON2011CodeIgniter Conference
 
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
katzgrau
 
Terraform at Scale
Terraform at ScaleTerraform at Scale
Terraform at Scale
Calvin French-Owen
 
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 Trove
Rama 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 Meetup
Andy 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 System
Accumulo Summit
 
Cassandra Summit 2014: Monitor Everything!
Cassandra Summit 2014: Monitor Everything!Cassandra Summit 2014: Monitor Everything!
Cassandra Summit 2014: Monitor Everything!
DataStax Academy
 

Similar to 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 - CICON2011
Bottom to Top Stack Optimization - CICON2011Bottom to Top Stack Optimization - CICON2011
Bottom to Top Stack Optimization - CICON2011
 
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
 
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!
 

More from Phil Marx

New Ranking Metrics by Google
New Ranking Metrics by GoogleNew Ranking Metrics by Google
New Ranking Metrics by Google
Phil 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 / 2021
Phil Marx
 
Podcasting unter WordPress
Podcasting unter WordPressPodcasting unter WordPress
Podcasting unter WordPress
Phil Marx
 
DSGVO und WordPress
 DSGVO und WordPress DSGVO und WordPress
DSGVO und WordPress
Phil Marx
 
Aus Englisch mach Deutsch
Aus Englisch mach DeutschAus Englisch mach Deutsch
Aus Englisch mach Deutsch
Phil 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 Tool
Phil Marx
 

More from 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
 

Recently uploaded

重新申请毕业证书(RMIT毕业证)皇家墨尔本理工大学毕业证成绩单精仿办理
重新申请毕业证书(RMIT毕业证)皇家墨尔本理工大学毕业证成绩单精仿办理重新申请毕业证书(RMIT毕业证)皇家墨尔本理工大学毕业证成绩单精仿办理
重新申请毕业证书(RMIT毕业证)皇家墨尔本理工大学毕业证成绩单精仿办理
vmemo1
 
制作毕业证书(ANU毕业证)莫纳什大学毕业证成绩单官方原版办理
制作毕业证书(ANU毕业证)莫纳什大学毕业证成绩单官方原版办理制作毕业证书(ANU毕业证)莫纳什大学毕业证成绩单官方原版办理
制作毕业证书(ANU毕业证)莫纳什大学毕业证成绩单官方原版办理
cuobya
 
Bridging the Digital Gap Brad Spiegel Macon, GA Initiative.pptx
Bridging the Digital Gap Brad Spiegel Macon, GA Initiative.pptxBridging the Digital Gap Brad Spiegel Macon, GA Initiative.pptx
Bridging the Digital Gap Brad Spiegel Macon, GA Initiative.pptx
Brad Spiegel Macon GA
 
test test test test testtest test testtest test testtest test testtest test ...
test test  test test testtest test testtest test testtest test testtest test ...test test  test test testtest test testtest test testtest test testtest test ...
test test test test testtest test testtest test testtest test testtest test ...
Arif0071
 
Explore-Insanony: Watch Instagram Stories Secretly
Explore-Insanony: Watch Instagram Stories SecretlyExplore-Insanony: Watch Instagram Stories Secretly
Explore-Insanony: Watch Instagram Stories Secretly
Trending Blogers
 
国外证书(Lincoln毕业证)新西兰林肯大学毕业证成绩单不能毕业办理
国外证书(Lincoln毕业证)新西兰林肯大学毕业证成绩单不能毕业办理国外证书(Lincoln毕业证)新西兰林肯大学毕业证成绩单不能毕业办理
国外证书(Lincoln毕业证)新西兰林肯大学毕业证成绩单不能毕业办理
zoowe
 
2.Cellular Networks_The final stage of connectivity is achieved by segmenting...
2.Cellular Networks_The final stage of connectivity is achieved by segmenting...2.Cellular Networks_The final stage of connectivity is achieved by segmenting...
2.Cellular Networks_The final stage of connectivity is achieved by segmenting...
JeyaPerumal1
 
Understanding User Behavior with Google Analytics.pdf
Understanding User Behavior with Google Analytics.pdfUnderstanding User Behavior with Google Analytics.pdf
Understanding User Behavior with Google Analytics.pdf
SEO Article Boost
 
Internet of Things in Manufacturing: Revolutionizing Efficiency & Quality | C...
Internet of Things in Manufacturing: Revolutionizing Efficiency & Quality | C...Internet of Things in Manufacturing: Revolutionizing Efficiency & Quality | C...
Internet of Things in Manufacturing: Revolutionizing Efficiency & Quality | C...
CIOWomenMagazine
 
一比一原版(SLU毕业证)圣路易斯大学毕业证成绩单专业办理
一比一原版(SLU毕业证)圣路易斯大学毕业证成绩单专业办理一比一原版(SLU毕业证)圣路易斯大学毕业证成绩单专业办理
一比一原版(SLU毕业证)圣路易斯大学毕业证成绩单专业办理
keoku
 
可查真实(Monash毕业证)西澳大学毕业证成绩单退学买
可查真实(Monash毕业证)西澳大学毕业证成绩单退学买可查真实(Monash毕业证)西澳大学毕业证成绩单退学买
可查真实(Monash毕业证)西澳大学毕业证成绩单退学买
cuobya
 
Search Result Showing My Post is Now Buried
Search Result Showing My Post is Now BuriedSearch Result Showing My Post is Now Buried
Search Result Showing My Post is Now Buried
Trish Parr
 
[HUN][hackersuli] Red Teaming alapok 2024
[HUN][hackersuli] Red Teaming alapok 2024[HUN][hackersuli] Red Teaming alapok 2024
[HUN][hackersuli] Red Teaming alapok 2024
hackersuli
 
Bài tập unit 1 English in the world.docx
Bài tập unit 1 English in the world.docxBài tập unit 1 English in the world.docx
Bài tập unit 1 English in the world.docx
nhiyenphan2005
 
JAVIER LASA-EXPERIENCIA digital 1986-2024.pdf
JAVIER LASA-EXPERIENCIA digital 1986-2024.pdfJAVIER LASA-EXPERIENCIA digital 1986-2024.pdf
JAVIER LASA-EXPERIENCIA digital 1986-2024.pdf
Javier Lasa
 
学位认证网(DU毕业证)迪肯大学毕业证成绩单一比一原版制作
学位认证网(DU毕业证)迪肯大学毕业证成绩单一比一原版制作学位认证网(DU毕业证)迪肯大学毕业证成绩单一比一原版制作
学位认证网(DU毕业证)迪肯大学毕业证成绩单一比一原版制作
zyfovom
 
Meet up Milano 14 _ Axpo Italia_ Migration from Mule3 (On-prem) to.pdf
Meet up Milano 14 _ Axpo Italia_ Migration from Mule3 (On-prem) to.pdfMeet up Milano 14 _ Axpo Italia_ Migration from Mule3 (On-prem) to.pdf
Meet up Milano 14 _ Axpo Italia_ Migration from Mule3 (On-prem) to.pdf
Florence Consulting
 
急速办(bedfordhire毕业证书)英国贝德福特大学毕业证成绩单原版一模一样
急速办(bedfordhire毕业证书)英国贝德福特大学毕业证成绩单原版一模一样急速办(bedfordhire毕业证书)英国贝德福特大学毕业证成绩单原版一模一样
急速办(bedfordhire毕业证书)英国贝德福特大学毕业证成绩单原版一模一样
3ipehhoa
 
一比一原版(CSU毕业证)加利福尼亚州立大学毕业证成绩单专业办理
一比一原版(CSU毕业证)加利福尼亚州立大学毕业证成绩单专业办理一比一原版(CSU毕业证)加利福尼亚州立大学毕业证成绩单专业办理
一比一原版(CSU毕业证)加利福尼亚州立大学毕业证成绩单专业办理
ufdana
 
一比一原版(LBS毕业证)伦敦商学院毕业证成绩单专业办理
一比一原版(LBS毕业证)伦敦商学院毕业证成绩单专业办理一比一原版(LBS毕业证)伦敦商学院毕业证成绩单专业办理
一比一原版(LBS毕业证)伦敦商学院毕业证成绩单专业办理
eutxy
 

Recently uploaded (20)

重新申请毕业证书(RMIT毕业证)皇家墨尔本理工大学毕业证成绩单精仿办理
重新申请毕业证书(RMIT毕业证)皇家墨尔本理工大学毕业证成绩单精仿办理重新申请毕业证书(RMIT毕业证)皇家墨尔本理工大学毕业证成绩单精仿办理
重新申请毕业证书(RMIT毕业证)皇家墨尔本理工大学毕业证成绩单精仿办理
 
制作毕业证书(ANU毕业证)莫纳什大学毕业证成绩单官方原版办理
制作毕业证书(ANU毕业证)莫纳什大学毕业证成绩单官方原版办理制作毕业证书(ANU毕业证)莫纳什大学毕业证成绩单官方原版办理
制作毕业证书(ANU毕业证)莫纳什大学毕业证成绩单官方原版办理
 
Bridging the Digital Gap Brad Spiegel Macon, GA Initiative.pptx
Bridging the Digital Gap Brad Spiegel Macon, GA Initiative.pptxBridging the Digital Gap Brad Spiegel Macon, GA Initiative.pptx
Bridging the Digital Gap Brad Spiegel Macon, GA Initiative.pptx
 
test test test test testtest test testtest test testtest test testtest test ...
test test  test test testtest test testtest test testtest test testtest test ...test test  test test testtest test testtest test testtest test testtest test ...
test test test test testtest test testtest test testtest test testtest test ...
 
Explore-Insanony: Watch Instagram Stories Secretly
Explore-Insanony: Watch Instagram Stories SecretlyExplore-Insanony: Watch Instagram Stories Secretly
Explore-Insanony: Watch Instagram Stories Secretly
 
国外证书(Lincoln毕业证)新西兰林肯大学毕业证成绩单不能毕业办理
国外证书(Lincoln毕业证)新西兰林肯大学毕业证成绩单不能毕业办理国外证书(Lincoln毕业证)新西兰林肯大学毕业证成绩单不能毕业办理
国外证书(Lincoln毕业证)新西兰林肯大学毕业证成绩单不能毕业办理
 
2.Cellular Networks_The final stage of connectivity is achieved by segmenting...
2.Cellular Networks_The final stage of connectivity is achieved by segmenting...2.Cellular Networks_The final stage of connectivity is achieved by segmenting...
2.Cellular Networks_The final stage of connectivity is achieved by segmenting...
 
Understanding User Behavior with Google Analytics.pdf
Understanding User Behavior with Google Analytics.pdfUnderstanding User Behavior with Google Analytics.pdf
Understanding User Behavior with Google Analytics.pdf
 
Internet of Things in Manufacturing: Revolutionizing Efficiency & Quality | C...
Internet of Things in Manufacturing: Revolutionizing Efficiency & Quality | C...Internet of Things in Manufacturing: Revolutionizing Efficiency & Quality | C...
Internet of Things in Manufacturing: Revolutionizing Efficiency & Quality | C...
 
一比一原版(SLU毕业证)圣路易斯大学毕业证成绩单专业办理
一比一原版(SLU毕业证)圣路易斯大学毕业证成绩单专业办理一比一原版(SLU毕业证)圣路易斯大学毕业证成绩单专业办理
一比一原版(SLU毕业证)圣路易斯大学毕业证成绩单专业办理
 
可查真实(Monash毕业证)西澳大学毕业证成绩单退学买
可查真实(Monash毕业证)西澳大学毕业证成绩单退学买可查真实(Monash毕业证)西澳大学毕业证成绩单退学买
可查真实(Monash毕业证)西澳大学毕业证成绩单退学买
 
Search Result Showing My Post is Now Buried
Search Result Showing My Post is Now BuriedSearch Result Showing My Post is Now Buried
Search Result Showing My Post is Now Buried
 
[HUN][hackersuli] Red Teaming alapok 2024
[HUN][hackersuli] Red Teaming alapok 2024[HUN][hackersuli] Red Teaming alapok 2024
[HUN][hackersuli] Red Teaming alapok 2024
 
Bài tập unit 1 English in the world.docx
Bài tập unit 1 English in the world.docxBài tập unit 1 English in the world.docx
Bài tập unit 1 English in the world.docx
 
JAVIER LASA-EXPERIENCIA digital 1986-2024.pdf
JAVIER LASA-EXPERIENCIA digital 1986-2024.pdfJAVIER LASA-EXPERIENCIA digital 1986-2024.pdf
JAVIER LASA-EXPERIENCIA digital 1986-2024.pdf
 
学位认证网(DU毕业证)迪肯大学毕业证成绩单一比一原版制作
学位认证网(DU毕业证)迪肯大学毕业证成绩单一比一原版制作学位认证网(DU毕业证)迪肯大学毕业证成绩单一比一原版制作
学位认证网(DU毕业证)迪肯大学毕业证成绩单一比一原版制作
 
Meet up Milano 14 _ Axpo Italia_ Migration from Mule3 (On-prem) to.pdf
Meet up Milano 14 _ Axpo Italia_ Migration from Mule3 (On-prem) to.pdfMeet up Milano 14 _ Axpo Italia_ Migration from Mule3 (On-prem) to.pdf
Meet up Milano 14 _ Axpo Italia_ Migration from Mule3 (On-prem) to.pdf
 
急速办(bedfordhire毕业证书)英国贝德福特大学毕业证成绩单原版一模一样
急速办(bedfordhire毕业证书)英国贝德福特大学毕业证成绩单原版一模一样急速办(bedfordhire毕业证书)英国贝德福特大学毕业证成绩单原版一模一样
急速办(bedfordhire毕业证书)英国贝德福特大学毕业证成绩单原版一模一样
 
一比一原版(CSU毕业证)加利福尼亚州立大学毕业证成绩单专业办理
一比一原版(CSU毕业证)加利福尼亚州立大学毕业证成绩单专业办理一比一原版(CSU毕业证)加利福尼亚州立大学毕业证成绩单专业办理
一比一原版(CSU毕业证)加利福尼亚州立大学毕业证成绩单专业办理
 
一比一原版(LBS毕业证)伦敦商学院毕业证成绩单专业办理
一比一原版(LBS毕业证)伦敦商学院毕业证成绩单专业办理一比一原版(LBS毕业证)伦敦商学院毕业证成绩单专业办理
一比一原版(LBS毕业证)伦敦商学院毕业证成绩单专业办理
 

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)

Editor's Notes

  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