Skip to content

Commit 64174bf

Browse files
committed
refactor: improve caching implementation with dedicated Cache class methods
1 parent 9ceb025 commit 64174bf

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

includes/frontend/class-display.php

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -353,19 +353,23 @@ public static function get_term_posts( $term ) {
353353
),
354354
);
355355

356+
$query = null;
357+
$cache_enabled = ! empty( \wzkb_get_option( 'cache' ) );
358+
$meta_key = null;
359+
356360
// Support caching to speed up retrieval.
357-
if ( ! empty( \wzkb_get_option( 'cache' ) ) ) {
361+
if ( $cache_enabled ) {
358362
$meta_key = Cache::get_key( $args );
359-
$query = get_term_meta( $term->term_id, $meta_key, true );
363+
$query = Cache::get( $term->term_id, $meta_key );
360364
}
361365

362366
if ( empty( $query ) ) {
363367
$query = new \WP_Query( $args );
364-
}
365368

366-
// Support caching to speed up retrieval.
367-
if ( ! empty( \wzkb_get_option( 'cache' ) ) ) {
368-
add_term_meta( $term->term_id, $meta_key, $query, true );
369+
// Support caching to speed up retrieval.
370+
if ( $cache_enabled ) {
371+
Cache::set( $term->term_id, $meta_key, $query );
372+
}
369373
}
370374

371375
return $query;

includes/frontend/class-media-handler.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ public static function get_the_post_thumbnail( $args = array() ) {
307307
}
308308

309309
/**
310-
* Filters post thumbnail created for Better Search.
310+
* Filters post thumbnail created for Knowledge Base.
311311
*
312312
* @since 2.3.0
313313
*

0 commit comments

Comments
 (0)