Synchronize Data every minute with set_transient

To my understanding, *_transient() is basically *_option() wrapped in a cache-timer. What that means in this context, is that set_transient( ‘…’, true, * MINUTE_IN_SECONDS ); will not run/re-evaluate every minute. Instead it will run/re-evaluate when the page has loaded by a visitor/user, and the data therein is older than 60 seconds. This is not ideal … Read more

How many transients is too many transients

It depends if you add an expiration time. If you do not add an expiration time then autoload will be yes. This means the option that stores this transient will be loaded on every request even if it’s not used. With large numbers of transients this poses an issue purely in terms of memory. I … Read more

Transient api Caches confused

“This code works” – but it doesn’t! If you’re gonna cache paginated posts, you’ll need to store them chunked: if ( ! $my_paged = absint( get_query_var( ‘paged’ ) ) ) $my_paged = 1; if ( ! $my_query = get_transient( “recent_$paged” ) ) { $my_query = new WP_Query( “cat=3&posts_per_page=5&paged=$my_paged” ); set_transient( “recent_$paged”, $my_query, 60 * 60 … Read more

Compare custom taxonomies of updated post (or new post) [Updated with progress]

Use the set_object_terms hook, http://adambrown.info/p/wp_hooks/hook/set_object_terms?version=3.4&file=wp-includes/taxonomy.php It should be fired when a post or page is modified. Here is the code that fires it: do_action(‘set_object_terms’, $object_id, $terms, $tt_ids, $taxonomy, $append, $old_tt_ids); You can thus check against the $object_id and taxonomy, and flush your transient cache and regenerate as needed. Specifically, clear the term caches of the … Read more

Why Transients may not work correctly?

By the definition and the usage pattern, transients might be deleted at any point in time, the expiry time parameter really specifies only the maximal time the value will be cached. It might be that the particular site has a problem with transients not being cleaned on time and employs some code to clean them … Read more

How to cache wp_query with pagination using transients?

You need to set a unique transient key for each page of posts otherwise each page will output same posts. Here is a example. Focus on get_transient & set_transient functions. <?php $my_posts_query = get_transient( ‘my_unique_transient_key_’ . get_query_var( ‘paged’ ) ); if( false === $my_posts_query ) { $args = array( ‘post_type’ => ‘post’, ‘posts_per_page’ => ’12’, … Read more

Transients with dynamic WP_Query

I have read quite a few of your posts and it seems like your queries are really complex which either slows the page or simply crashes it. Transients are definitely an option to store the results of such labor intensive queries. As @s_ha_dum mentioned, you’ll need to look into what you will be saving. Would … Read more

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