{"id":2156,"date":"2013-03-16T17:10:50","date_gmt":"2013-03-16T17:10:50","guid":{"rendered":"https:\/\/2013.atlanta.wordcamp.org\/?p=2156"},"modified":"2013-03-18T17:55:49","modified_gmt":"2013-03-18T17:55:49","slug":"live-blogging-speed-things-up-with-transients%e2%80%a8","status":"publish","type":"post","link":"https:\/\/atlanta.wordcamp.org\/2013\/live-blogging-speed-things-up-with-transients%e2%80%a8\/","title":{"rendered":"Speed Things Up With Transients\u2028"},"content":{"rendered":"<p><strong>Speaker:<\/strong> Cliff Seal<br \/>\n<strong>Twitter:<\/strong> <a href=\"http:\/\/www.twitter.com\/cliffseal\" target=\"_blank\">@cliffseal<\/a><br \/>\n<strong>Presentation Slides:<\/strong> <a href=\"http:\/\/www.logos-creative.com\/wcatl\" target=\"_blank\">logos-creative.com\/wcatl<\/a><\/p>\n<p><strong>What is the transients API<\/strong><\/p>\n<ul>\n<li>simple way to store cached data in the database temporarily by giving it a name and timeframe after which it will expire<\/li>\n<li>like options API, but with expiration<\/li>\n<li>uses fast memory (if configured)<\/li>\n<li>uses database otherwise<\/li>\n<\/ul>\n<p><strong>What can you do with it?<\/strong><\/p>\n<ul>\n<li>external APIs &#8211; tweets, friends, scrobbles<\/li>\n<li>cache expensive queries &#8211; tag cloud, ratings, custom queries<\/li>\n<\/ul>\n<p><strong>set_transient<\/strong><\/p>\n<ul>\n<li>$transient\n<ul>\n<li>(string) a unique identifiedr for your cached data<\/li>\n<li>45 characters or less in length<\/li>\n<li>For multi-site transients, 40 characters or less in length<\/li>\n<\/ul>\n<\/li>\n<li>$value\n<ul>\n<li>(array|object) Data to save, either a regular variable or an array\/object<\/li>\n<li>Handles serialization for you<\/li>\n<\/ul>\n<\/li>\n<li>$expiration\n<ul>\n<li>(integer) number of seconds to keep the data before refreshing<\/li>\n<li>built in wordpress time functions<\/li>\n<\/ul>\n<\/li>\n<li>get_transient($transient);\n<ul>\n<li>if the transient does not exist, or has expired, returns false<\/li>\n<li>an integer value of zero\/empty or could be the stored data<\/li>\n<li>should not be used to hold plain boolean values; array or integers instead<\/li>\n<\/ul>\n<\/li>\n<li>delete_transient($transient);<\/li>\n<li>multi-site\n<ul>\n<li>set_site_transient<\/li>\n<li>get_site_transient<\/li>\n<li>delete_site_transient<\/li>\n<\/ul>\n<\/li>\n<li>warnings\n<ul>\n<li>everything works on request<\/li>\n<li>expired != deleted, unless requested<\/li>\n<li>unrequested, undeleted transients stay until you remove them explicitly<\/li>\n<\/ul>\n<\/li>\n<li>scalar\n<ul>\n<li>accepts scalar values (integer, float, string or boolean) &amp; non-scalar serializable values (arrays, some objects)<\/li>\n<li>SimpleXMLElement will FREAK OUT, so convert it to a string or array of objects (i.e. simplexml_load_string)<\/li>\n<\/ul>\n<\/li>\n<li>infinite\n<ul>\n<li>transients set without an expiration time are autoloaded<\/li>\n<li>if you don\u2019t need it on every page, set an expiration (even if it\u2019s a year)<\/li>\n<li>consider the Options API for non-transient data<\/li>\n<\/ul>\n<\/li>\n<li>caching\n<ul>\n<li>in some shared hosting environments, object caching can be slower than using the database; check your host\u2019s recommended settings<\/li>\n<li>always use the Transients API to access transients; don\u2019t assume they\u2019re in the database (or vice versa)<\/li>\n<\/ul>\n<\/li>\n<li>3 useful tools\n<ul>\n<li>TLC Transients &#8211; supports soft-expiration, background updating<\/li>\n<li>Debug Bar Transients &#8211; adds panel to debug bar with transient info<\/li>\n<li>Artiss Transient Cleaner &#8211; Deletes expired transients and optimizes table<\/li>\n<\/ul>\n<\/li>\n<p>\n<strong>Lots of code examples, be sure to checkout the <a href=\"http:\/\/www.logos-creative.com\/wcatl\" target=\"_blank\">presenter slides<\/a>!<\/strong><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Speaker: Cliff Seal Twitter: @cliffseal Presentation Slides: logos-creative.com\/wcatl What is the transients API simple way to store cached data in the database temporarily by giving it a name and timeframe after which it will expire like options API, but with expiration uses fast memory (if configured) uses database otherwise What can you do with it? [&hellip;]<\/p>\n","protected":false},"author":8480538,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[126376],"tags":[],"class_list":["post-2156","post","type-post","status-publish","format-standard","hentry","category-live-blogging"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p2YmVp-yM","_links":{"self":[{"href":"https:\/\/atlanta.wordcamp.org\/2013\/wp-json\/wp\/v2\/posts\/2156","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/atlanta.wordcamp.org\/2013\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/atlanta.wordcamp.org\/2013\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/atlanta.wordcamp.org\/2013\/wp-json\/wp\/v2\/users\/8480538"}],"replies":[{"embeddable":true,"href":"https:\/\/atlanta.wordcamp.org\/2013\/wp-json\/wp\/v2\/comments?post=2156"}],"version-history":[{"count":5,"href":"https:\/\/atlanta.wordcamp.org\/2013\/wp-json\/wp\/v2\/posts\/2156\/revisions"}],"predecessor-version":[{"id":2198,"href":"https:\/\/atlanta.wordcamp.org\/2013\/wp-json\/wp\/v2\/posts\/2156\/revisions\/2198"}],"wp:attachment":[{"href":"https:\/\/atlanta.wordcamp.org\/2013\/wp-json\/wp\/v2\/media?parent=2156"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/atlanta.wordcamp.org\/2013\/wp-json\/wp\/v2\/categories?post=2156"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/atlanta.wordcamp.org\/2013\/wp-json\/wp\/v2\/tags?post=2156"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}