epl_flush_listing_query_cache(): refresh the listing search cache

Description #

Refreshes the listing search cache (the search dropdown values and the location list). EPL does this by itself when listings change through WordPress, so you only need it after changing listings directly in the database, with SQL, phpMyAdmin or a database import. See How the listing search cache works.


Usage #

epl_flush_listing_query_cache( $now );

Parameters #

$now (bool)
Default false: mark the cache as out of date and rebuild it in the background with WP-Cron. Visitors keep getting the current results until the rebuild finishes. True: clear it straight away, and each query runs again the next time a visitor needs it.

Returns nothing.


Examples #

After changing listings with SQL:

global $wpdb;

$wpdb->query(
	$wpdb->prepare(
		"UPDATE {$wpdb->postmeta} SET meta_value = %s WHERE meta_key = %s AND meta_value = %s",
		'Sometown',
		'property_address_suburb',
		'Some Town'
	)
);

epl_flush_listing_query_cache();

Clear it straight away from the command line with WP-CLI:

wp eval 'epl_flush_listing_query_cache( true );'

Changes made with WordPress functions (wp_update_post(), update_post_meta(), wp_set_object_terms(), wp_delete_post()) already refresh the cache once, at the end of the request, so don't call it after those.

The default background refresh starts WP-Cron straight away. If the rebuild hasn't finished within 10 minutes (epl_listing_query_cache_stale_limit), the next page load clears the cache as if you had passed true.


Source #

lib/includes/functions.php, in epl_flush_listing_query_cache(). The rebuild runs in epl_rebuild_listing_query_cache() on the WP-Cron event epl_listing_query_cache_rebuild. Since 3.6.

Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.