Skip to content

Commit

Permalink
Add additional parameters to generate a cache hash
Browse files Browse the repository at this point in the history
'caching' (controls View-specific caching behavior) and
'caching-entries' (controls cache duration), along with
the 'view_id', allow for a more granular control over
the cached entries.
  • Loading branch information
mrcasual committed Jul 30, 2024
1 parent a75ef65 commit a198e66
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions future/includes/class-gv-view.php
Original file line number Diff line number Diff line change
Expand Up @@ -1464,20 +1464,22 @@ private function run_db_query( GF_Query $query ) {

$query_hash = md5( serialize( $query_introspect ) );

$cache_atts = [
'view_id' => $this->post->ID,
'query_hash' => $query_hash,
$caching_atts = [
'view_id' => $this->ID ?: null,
'caching' => $this->settings->get( 'caching' ),
'caching_entries' => $this->settings->get( 'caching_entries' ),
'query_hash' => $query_hash,
];

$cache_atts = array_merge( $cache_atts, $this->settings->get( 'cache_atts', [] ) );
$caching_atts = array_merge( $caching_atts, $this->settings->get( 'caching_atts', [] ) );

$form_ids = [ $this->form->ID ];

foreach ( $this->joins as $join ) {
$form_ids[] = $join->join_on->ID;
}

$long_lived_cache = new GravityView_Cache( $form_ids, $cache_atts );
$long_lived_cache = new GravityView_Cache( $form_ids, $caching_atts );

if ( $long_lived_cache->use_cache() ) {
$cached_entries = $long_lived_cache->get();
Expand Down

0 comments on commit a198e66

Please sign in to comment.