kevinweber / lazy-load-for-videos

Speed up your site by replacing embedded Youtube and Vimeo videos with a clickable preview image. Free WordPress plugin.
http://wordpress.org/plugins/lazy-load-for-videos/
GNU General Public License v3.0
41 stars 22 forks source link

Improvements to clearing oembed caches #1

Closed msigley closed 10 years ago

msigley commented 10 years ago

Kevin,

I saw your post on the issue report for improvements to the oembed caches. I saw you were asking for suggestion to improve your cache clear method. Here is a function I use in one of my plugins. It is much more efficent. You could narrow its focus down by post_type by doing a MySQL JOIN.

function delete_all_oembed_caches() {
                global $wpdb;
        $query = $wpdb->prepare( 
                    "DELETE FROM `".$wpdb->postmeta."`
                        WHERE `meta_key` LIKE '|_oembed|_%%' ESCAPE '|'
                            OR `meta_key` LIKE '|_oembed|_time|_%%' ESCAPE '|'"
                    );
        $result = $wpdb->query($query);
    }
kevinweber commented 10 years ago

Hey, YOU ARE AMAZING! Here's the commit that implements your suggestion: https://github.com/kevinweber/lazy-load-for-videos/commit/5b3d20153e26050f1903b92ca58707454d207012

On a small test site, this reduced the total query time from 1,300 ms to 200 ms and the amount of queries from 1,050 to 100.

Because of your help, I want to give you the premium version for free. Simply send me a mail to my mail address from http://kevinw.de/kontakt/ and I'll give you a 100% discount.

Feel free to suggest any other improvements.

Best regards, Kevin

PS: Thanks again!