From 21e9fcfa2c9855ca412c5e192ba3252f77174137 Mon Sep 17 00:00:00 2001 From: Nurul Umbhiya Date: Thu, 26 Oct 2023 00:40:42 +0600 Subject: [PATCH] =?UTF-8?q?=F0=9F=93=9D=20docs(ObjectCache.php):=20update?= =?UTF-8?q?=20@since=20tag=20to=20have=20proper=20indentation=20and=20spac?= =?UTF-8?q?ing=20for=20consistency=20=F0=9F=90=9B=20fix(ObjectCache.php):?= =?UTF-8?q?=20fix=20typo=20in=20comment,=20change=20"underneath"=20to=20"u?= =?UTF-8?q?nderlying"=20for=20clarity=20=F0=9F=90=9B=20fix(ObjectCache.php?= =?UTF-8?q?):=20fix=20indentation=20issue=20in=20the=20invalidate=5Fgroup(?= =?UTF-8?q?)=20method=20=E2=9C=A8=20feat(ObjectCache.php):=20add=20support?= =?UTF-8?q?=20for=20flushing=20cache=20group=20using=20wp=5Fcache=5Fflush?= =?UTF-8?q?=5Fgroup()=20function?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- includes/Traits/ObjectCache.php | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/includes/Traits/ObjectCache.php b/includes/Traits/ObjectCache.php index ff02053ac2..2fdb8e1916 100644 --- a/includes/Traits/ObjectCache.php +++ b/includes/Traits/ObjectCache.php @@ -7,7 +7,7 @@ * * Handles Caching underneath functionalities with the help of this Cacheable trait. * - * @since 3.3.2 + * @since 3.3.2 * * @package WeDevs\Dokan\Abstracts\Traits */ @@ -129,7 +129,7 @@ public static function delete( $key, $group = '', $time = 0 ) { if ( empty( $key ) ) { return false; } - + return wp_cache_delete( $key, $group, $time ); } @@ -143,24 +143,29 @@ public static function delete( $key, $group = '', $time = 0 ) { * * @since 3.3.2 * - * @param string $group Group of cache to clear. + * @param string $group Group of caches to clear. * * @return bool */ public static function invalidate_group( $group ) { $group = static::get_cache_group_with_prefix( $group ); + $supported = wp_cache_supports( 'flush_group' ); + if ( $supported ) { + wp_cache_flush_group( $group . '_prefix' ); + } + return wp_cache_set( $group . '_prefix', static::get_time_prefix(), $group ); } /** * Get Cache Key and Group with Prefix added. * - * @param string $key - * @param string $group - * * @since 3.3.2 * + * @param string $key + * @param string $group + * * @return array */ private static function get_key_and_group( $key, $group ) {