Support » Plugin: Featured Image Column » Delete Object Cache (Memcache)

  • Resolved sgatz


    Love this plugin, but one little bug, if you are using an external object cache (like APC or Memcache) and you look at your posts list and see a missing featured image, then you add one, the list still shows that you don’t have a featured image (or if you change one it shows the old). This is due to caching. I created this simple function for my functions file to solve it. It’d be great if you can integrate this into your code:

    * ADMIN: Clear cache for featured image column plugin when new featured image
    * only useful as long as featured image column plugin is active
    * could be a conditional to check if meta_key=_thumbnail_id, but figured the lookup isn’t worth it, just delete the cache on all post meta updates for a post

    function fic_thumbnail_updated_actions($meta_id, $post_id) {

    $post_id = (int) $post_id;
    $cache_key = “featured_image_post_id-{$post_id}-_thumbnail”;
    $cache = wp_cache_delete( $cache_key, null );

    add_action( ‘deleted_post_meta’, ‘fic_thumbnail_updated_actions’, 10, 2 );
    add_action( ‘updated_post_meta’, ‘fic_thumbnail_updated_actions’, 10, 2 );
    add_action( ‘added_post_meta’, ‘fic_thumbnail_updated_actions’, 10, 2 );

  • The topic ‘Delete Object Cache (Memcache)’ is closed to new replies.