transient or not transient

Transients are a simple way of storing cached data in the database temporarily by giving it a custom name and a timeframe after which it will expire and be deleted. So yes, it will be a good idea to get data from second DB and store it as a transient. First thing you have to … Read more

Is this the proper usage of creating / using a transient?

No quite: Get the transient’s content first, then do the expensive work to fetch the external resource. function google_transient() { $transient_name=”google”; $content = get_transient( $transient_name ); // done if ( $content ) return $content; $url=”http://www.google.com”; $content = wp_remote_retrieve_body( wp_remote_get($url) ); set_transient( $transient_name, $content, DAY_IN_SECONDS ); // 24 hour cache return $content; }

WordPress transient doesn’t use the transient

I mean in shortly your code is wrong in the first line, the comparing is wrong. The variable $post should store = the data of the request via get_transient() and not compare ===. So you should switch to: if ( false === ( $posts = get_transient(‘posts_array’) ) ) { // this code runs when there … Read more

Set Transient expiration

The countdown would start as soon as the transient is created or updated. Running set_transient() on an existing transient value will restart the clock. Per the Codex page on set_transient(): If a transient exists, this function will update the transient’s expiration time. According to the Transients API page, the expiration time is the maximum lifetime … Read more

How to delete transients written by fetch_feed()?

This data should be automatically deleted after 12 hours, that’s the default feed cache TTL. So this kind of house cleaning, for data added by the WordPress transients API, might be unnecessary. But let’s check out what kind of data is stored. If you take for example the feed for your current question: http://wordpress.stackexchange.com/feeds/question/172444 and … Read more

How to use transients and variables

You’re saving the data in a loop under the same key for each iteration. You’ll have to add the index of the current iteration of the loop to the key if you want a unique value for each. Something like: $i = 0; while ( have_rows(‘images’) ): the_row(); fragment_cache(‘cms_images_text_’ . $i . ‘_’ . $post->ID, … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)