Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
83ea358
remove old rules
tillkruss Nov 5, 2022
7e3a04a
Merge remote-tracking branch 'origin/develop'
tillkruss Jan 11, 2023
0293eb1
Merge remote-tracking branch 'origin/develop'
tillkruss Feb 26, 2023
c4b5f7c
Merge remote-tracking branch 'origin/develop'
tillkruss Apr 13, 2023
1148bf6
Merge remote-tracking branch 'origin/develop'
tillkruss May 4, 2023
60467c1
Merge remote-tracking branch 'origin/develop'
tillkruss May 4, 2023
89e69d6
Merge remote-tracking branch 'origin/develop'
tillkruss Jun 28, 2023
326d8a1
Merge remote-tracking branch 'origin/develop'
tillkruss Jun 29, 2023
856f496
Merge remote-tracking branch 'origin/develop'
tillkruss Aug 11, 2023
e580c96
Merge remote-tracking branch 'origin/develop'
tillkruss Feb 29, 2024
14d740b
Merge branch 'develop'
tillkruss Apr 22, 2024
b397939
bump tested version
tillkruss Apr 22, 2024
872ad76
adds support for ssl context in redis clusters (#518)
mbrowngold May 3, 2024
c6b91f0
drop 7.2 linting
tillkruss May 3, 2024
c4c3d73
Fixed issue with Predis and replication connection (#520)
yatsukhnenko May 3, 2024
c3e1b89
Fixed loading textdomain in show_error_and_die (#533)
yatsukhnenko Jun 6, 2024
352c9f2
Introduce WP_REDIS_DISABLE_GROUP_FLUSH to disable group flushing (#532)
yatsukhnenko Jun 10, 2024
81a0406
Fix Redis version determination for predis replication connection (#522)
yatsukhnenko Jun 10, 2024
0ebd266
Fix Predis cluster flush (#529)
yatsukhnenko Jun 10, 2024
1816d87
document WP_REDIS_DISABLE_COMMENT
tillkruss Jul 2, 2024
b6ef5a8
Add filter to allow customizing who can flush the cache (#535)
pmgarman Jul 12, 2024
7ea28cf
remove whitespace [skip ci]
tillkruss Jul 12, 2024
034def1
Update phpstan.dist.neon
tillkruss Jul 12, 2024
6848677
ignore warning
tillkruss Jul 12, 2024
19a6e16
Update CHANGELOG.md [skip ci]
tillkruss Jul 12, 2024
9a123ef
tag v2.5.3
tillkruss Jul 12, 2024
3e97403
update pot file
tillkruss Jul 12, 2024
9b49863
Merge remote-tracking branch 'origin/develop'
tillkruss Oct 15, 2024
df6b081
Merge remote-tracking branch 'origin/develop'
tillkruss Jul 23, 2025
10e4627
Merge remote-tracking branch 'origin/develop'
tillkruss Jul 24, 2025
5bfcc7d
bump pot file
tillkruss Jul 24, 2025
6880fdd
Merge remote-tracking branch 'origin/develop'
tillkruss Aug 20, 2025
53e8f95
Merge remote-tracking branch 'origin/develop'
tillkruss Sep 29, 2025
6a002ca
WP_REDIS_SERVERLESS_WORKAROUND
ustramooner Dec 2, 2025
1d2c1f4
implement pconnect
ustramooner Mar 2, 2026
b929e42
Merge branch 'main' of github.com:rhubarbgroup/redis-cache into WP_RE…
ustramooner Mar 2, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions includes/diagnostics.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
$info['Timeout'] = $wp_object_cache->diagnostics['timeout'] ?? false;
$info['Read Timeout'] = $wp_object_cache->diagnostics['read_timeout'] ?? false;
$info['Retry Interval'] = $wp_object_cache->diagnostics['retry_interval'] ?? false;
$info['Persistent'] = $wp_object_cache->diagnostics['persistent'] ?? false;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR needs several changelog entries.

}

$constants = [
Expand Down
60 changes: 54 additions & 6 deletions includes/object-cache.php
Original file line number Diff line number Diff line change
Expand Up @@ -640,6 +640,7 @@ protected function build_parameters() {
'timeout',
'read_timeout',
'retry_interval',
'persistent',
];

foreach ( $settings as $setting ) {
Expand All @@ -657,7 +658,7 @@ protected function build_parameters() {
$this->diagnostics[ 'timeout' ] = $parameters[ 'timeout' ];
$this->diagnostics[ 'read_timeout' ] = $parameters[ 'read_timeout' ];
$this->diagnostics[ 'retry_interval' ] = $parameters[ 'retry_interval' ];

$this->diagnostics[ 'persistent' ] = $parameters[ 'persistent' ];
return $parameters;
}

Expand Down Expand Up @@ -705,11 +706,23 @@ protected function connect_using_phpredis( $parameters ) {
} else {
$this->redis = new Redis();

if ( $parameters['persistent'] ) {
$persistent_id = sprintf(
'%s:%s:%s:%s',
$parameters['host'],
$parameters['port'],
$parameters['database'],
isset( $parameters['password'] ) ? hash( 'sha256', json_encode( $parameters['password'] ) ) : ''
);
}else{
$persistent_id = '';
}

$args = [
'host' => $parameters['host'],
'port' => $parameters['port'],
'timeout' => $parameters['timeout'],
'',
$persistent_id,
'retry_interval' => (int) $parameters['retry_interval'],
];

Expand All @@ -734,7 +747,8 @@ protected function connect_using_phpredis( $parameters ) {
$args['port'] = -1;
}

call_user_func_array( [ $this->redis, 'connect' ], array_values( $args ) );
call_user_func_array( [ $this->redis, $parameters['persistent'] ? 'pconnect' : 'connect' ], array_values( $args ) );
$args['persistent'] = $parameters['persistent'];

if ( isset( $parameters['password'] ) ) {
$args['password'] = $parameters['password'];
Expand Down Expand Up @@ -1083,6 +1097,8 @@ public function fetch_info() {
$info = $this->is_predis()
? $this->redis->getClientBy( 'id', $connectionId )->info()
: $this->redis->info( $connectionId );
} else if ($this->is_predis() && $this->redis->getConnection() instanceof Predis\Connection\Replication\MasterSlaveReplication) {
$info = $this->redis->getClientBy( 'role' , 'master' )->info();
} else {
if ( $this->is_predis() ) {
$connection = $this->redis->getConnection();
Expand Down Expand Up @@ -1215,6 +1231,9 @@ protected function add_multiple_at_once( array $data, $group = 'default', $expir

$san_key = $this->sanitize_key_part( $key );
$derived_key = $derived_keys[ $key ] = $this->fast_build_key( $san_key, $san_group );
if (defined('WP_REDIS_SERVERLESS_WORKAROUND') && WP_REDIS_SERVERLESS_WORKAROUND ) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs a README entry with explanation

$this->redis->sadd(WP_REDIS_SERVERLESS_WORKAROUND, $derived_key);
}

$args = [ $derived_key, $this->maybe_serialize( $value ) ];

Expand Down Expand Up @@ -1313,6 +1332,9 @@ protected function add_or_replace( $add, $key, $value, $group = 'default', $expi
$san_group = $this->sanitize_key_part( $group );

$derived_key = $this->fast_build_key( $san_key, $san_group );
if (defined('WP_REDIS_SERVERLESS_WORKAROUND') && WP_REDIS_SERVERLESS_WORKAROUND ) {
$this->redis->sadd(WP_REDIS_SERVERLESS_WORKAROUND, $derived_key);
}

// Save if group not excluded and redis is up.
if ( ! $this->is_ignored_group( $san_group ) && $this->redis_status() ) {
Expand Down Expand Up @@ -1404,6 +1426,9 @@ public function delete( $key, $group = 'default', $deprecated = false ) {
$san_group = $this->sanitize_key_part( $group );

$derived_key = $this->fast_build_key( $san_key, $san_group );
if (defined('WP_REDIS_SERVERLESS_WORKAROUND') && WP_REDIS_SERVERLESS_WORKAROUND ) {
$this->redis->srem(WP_REDIS_SERVERLESS_WORKAROUND, $derived_key);
}

if ( array_key_exists( $derived_key, $this->cache ) ) {
unset( $this->cache[ $derived_key ] );
Expand Down Expand Up @@ -1639,11 +1664,22 @@ public function flush() {
$start_time = microtime( true );

if ( $salt && $selective ) {
$script = $this->get_flush_closure( $salt );
$results = $this->execute_lua_script( $script );
if (defined('WP_REDIS_SERVERLESS_WORKAROUND') && WP_REDIS_SERVERLESS_WORKAROUND ) {
$results = $this->redis->smembers(WP_REDIS_SERVERLESS_WORKAROUND);
foreach ($results as $key) {
$this->redis->srem(WP_REDIS_SERVERLESS_WORKAROUND, $key);
$this->redis->del($key);
}
if (empty($results)) {
return false;
}
} else {
$script = $this->get_flush_closure($salt);
$results = $this->execute_lua_script($script);

if ( empty( $results ) ) {
if (empty($results)) {
return false;
}
}
} else {
if ( defined( 'WP_REDIS_CLUSTER' ) ) {
Expand Down Expand Up @@ -2147,6 +2183,9 @@ public function set( $key, $value, $group = 'default', $expiration = 0 ) {
$san_group = $this->sanitize_key_part( $group );

$derived_key = $this->fast_build_key( $san_key, $san_group );
if (defined('WP_REDIS_SERVERLESS_WORKAROUND') && WP_REDIS_SERVERLESS_WORKAROUND ) {
$this->redis->sadd(WP_REDIS_SERVERLESS_WORKAROUND, $derived_key);
}

// Save if group not excluded from redis and redis is up.
if ( ! $this->is_ignored_group( $group ) && $this->redis_status() ) {
Expand Down Expand Up @@ -2257,6 +2296,9 @@ protected function set_multiple_at_once( array $data, $group = 'default', $expir
foreach ( $data as $key => $value ) {
$san_key = $this->sanitize_key_part( $key );
$derived_key = $derived_keys[ $key ] = $this->fast_build_key( $san_key, $san_group );
if (defined('WP_REDIS_SERVERLESS_WORKAROUND') && WP_REDIS_SERVERLESS_WORKAROUND ) {
$this->redis->sadd(WP_REDIS_SERVERLESS_WORKAROUND, $derived_key);
}

/**
* Filters the cache expiration time
Expand Down Expand Up @@ -2340,6 +2382,9 @@ public function increment( $key, $offset = 1, $group = 'default' ) {
$san_group = $this->sanitize_key_part( $group );

$derived_key = $this->fast_build_key( $san_key, $san_group );
if (defined('WP_REDIS_SERVERLESS_WORKAROUND') && WP_REDIS_SERVERLESS_WORKAROUND ) {
$this->redis->sadd(WP_REDIS_SERVERLESS_WORKAROUND, $derived_key);
}

// If group is a non-Redis group, save to internal cache, not Redis.
if ( $this->is_ignored_group( $group ) || ! $this->redis_status() ) {
Expand Down Expand Up @@ -2417,6 +2462,9 @@ public function decrement( $key, $offset = 1, $group = 'default' ) {
$san_group = $this->sanitize_key_part( $group );

$derived_key = $this->fast_build_key( $san_key, $san_group );
if (defined('WP_REDIS_SERVERLESS_WORKAROUND') && WP_REDIS_SERVERLESS_WORKAROUND ) {
$this->redis->sadd(WP_REDIS_SERVERLESS_WORKAROUND, $derived_key);
}

// If group is a non-Redis group, save to internal cache, not Redis.
if ( $this->is_ignored_group( $group ) || ! $this->redis_status() ) {
Expand Down
8 changes: 7 additions & 1 deletion includes/ui/tabs/overview.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
$filesystem_writable = $roc->test_filesystem_writing();

$diagnostics = $roc->get_diagnostics();

?>

<?php if ( is_string( $redis_connection ) ) : ?>
Expand Down Expand Up @@ -226,6 +225,13 @@
</tr>
<?php endif; ?>

<?php if ( isset( $diagnostics['persistent'] ) ) : ?>
<tr>
<th><?php esc_html_e( 'Persistent Connection:', 'redis-cache' ); ?></th>
<td><code><?php echo esc_html( $diagnostics['persistent'] ? 'Yes' : 'No' ); ?></code></td>
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make sure these are translatable.

</tr>
<?php endif; ?>

<?php if ( isset( $diagnostics['read_timeout'] ) ) : ?>
<tr>
<th><?php esc_html_e( 'Read Timeout:', 'redis-cache' ); ?></th>
Expand Down