Support Forums

Looking for support? You can access the support system via your account.

Forums Forums Search & Filter Pro Programmatically Rebuild Cache

Viewing 4 posts - 11 through 14 (of 14 total)
  • Ross Moderator
    #65988

    Hey Paddy

    Why not perform a ajax request to to trigger the rebuild? I think that you would need to be in the admin area for it to work though.

    Alternatively, you can try to do this manually, you would need the class located in

    search-filter-pro/includes/class-search-filter-post-cache.php

    You’d probably just need to init the class –

    $sf_cache = new Search_Filter_Post_Cache();

    Then run the function:

    $sf_cache->cache_restart();

    The function will also start processing the first batch of posts too if wp_remote_post is not working in your environment – so this may cause it to take considerable time to complete (ie, a few seconds, possibly more depending on your environment)

    That being said, this class wasn’t made to be dev friendly at this stage, although looking at it it should just work – be aware of possible changes in future releases where class names and functions may be changed.

    Thanks

    Paddy McCann
    #66152

    Hi Ross,

    That looks great! I will test that out, but if what you said is true about the class names changing in the future, then I’d like to ask maybe there’s another way to what I am really trying to achieve?

    What I am actually doing is:

    1. Delete all posts.
    2. Delete all S&F cache.
    3. Start adding posts one at a time inside a loop. While adding a single post, I am also using do_action('search_filter_update_post_cache', $new_post_id); to generate the new cache as the script proceeds to adding each posts.

    So if it’s okay to rephrase my question a little bit, is there a way for me to “Empty” the cache instead?

    By the way. Thanks for the helpful warning!

    Paddy McCann
    #66541

    Hi!

    Notifying that, the solution Ross mentioned is working. Thanks!

    Trevor Moderator
    #66543

    Hi

    Can we mark this as resolved and close the thread?

Viewing 4 posts - 11 through 14 (of 14 total)

The topic ‘Programmatically Rebuild Cache’ is closed to new replies.