Skip to content

Commit 6c4ce4f

Browse files
committed
fix redis flush_group
1 parent 4bf2aa1 commit 6c4ce4f

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

includes/dropins/redis-object-cache.php

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -667,6 +667,31 @@ public function flush( $redis = true ) {
667667
return true;
668668
}
669669

670+
/**
671+
* Removes all cache items in a group.
672+
*
673+
* @param string $group Name of group to remove from cache.
674+
* @return true Always returns true.
675+
*/
676+
public function flush_group( $group ) {
677+
if ( ! $this->_should_use_redis_hashes( $group ) ) {
678+
return false;
679+
}
680+
681+
$multisite_safe_group = $this->multisite && ! isset( $this->global_groups[ $group ] ) ? $this->blog_prefix . $group : $group;
682+
$redis_safe_group = $this->_key( '', $group );
683+
if ( $this->_should_persist( $group ) ) {
684+
$result = $this->_call_redis( 'del', $redis_safe_group );
685+
if ( 1 !== $result ) {
686+
return false;
687+
}
688+
} elseif ( ! $this->_should_persist( $group ) && ! isset( $this->cache[ $multisite_safe_group ] ) ) {
689+
return false;
690+
}
691+
unset( $this->cache[ $multisite_safe_group ] );
692+
return true;
693+
}
694+
670695
/**
671696
* Retrieves the cache contents, if it exists
672697
*

0 commit comments

Comments
 (0)