Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
tillkruss committed Jul 20, 2022
2 parents 0dd439b + 410816b commit b0bc4fe
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 14 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## 2.1.4

- Added `is_predis()` helper

## 2.1.3

- Fixed bug in `wp_cache_add_multiple()` and `wp_cache_set_multiple()`
Expand Down
27 changes: 17 additions & 10 deletions includes/object-cache.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Plugin Name: Redis Object Cache Drop-In
* Plugin URI: https://wordpress.org/plugins/redis-cache/
* Description: A persistent object cache backend powered by Redis. Supports Predis, PhpRedis, Relay, replication, sentinels, clustering and WP-CLI.
* Version: 2.1.3
* Version: 2.1.4
* Author: Till Krüss
* Author URI: https://objectcache.pro
* License: GPLv3
Expand Down Expand Up @@ -1184,7 +1184,7 @@ protected function add_multiple_at_once( array $data, $group = 'default', $expir

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

if ( $this->redis instanceof Predis\Client ) {
if ( $this->is_predis() ) {
$args[] = 'nx';

if ( $expire ) {
Expand All @@ -1205,7 +1205,7 @@ protected function add_multiple_at_once( array $data, $group = 'default', $expir
try {
$start_time = microtime( true );

$method = ( $this->redis instanceof Predis\Client ) ? 'execute' : 'exec';
$method = $this->is_predis() ? 'execute' : 'exec';

$results = array_map( function ( $response ) {
return (bool) $this->parse_redis_response( $response );
Expand Down Expand Up @@ -1295,7 +1295,7 @@ protected function add_or_replace( $add, $key, $value, $group = 'default', $expi
if ( $add ) {
$args = [ $derived_key, $this->maybe_serialize( $value ) ];

if ( $this->redis instanceof Predis\Client ) {
if ( $this->is_predis() ) {
$args[] = 'nx';

if ( $expiration ) {
Expand Down Expand Up @@ -1450,7 +1450,7 @@ protected function delete_multiple_at_once( array $keys, $group = 'default' ) {
unset( $this->cache[ $derived_key ] );
}

$method = ( $this->redis instanceof Predis\Client ) ? 'execute' : 'exec';
$method = $this->is_predis() ? 'execute' : 'exec';

$results = array_map( function ( $response ) {
return (bool) $this->parse_redis_response( $response );
Expand Down Expand Up @@ -1657,9 +1657,7 @@ protected function lua_flush_closure( $salt ) {
$script = 'redis.replicate_commands()' . "\n" . $script;
}

$args = ( $this->redis instanceof Predis\Client )
? [ $script, 0 ]
: [ $script ];
$args = is_predis() ? [ $script, 0 ] : [ $script ];

return call_user_func_array( [ $this->redis, 'eval' ], $args );
};
Expand Down Expand Up @@ -1711,7 +1709,7 @@ function ( $group ) {
$script = 'redis.replicate_commands()' . "\n" . $script;
}

$args = ( $this->redis instanceof Predis\Client )
$args = $this->is_predis()
? array_merge( [ $script, count( $unflushable ) ], $unflushable )
: [ $script, $unflushable, count( $unflushable ) ];

Expand Down Expand Up @@ -2097,7 +2095,7 @@ protected function set_multiple_at_once( array $data, $group = 'default', $expir
}

try {
$method = ( $this->redis instanceof Predis\Client ) ? 'execute' : 'exec';
$method = $this->is_predis() ? 'execute' : 'exec';

$results = array_map( function ( $response ) {
return (bool) $this->parse_redis_response( $response );
Expand Down Expand Up @@ -2731,6 +2729,15 @@ protected function build_cluster_connection_array() {
return $cluster;
}

/**
* Check whether Predis client is in use.
*
* @return bool
*/
protected function is_predis() {
return $this->redis instanceof Predis\Client;
}

/**
* Allows access to private properties for backwards compatibility.
*
Expand Down
4 changes: 2 additions & 2 deletions languages/redis-cache.pot
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
# This file is distributed under the GPLv3.
msgid ""
msgstr ""
"Project-Id-Version: Redis Object Cache 2.1.2\n"
"Project-Id-Version: Redis Object Cache 2.1.3\n"
"Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/redis-cache\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <[email protected]>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"POT-Creation-Date: 2022-07-19T03:20:42+00:00\n"
"POT-Creation-Date: 2022-07-20T18:43:43+00:00\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"X-Generator: WP-CLI 2.6.0\n"
"X-Domain: redis-cache\n"
Expand Down
8 changes: 6 additions & 2 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Tags: redis, predis, phpredis, credis, relay, caching, cache, object cache, perf
Requires at least: 3.3
Tested up to: 6.0
Requires PHP: 7.2
Stable tag: 2.1.3
Stable tag: 2.1.4
License: GPLv3
License URI: http://www.gnu.org/licenses/gpl-3.0.html

Expand Down Expand Up @@ -83,6 +83,10 @@ To see a list of all available WP-CLI commands, please see the [WP CLI commands

== Changelog ==

= 2.1.4 =

- Added `is_predis()` helper

= 2.1.3 =

- Fixed bug in `wp_cache_add_multiple()` and `wp_cache_set_multiple()`
Expand Down Expand Up @@ -584,6 +588,6 @@ Since Predis isn't maintained any longer, it's highly recommended to switch over

== Upgrade Notice ==

= 2.1.3 =
= 2.1.4 =

Bumped PHP requirement to 7.2, updated Predis to v2.0 and deprecated Credis and HHVM clients.

0 comments on commit b0bc4fe

Please sign in to comment.