• Dear Ajay,

    I’m using your plugin and make my own function based on tptn_pop_posts to personalize outputs.

    After inspecting the way you query results I’ve saw that you don’t use http://codex.wordpress.org/Transients_API

    Query monitor plugin always show me information that tptn_pop_posts query always slowest.

    So, I wrapped
    $results = $wpdb->get_results( $sql );

    this way:

    if ( false === ( $results = get_transient( 'tptn_pop_posts_desktop_view' ) ) ) {
            // It wasn't there, so regenerate the data and save the transient
            $results = $wpdb->get_results( $sql );
            set_transient( 'tptn_pop_posts_desktop_view', $results, 12 * HOUR_IN_SECONDS );
        }

    and got a better performance ! 🙂

    https://wordpress.org/plugins/top-10/

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Ajay

    (@ajay)

    Hi Slams,

    Thanks for the code. It’s definitely something I’ve thought about but kept pending. Your code above should cache the mySQL results for 12 hours.

    Wouldn’t this prevent the sites from showing the latest popular posts?

    However, being said, that would help those who want to cache the output, so I’ll put this into a future release with an option to enable

    Thread Starter Slams

    (@slams)

    Ajay,

    This code adapted for me, because I display popular posts per month and new data don’t needed to me frequently, but you can adopt this api for your purposes.

    Also, pay attention to this API http://codex.wordpress.org/Class_Reference/WP_Object_Cache
    In some cases it’s better to use Object Cache API.

    Have a nice day!

    Plugin Author Ajay

    (@ajay)

    Thanks. I’ll take a look at this.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Cache wpdb->result’ is closed to new replies.