Version Description
- Added warning message about invalid MaxTTL
- Added warning about unmaintained Predis library
- Added suggestion about shorter, human-readable prefixes
- Added Redis Cache Pro compatibility to settings
- Fixed flushing the cache when the prefix contains special characters
- Fixed calling Redis
INFO
when using clusters - Cleaned up the settings a little bit
Download this release
Release Info
Developer | tillkruess |
Plugin | Redis Object Cache |
Version | 1.5.8 |
Comparing to | |
See all releases |
Code changes from version 1.5.7 to 1.5.8
- includes/admin-page.php +84 -8
- includes/object-cache.php +24 -4
- readme.txt +12 -2
- redis-cache.php +2 -2
includes/admin-page.php
CHANGED
@@ -42,24 +42,52 @@
|
|
42 |
<td><code><?php echo $this->get_status(); ?></code></td>
|
43 |
</tr>
|
44 |
|
45 |
-
<?php
|
|
|
|
|
|
|
|
|
46 |
<tr>
|
47 |
<th><?php _e( 'Client:', 'redis-cache' ); ?></th>
|
48 |
-
<td
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
49 |
</tr>
|
50 |
<?php endif; ?>
|
51 |
|
52 |
-
<?php if ( ! is_null( $
|
53 |
<tr>
|
54 |
<th><?php _e( 'Key Prefix:', 'redis-cache' ); ?></th>
|
55 |
-
<td
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
56 |
</tr>
|
57 |
<?php endif; ?>
|
58 |
|
59 |
-
<?php if ( ! is_null( $
|
60 |
<tr>
|
61 |
<th><?php _e( 'Max. TTL:', 'redis-cache' ); ?></th>
|
62 |
-
<td
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
63 |
</tr>
|
64 |
<?php endif; ?>
|
65 |
|
@@ -89,15 +117,63 @@
|
|
89 |
|
90 |
<?php $this->show_servers_list(); ?>
|
91 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
92 |
<?php if ( isset( $_GET[ 'diagnostics' ] ) ) : ?>
|
93 |
|
94 |
-
<
|
|
|
|
|
|
|
95 |
|
96 |
<textarea class="large-text readonly" rows="20" readonly><?php include dirname( __FILE__ ) . '/diagnostics.php'; ?></textarea>
|
97 |
|
98 |
<?php else : ?>
|
99 |
|
100 |
-
<p
|
|
|
|
|
|
|
|
|
|
|
101 |
|
102 |
<?php endif; ?>
|
103 |
|
42 |
<td><code><?php echo $this->get_status(); ?></code></td>
|
43 |
</tr>
|
44 |
|
45 |
+
<?php $redisClient = $this->get_redis_client_name(); ?>
|
46 |
+
<?php $redisPrefix = $this->get_redis_cachekey_prefix(); ?>
|
47 |
+
<?php $redisMaxTTL = $this->get_redis_maxttl(); ?>
|
48 |
+
|
49 |
+
<?php if ( ! is_null( $redisClient ) ) : ?>
|
50 |
<tr>
|
51 |
<th><?php _e( 'Client:', 'redis-cache' ); ?></th>
|
52 |
+
<td>
|
53 |
+
<code><?php echo esc_html( $redisClient ); ?></code>
|
54 |
+
|
55 |
+
<?php if ( strpos( (string) $redisClient, 'predis' ) !== false ) : ?>
|
56 |
+
<p class="description" style="color: #d54e21; max-width: 20rem;">
|
57 |
+
<?php _e( 'The Predis library is no longer maintained. Consider switching over to PhpRedis to avoid compatiblity issues in the future.', 'redis-cache' ); ?>
|
58 |
+
</p>
|
59 |
+
<?php endif; ?>
|
60 |
+
</td>
|
61 |
</tr>
|
62 |
<?php endif; ?>
|
63 |
|
64 |
+
<?php if ( ! is_null( $redisPrefix ) && trim( $redisPrefix ) !== '' ) : ?>
|
65 |
<tr>
|
66 |
<th><?php _e( 'Key Prefix:', 'redis-cache' ); ?></th>
|
67 |
+
<td>
|
68 |
+
<code><?php echo esc_html( $redisPrefix ); ?></code>
|
69 |
+
|
70 |
+
<?php if ( strlen( (string) $redisPrefix ) > 20 || ! ctype_alnum( $redisPrefix ) ) : ?>
|
71 |
+
<p class="description" style="color: #d54e21;">
|
72 |
+
<?php _e( 'Consider using a shorter, human-readable prefix.', 'redis-cache' ); ?>
|
73 |
+
</p>
|
74 |
+
<?php endif; ?>
|
75 |
+
</td>
|
76 |
</tr>
|
77 |
<?php endif; ?>
|
78 |
|
79 |
+
<?php if ( ! is_null( $redisMaxTTL ) ) : ?>
|
80 |
<tr>
|
81 |
<th><?php _e( 'Max. TTL:', 'redis-cache' ); ?></th>
|
82 |
+
<td>
|
83 |
+
<code><?php echo esc_html( $redisMaxTTL ); ?></code>
|
84 |
+
|
85 |
+
<?php if ( ! is_int( $redisMaxTTL ) && ! ctype_digit( $redisMaxTTL ) !== 0 ) : ?>
|
86 |
+
<p class="description" style="color: #d54e21;">
|
87 |
+
<?php _e( 'This doesn’t appear to be a valid number.', 'redis-cache' ); ?>
|
88 |
+
</p>
|
89 |
+
<?php endif; ?>
|
90 |
+
</td>
|
91 |
</tr>
|
92 |
<?php endif; ?>
|
93 |
|
117 |
|
118 |
<?php $this->show_servers_list(); ?>
|
119 |
|
120 |
+
<?php if ( ! defined( 'WP_REDIS_DISABLE_BANNERS' ) || ! WP_REDIS_DISABLE_BANNERS ) : ?>
|
121 |
+
<br>
|
122 |
+
<h2 class="title">
|
123 |
+
<?php _e( 'Redis Cache Pro', 'redis-cache' ); ?>
|
124 |
+
</h2>
|
125 |
+
|
126 |
+
<?php $isPhp7 = version_compare( phpversion(), '7.0', '>=' ); ?>
|
127 |
+
<?php $isPhpRedis311 = version_compare( phpversion( 'redis' ), '3.1.1', '>=' ); ?>
|
128 |
+
<?php $phpRedisInstalled = (bool) phpversion( 'redis' ); ?>
|
129 |
+
|
130 |
+
<?php if ($isPhp7 && $isPhpRedis311) : ?>
|
131 |
+
<p>
|
132 |
+
<?php _e( 'Your site meets the system requirements for the Pro version (PHP 7+; PhpRedis 3.1.1+).', 'redis-cache' ); ?>
|
133 |
+
</p>
|
134 |
+
<?php else : ?>
|
135 |
+
<p>
|
136 |
+
<?php _e( 'Your site <i>does not</i> meet the system requirements for the Pro version:', 'redis-cache' ); ?>
|
137 |
+
</p>
|
138 |
+
|
139 |
+
<ul style="padding-left: 30px; list-style: disc;">
|
140 |
+
<?php if (! $isPhp7) : ?>
|
141 |
+
<li>
|
142 |
+
<?php printf( __( 'The current version (%s) of PHP is too old. PHP 7 or newer is required.', 'redis-cache' ), phpversion() ); ?>
|
143 |
+
</li>
|
144 |
+
<?php endif; ?>
|
145 |
+
|
146 |
+
<?php if (! $phpRedisInstalled) : ?>
|
147 |
+
<li>
|
148 |
+
<?php printf( __( 'The PhpRedis extension is not installed.', 'redis-cache' ), phpversion() ); ?>
|
149 |
+
</li>
|
150 |
+
<?php elseif (! $isPhpRedis311) : ?>
|
151 |
+
<li>
|
152 |
+
<?php printf( __( 'The current version (%s) of the PhpRedis extension is too old. PhpRedis 3.1 or newer is required.', 'redis-cache' ), phpversion( 'redis' ) ); ?>
|
153 |
+
</li>
|
154 |
+
<?php endif; ?>
|
155 |
+
</ul>
|
156 |
+
|
157 |
+
<?php endif; ?>
|
158 |
+
<?php endif; ?>
|
159 |
+
|
160 |
<?php if ( isset( $_GET[ 'diagnostics' ] ) ) : ?>
|
161 |
|
162 |
+
<br>
|
163 |
+
<h2 class="title">
|
164 |
+
<?php _e( 'Diagnostics', 'redis-cache' ); ?>
|
165 |
+
</h2>
|
166 |
|
167 |
<textarea class="large-text readonly" rows="20" readonly><?php include dirname( __FILE__ ) . '/diagnostics.php'; ?></textarea>
|
168 |
|
169 |
<?php else : ?>
|
170 |
|
171 |
+
<p class="mt-5">
|
172 |
+
<br>
|
173 |
+
<a class="button button-secondary" href="<?php echo network_admin_url( add_query_arg( 'diagnostics', '1', $this->page ) ); ?>">
|
174 |
+
<?php _e( 'Show Diagnostics', 'redis-cache' ); ?>
|
175 |
+
</a>
|
176 |
+
</p>
|
177 |
|
178 |
<?php endif; ?>
|
179 |
|
includes/object-cache.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
Plugin Name: Redis Object Cache Drop-In
|
4 |
Plugin URI: http://wordpress.org/plugins/redis-cache/
|
5 |
Description: A persistent object cache backend powered by Redis. Supports Predis, PhpRedis, HHVM, replication, clustering and WP-CLI.
|
6 |
-
Version: 1.5.
|
7 |
Author: Till Krüss
|
8 |
Author URI: https://till.im/
|
9 |
License: GPLv3
|
@@ -230,7 +230,7 @@ function wp_cache_set($key, $value, $group = '', $expiration = 0)
|
|
230 |
}
|
231 |
|
232 |
/**
|
233 |
-
* Switch the
|
234 |
*
|
235 |
* This changes the blog id used to create keys in blog specific groups.
|
236 |
*
|
@@ -592,7 +592,11 @@ class WP_Object_Cache
|
|
592 |
}
|
593 |
|
594 |
if ( ! isset( $options['replication'] ) || ! $options['replication'] ) {
|
595 |
-
|
|
|
|
|
|
|
|
|
596 |
|
597 |
if (isset($info['redis_version'])) {
|
598 |
$this->redis_version = $info['redis_version'];
|
@@ -881,6 +885,18 @@ class WP_Object_Cache
|
|
881 |
}
|
882 |
}
|
883 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
884 |
/**
|
885 |
* Returns a closure ready to be called to flush selectively ignoring unflushable groups.
|
886 |
*
|
@@ -889,6 +905,8 @@ class WP_Object_Cache
|
|
889 |
*/
|
890 |
protected function lua_flush_closure($salt)
|
891 |
{
|
|
|
|
|
892 |
return function () use ($salt) {
|
893 |
$script = <<<LUA
|
894 |
local cur = 0
|
@@ -927,6 +945,8 @@ LUA;
|
|
927 |
*/
|
928 |
protected function lua_flush_extended_closure($salt)
|
929 |
{
|
|
|
|
|
930 |
return function () use ($salt) {
|
931 |
$salt_length = strlen($salt);
|
932 |
|
@@ -1423,7 +1443,7 @@ LUA;
|
|
1423 |
/**
|
1424 |
* Wrapper to validate the cache keys expiration value
|
1425 |
*
|
1426 |
-
* @param mixed $expiration
|
1427 |
*/
|
1428 |
protected function validate_expiration($expiration)
|
1429 |
{
|
3 |
Plugin Name: Redis Object Cache Drop-In
|
4 |
Plugin URI: http://wordpress.org/plugins/redis-cache/
|
5 |
Description: A persistent object cache backend powered by Redis. Supports Predis, PhpRedis, HHVM, replication, clustering and WP-CLI.
|
6 |
+
Version: 1.5.8
|
7 |
Author: Till Krüss
|
8 |
Author URI: https://till.im/
|
9 |
License: GPLv3
|
230 |
}
|
231 |
|
232 |
/**
|
233 |
+
* Switch the internal blog id.
|
234 |
*
|
235 |
* This changes the blog id used to create keys in blog specific groups.
|
236 |
*
|
592 |
}
|
593 |
|
594 |
if ( ! isset( $options['replication'] ) || ! $options['replication'] ) {
|
595 |
+
if (defined('WP_REDIS_CLUSTER')) {
|
596 |
+
$this->redis->info(current(array_values(WP_REDIS_CLUSTER)));
|
597 |
+
} else {
|
598 |
+
$this->redis->info();
|
599 |
+
}
|
600 |
|
601 |
if (isset($info['redis_version'])) {
|
602 |
$this->redis_version = $info['redis_version'];
|
885 |
}
|
886 |
}
|
887 |
|
888 |
+
protected function glob_quote($string) {
|
889 |
+
$characters = ['*', '+', '?', '!', '{', '}', '[', ']', '(', ')', '|', '@'];
|
890 |
+
|
891 |
+
return str_replace(
|
892 |
+
$characters,
|
893 |
+
array_map(function ($character) {
|
894 |
+
return "[{$character}]";
|
895 |
+
}, $characters),
|
896 |
+
$string
|
897 |
+
);
|
898 |
+
}
|
899 |
+
|
900 |
/**
|
901 |
* Returns a closure ready to be called to flush selectively ignoring unflushable groups.
|
902 |
*
|
905 |
*/
|
906 |
protected function lua_flush_closure($salt)
|
907 |
{
|
908 |
+
$salt = $this->glob_quote($salt);
|
909 |
+
|
910 |
return function () use ($salt) {
|
911 |
$script = <<<LUA
|
912 |
local cur = 0
|
945 |
*/
|
946 |
protected function lua_flush_extended_closure($salt)
|
947 |
{
|
948 |
+
$salt = $this->glob_quote($salt);
|
949 |
+
|
950 |
return function () use ($salt) {
|
951 |
$salt_length = strlen($salt);
|
952 |
|
1443 |
/**
|
1444 |
* Wrapper to validate the cache keys expiration value
|
1445 |
*
|
1446 |
+
* @param mixed $expiration Incoming expiration value (whatever it is)
|
1447 |
*/
|
1448 |
protected function validate_expiration($expiration)
|
1449 |
{
|
readme.txt
CHANGED
@@ -5,7 +5,7 @@ Tags: redis, predis, phpredis, hhvm, pecl, caching, cache, object cache, perform
|
|
5 |
Requires at least: 3.3
|
6 |
Tested up to: 5.4
|
7 |
Requires PHP: 5.4
|
8 |
-
Stable tag: 1.5.
|
9 |
License: GPLv3
|
10 |
License URI: http://www.gnu.org/licenses/gpl-3.0.html
|
11 |
|
@@ -218,6 +218,16 @@ The following commands are supported:
|
|
218 |
|
219 |
== Changelog ==
|
220 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
221 |
= 1.5.7 =
|
222 |
|
223 |
- Added support for PhpRedis TLS connections
|
@@ -268,7 +278,7 @@ This plugin turned 5 years today (Nov 14th) and its only fitting to release the
|
|
268 |
|
269 |
= 1.5.0 =
|
270 |
|
271 |
-
Since Predis isn't maintained any longer, it's highly recommended to switch over to PhpRedis (the Redis PECL
|
272 |
|
273 |
* Improved Redis key name builder
|
274 |
* Added support for PhpRedis serializers
|
5 |
Requires at least: 3.3
|
6 |
Tested up to: 5.4
|
7 |
Requires PHP: 5.4
|
8 |
+
Stable tag: 1.5.8
|
9 |
License: GPLv3
|
10 |
License URI: http://www.gnu.org/licenses/gpl-3.0.html
|
11 |
|
218 |
|
219 |
== Changelog ==
|
220 |
|
221 |
+
= 1.5.8 =
|
222 |
+
|
223 |
+
- Added warning message about invalid MaxTTL
|
224 |
+
- Added warning about unmaintained Predis library
|
225 |
+
- Added suggestion about shorter, human-readable prefixes
|
226 |
+
- Added Redis Cache Pro compatibility to settings
|
227 |
+
- Fixed flushing the cache when the prefix contains special characters
|
228 |
+
- Fixed calling Redis `INFO` when using clusters
|
229 |
+
- Cleaned up the settings a little bit
|
230 |
+
|
231 |
= 1.5.7 =
|
232 |
|
233 |
- Added support for PhpRedis TLS connections
|
278 |
|
279 |
= 1.5.0 =
|
280 |
|
281 |
+
Since Predis isn't maintained any longer, it's highly recommended to switch over to PhpRedis (the Redis PECL extension).
|
282 |
|
283 |
* Improved Redis key name builder
|
284 |
* Added support for PhpRedis serializers
|
redis-cache.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
Plugin Name: Redis Object Cache
|
4 |
Plugin URI: https://wordpress.org/plugins/redis-cache/
|
5 |
Description: A persistent object cache backend powered by Redis. Supports Predis, PhpRedis, HHVM, replication, clustering and WP-CLI.
|
6 |
-
Version: 1.5.
|
7 |
Text Domain: redis-cache
|
8 |
Domain Path: /languages
|
9 |
Author: Till Krüss
|
@@ -17,7 +17,7 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|
17 |
exit;
|
18 |
}
|
19 |
|
20 |
-
define( 'WP_REDIS_VERSION', '1.5.
|
21 |
|
22 |
if ( defined( 'WP_CLI' ) && WP_CLI ) {
|
23 |
require_once dirname( __FILE__ ) . '/includes/wp-cli-commands.php';
|
3 |
Plugin Name: Redis Object Cache
|
4 |
Plugin URI: https://wordpress.org/plugins/redis-cache/
|
5 |
Description: A persistent object cache backend powered by Redis. Supports Predis, PhpRedis, HHVM, replication, clustering and WP-CLI.
|
6 |
+
Version: 1.5.8
|
7 |
Text Domain: redis-cache
|
8 |
Domain Path: /languages
|
9 |
Author: Till Krüss
|
17 |
exit;
|
18 |
}
|
19 |
|
20 |
+
define( 'WP_REDIS_VERSION', '1.5.8' );
|
21 |
|
22 |
if ( defined( 'WP_CLI' ) && WP_CLI ) {
|
23 |
require_once dirname( __FILE__ ) . '/includes/wp-cli-commands.php';
|