Skip to content

Commit

Permalink
Map: Generate cache key when forcing refresh
Browse files Browse the repository at this point in the history
Previously the cache key was never generated when running the cron.
  • Loading branch information
iandunn committed Dec 6, 2023
1 parent d6a1749 commit 3272cbc
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions mu-plugins/blocks/google-map/inc/event-filters.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,18 @@ function get_events( string $filter_slug, int $start_timestamp, int $end_timesta
$cacheable = false;
}

if ( $cacheable && ! $force_refresh ) {
if ( $cacheable ) {
$cache_key = get_cache_key( array_merge(
compact( 'filter_slug', 'start_timestamp', 'end_timestamp' ),
$facets // It's safe to include this because of the logic around `$cacheable`.
) );

$cached_events = get_transient( $cache_key );
if ( ! $force_refresh ) {
$cached_events = get_transient( $cache_key );

if ( $cached_events ) {
$events = $cached_events;
if ( $cached_events ) {
$events = $cached_events;
}
}
}

Expand Down

0 comments on commit 3272cbc

Please sign in to comment.