Redis Object Cache - Version 1.4.0

Version Description

  • Added support for igbinary
    • Added support for wp_suspend_cache_addition()
Download this release

Release Info

Developer tillkruess
Plugin Icon 128x128 Redis Object Cache
Version 1.4.0
Comparing to
See all releases

Code changes from version 1.3.9 to 1.4.0

includes/admin-page.css CHANGED
@@ -34,3 +34,24 @@
34
  0 0 0 1px #d54e21,
35
  0 0 2px 1px rgba( 30, 140, 190, .8 );
36
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
34
  0 0 0 1px #d54e21,
35
  0 0 2px 1px rgba( 30, 140, 190, .8 );
36
  }
37
+
38
+ .settings_page_redis-cache .card,
39
+ .settings_page_redis-cache br.clearfix {
40
+ display: none;
41
+ }
42
+
43
+ @media screen and (min-width: 1110px) {
44
+ .settings_page_redis-cache .card {
45
+ display: block;
46
+ float: right;
47
+ }
48
+
49
+ .settings_page_redis-cache .section-overview {
50
+ float: left;
51
+ }
52
+
53
+ .settings_page_redis-cache br.clearfix {
54
+ display: block;
55
+ clear: both;
56
+ }
57
+ }
includes/admin-page.php CHANGED
@@ -5,53 +5,77 @@
5
 
6
  <h1><?php _e( 'Redis Object Cache', 'redis-cache' ); ?></h1>
7
 
8
- <h2 class="title"><?php _e( 'Overview', 'redis-cache' ); ?></h2>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9
 
10
- <table class="form-table">
11
 
12
- <tr>
13
- <th><?php _e( 'Status:', 'redis-cache' ); ?></th>
14
- <td><code><?php echo $this->get_status(); ?></code></td>
15
- </tr>
16
 
17
- <?php if ( ! is_null( $this->get_redis_client_name() ) ) : ?>
18
- <tr>
19
- <th><?php _e( 'Client:', 'redis-cache' ); ?></th>
20
- <td><code><?php echo esc_html( $this->get_redis_client_name() ); ?></code></td>
21
- </tr>
22
- <?php endif; ?>
23
 
24
- <?php if ( ! is_null( $this->get_redis_cachekey_prefix() ) && trim( $this->get_redis_cachekey_prefix() ) !== '' ) : ?>
25
  <tr>
26
- <th><?php _e( 'Key Prefix:', 'redis-cache' ); ?></th>
27
- <td><code><?php echo esc_html( $this->get_redis_cachekey_prefix() ); ?></code></td>
28
  </tr>
29
- <?php endif; ?>
30
 
31
- <?php if ( ! is_null( $this->get_redis_maxttl() ) ) : ?>
32
- <tr>
33
- <th><?php _e( 'Max. TTL:', 'redis-cache' ); ?></th>
34
- <td><code><?php echo esc_html( $this->get_redis_maxttl() ); ?></code></td>
35
- </tr>
36
- <?php endif; ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
37
 
38
- </table>
 
 
39
 
40
- <p class="submit">
 
 
 
 
41
 
42
- <?php if ( $this->get_redis_status() ) : ?>
43
- <a href="<?php echo wp_nonce_url( network_admin_url( add_query_arg( 'action', 'flush-cache', $this->page ) ), 'flush-cache' ); ?>" class="button button-primary button-large"><?php _e( 'Flush Cache', 'redis-cache' ); ?></a> &nbsp;
44
- <?php endif; ?>
45
 
46
- <?php if ( ! $this->object_cache_dropin_exists() ) : ?>
47
- <a href="<?php echo wp_nonce_url( network_admin_url( add_query_arg( 'action', 'enable-cache', $this->page ) ), 'enable-cache' ); ?>" class="button button-primary button-large"><?php _e( 'Enable Object Cache', 'redis-cache' ); ?></a>
48
- <?php elseif ( $this->validate_object_cache_dropin() ) : ?>
49
- <a href="<?php echo wp_nonce_url( network_admin_url( add_query_arg( 'action', 'disable-cache', $this->page ) ), 'disable-cache' ); ?>" class="button button-secondary button-large delete"><?php _e( 'Disable Object Cache', 'redis-cache' ); ?></a>
50
- <?php endif; ?>
51
 
52
- </p>
53
 
54
- <h2 class="title"><?php _e( 'Servers', 'redis-cache' ); ?></h2>
 
 
55
 
56
  <?php $this->show_servers_list(); ?>
57
 
5
 
6
  <h1><?php _e( 'Redis Object Cache', 'redis-cache' ); ?></h1>
7
 
8
+ <?php if ( defined( 'EAE_DISABLE_NOTICES' ) || ! is_plugin_active( 'email-address-encoder' ) && ! is_plugin_active( 'email-encoder-premium' ) && ! is_plugin_inactive( 'email-address-encoder' ) && ! is_plugin_inactive( 'email-encoder-premium' ) ) : ?>
9
+ <div class="card">
10
+ <h2 class="title">
11
+ <?php _e( 'Are your email addresses protected?', 'redis-cache' ); ?>
12
+ </h2>
13
+ <p>
14
+ <?php _e( 'Enjoy a clean inbox and peace of mind knowing that your email address is safe from email-harvesting robots.', 'redis-cache' ); ?>
15
+ </p>
16
+ <p>
17
+ <a class="button button-primary" target="_blank" rel="noopener" href="https://encoder.till.im/?utm_source=wp-plugin&amp;utm_medium=redis">
18
+ <?php _e( 'Download for Free', 'email-address-encoder' ); ?>
19
+ </a>
20
+ </p>
21
+ </div>
22
+ <?php endif; ?>
23
 
24
+ <div class="section-overview">
25
 
26
+ <h2 class="title"><?php _e( 'Overview', 'redis-cache' ); ?></h2>
 
 
 
27
 
28
+ <table class="form-table">
 
 
 
 
 
29
 
 
30
  <tr>
31
+ <th><?php _e( 'Status:', 'redis-cache' ); ?></th>
32
+ <td><code><?php echo $this->get_status(); ?></code></td>
33
  </tr>
 
34
 
35
+ <?php if ( ! is_null( $this->get_redis_client_name() ) ) : ?>
36
+ <tr>
37
+ <th><?php _e( 'Client:', 'redis-cache' ); ?></th>
38
+ <td><code><?php echo esc_html( $this->get_redis_client_name() ); ?></code></td>
39
+ </tr>
40
+ <?php endif; ?>
41
+
42
+ <?php if ( ! is_null( $this->get_redis_cachekey_prefix() ) && trim( $this->get_redis_cachekey_prefix() ) !== '' ) : ?>
43
+ <tr>
44
+ <th><?php _e( 'Key Prefix:', 'redis-cache' ); ?></th>
45
+ <td><code><?php echo esc_html( $this->get_redis_cachekey_prefix() ); ?></code></td>
46
+ </tr>
47
+ <?php endif; ?>
48
+
49
+ <?php if ( ! is_null( $this->get_redis_maxttl() ) ) : ?>
50
+ <tr>
51
+ <th><?php _e( 'Max. TTL:', 'redis-cache' ); ?></th>
52
+ <td><code><?php echo esc_html( $this->get_redis_maxttl() ); ?></code></td>
53
+ </tr>
54
+ <?php endif; ?>
55
+
56
+ </table>
57
+
58
+ <p class="submit">
59
 
60
+ <?php if ( $this->get_redis_status() ) : ?>
61
+ <a href="<?php echo wp_nonce_url( network_admin_url( add_query_arg( 'action', 'flush-cache', $this->page ) ), 'flush-cache' ); ?>" class="button button-primary button-large"><?php _e( 'Flush Cache', 'redis-cache' ); ?></a> &nbsp;
62
+ <?php endif; ?>
63
 
64
+ <?php if ( ! $this->object_cache_dropin_exists() ) : ?>
65
+ <a href="<?php echo wp_nonce_url( network_admin_url( add_query_arg( 'action', 'enable-cache', $this->page ) ), 'enable-cache' ); ?>" class="button button-primary button-large"><?php _e( 'Enable Object Cache', 'redis-cache' ); ?></a>
66
+ <?php elseif ( $this->validate_object_cache_dropin() ) : ?>
67
+ <a href="<?php echo wp_nonce_url( network_admin_url( add_query_arg( 'action', 'disable-cache', $this->page ) ), 'disable-cache' ); ?>" class="button button-secondary button-large delete"><?php _e( 'Disable Object Cache', 'redis-cache' ); ?></a>
68
+ <?php endif; ?>
69
 
70
+ </p>
 
 
71
 
72
+ </div>
 
 
 
 
73
 
74
+ <br class="clearfix">
75
 
76
+ <h2 class="title">
77
+ <?php _e( 'Servers', 'redis-cache' ); ?>
78
+ </h2>
79
 
80
  <?php $this->show_servers_list(); ?>
81
 
includes/diagnostics.php CHANGED
@@ -11,12 +11,12 @@ $info[ 'Client' ] = $this->get_redis_client_name();
11
  $info[ 'Drop-in' ] = $dropin ? 'Valid' : 'Invalid';
12
 
13
  if ( $dropin ) {
14
- try {
15
- $cache = new WP_Object_Cache( false );
16
- $info[ 'Ping' ] = $cache->redis_instance()->ping();
17
- } catch ( Exception $exception ) {
18
- $info[ 'Connection Exception' ] = sprintf( '%s (%s)', $exception->getMessage(), get_class( $exception ) );
19
- }
20
  }
21
 
22
  $info[ 'Redis Extension' ] = class_exists( 'Redis' ) ? phpversion( 'redis' ) : 'Not Found';
@@ -33,13 +33,15 @@ if ( defined( 'HHVM_VERSION' ) ) {
33
  $info[ 'Multisite' ] = is_multisite() ? 'Yes' : 'No';
34
 
35
  if ( $dropin ) {
36
- $info[ 'Global Prefix' ] = json_encode( $wp_object_cache->global_prefix );
37
  $info[ 'Blog Prefix' ] = json_encode( $wp_object_cache->blog_prefix );
38
  }
39
 
40
  $constants = array(
41
  'WP_REDIS_DISABLED',
42
  'WP_REDIS_CLIENT',
 
 
43
  'WP_REDIS_HOST',
44
  'WP_REDIS_PORT',
45
  'WP_REDIS_DATABASE',
@@ -47,6 +49,7 @@ $constants = array(
47
  'WP_REDIS_CLUSTER',
48
  'WP_REDIS_SHARDS',
49
  'WP_REDIS_SENTINEL',
 
50
  'WP_REDIS_MAXTTL',
51
  'WP_CACHE_KEY_SALT',
52
  'WP_REDIS_GLOBAL_GROUPS',
@@ -73,29 +76,29 @@ foreach ( $info as $name => $value ) {
73
  }
74
 
75
  foreach ( get_dropins() as $file => $details ) {
76
- $dropins[ $file ] = sprintf(
77
- ' - %s v%s by %s',
78
- $details[ 'Name' ],
79
- $details[ 'Version' ],
80
- $details[ 'Author' ]
81
- );
82
  }
83
 
84
  if ( ! empty( $dropins ) ) {
85
- echo "Dropins: \r\n", implode( "\r\n", $dropins ), "\r\n";
86
  }
87
 
88
  foreach ( get_plugins() as $file => $details ) {
89
- $plugins[] = sprintf(
90
- ' - %s v%s by %s (%s%s)',
91
- $details[ 'Name' ],
92
- $details[ 'Version' ],
93
- $details[ 'Author' ],
94
- is_plugin_active( $file ) ? 'Active' : 'Inactive',
95
- is_multisite() ? ( is_plugin_active_for_network( $file ) ? ' network-wide' : '' ) : ''
96
- );
97
  }
98
 
99
  if ( ! empty( $plugins ) ) {
100
- echo "Plugins: \r\n", implode( "\r\n", $plugins ), "\r\n";
101
  }
11
  $info[ 'Drop-in' ] = $dropin ? 'Valid' : 'Invalid';
12
 
13
  if ( $dropin ) {
14
+ try {
15
+ $cache = new WP_Object_Cache( false );
16
+ $info[ 'Ping' ] = $cache->redis_instance()->ping();
17
+ } catch ( Exception $exception ) {
18
+ $info[ 'Connection Exception' ] = sprintf( '%s (%s)', $exception->getMessage(), get_class( $exception ) );
19
+ }
20
  }
21
 
22
  $info[ 'Redis Extension' ] = class_exists( 'Redis' ) ? phpversion( 'redis' ) : 'Not Found';
33
  $info[ 'Multisite' ] = is_multisite() ? 'Yes' : 'No';
34
 
35
  if ( $dropin ) {
36
+ $info[ 'Global Prefix' ] = json_encode( $wp_object_cache->global_prefix );
37
  $info[ 'Blog Prefix' ] = json_encode( $wp_object_cache->blog_prefix );
38
  }
39
 
40
  $constants = array(
41
  'WP_REDIS_DISABLED',
42
  'WP_REDIS_CLIENT',
43
+ 'WP_REDIS_SCHEME',
44
+ 'WP_REDIS_PATH',
45
  'WP_REDIS_HOST',
46
  'WP_REDIS_PORT',
47
  'WP_REDIS_DATABASE',
49
  'WP_REDIS_CLUSTER',
50
  'WP_REDIS_SHARDS',
51
  'WP_REDIS_SENTINEL',
52
+ 'WP_REDIS_IGBINARY',
53
  'WP_REDIS_MAXTTL',
54
  'WP_CACHE_KEY_SALT',
55
  'WP_REDIS_GLOBAL_GROUPS',
76
  }
77
 
78
  foreach ( get_dropins() as $file => $details ) {
79
+ $dropins[ $file ] = sprintf(
80
+ ' - %s v%s by %s',
81
+ $details[ 'Name' ],
82
+ $details[ 'Version' ],
83
+ $details[ 'Author' ]
84
+ );
85
  }
86
 
87
  if ( ! empty( $dropins ) ) {
88
+ echo "Dropins: \r\n", implode( "\r\n", $dropins ), "\r\n";
89
  }
90
 
91
  foreach ( get_plugins() as $file => $details ) {
92
+ $plugins[] = sprintf(
93
+ ' - %s v%s by %s (%s%s)',
94
+ $details[ 'Name' ],
95
+ $details[ 'Version' ],
96
+ $details[ 'Author' ],
97
+ is_plugin_active( $file ) ? 'Active' : 'Inactive',
98
+ is_multisite() ? ( is_plugin_active_for_network( $file ) ? ' network-wide' : '' ) : ''
99
+ );
100
  }
101
 
102
  if ( ! empty( $plugins ) ) {
103
+ echo "Plugins: \r\n", implode( "\r\n", $plugins ), "\r\n";
104
  }
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.3.9
7
  Author: Till Krüss
8
  Author URI: https://till.im/
9
  License: GPLv3
@@ -581,6 +581,10 @@ class WP_Object_Cache
581
  */
582
  protected function add_or_replace($add, $key, $value, $group = 'default', $expiration = 0)
583
  {
 
 
 
 
584
  $result = true;
585
  $derived_key = $this->build_key($key, $group);
586
 
@@ -1111,6 +1115,10 @@ class WP_Object_Cache
1111
  */
1112
  protected function maybe_unserialize($original)
1113
  {
 
 
 
 
1114
  // don't attempt to unserialize data that wasn't serialized going in
1115
  if ($this->is_serialized($original)) {
1116
  return @unserialize($original);
@@ -1126,6 +1134,10 @@ class WP_Object_Cache
1126
  */
1127
  protected function maybe_serialize($data)
1128
  {
 
 
 
 
1129
  if (is_array($data) || is_object($data)) {
1130
  return serialize($data);
1131
  }
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.4.0
7
  Author: Till Krüss
8
  Author URI: https://till.im/
9
  License: GPLv3
581
  */
582
  protected function add_or_replace($add, $key, $value, $group = 'default', $expiration = 0)
583
  {
584
+ if ( $add && wp_suspend_cache_addition() ) {
585
+ return false;
586
+ }
587
+
588
  $result = true;
589
  $derived_key = $this->build_key($key, $group);
590
 
1115
  */
1116
  protected function maybe_unserialize($original)
1117
  {
1118
+ if (defined('WP_REDIS_IGBINARY') && WP_REDIS_IGBINARY) {
1119
+ return igbinary_unserialize($original);
1120
+ }
1121
+
1122
  // don't attempt to unserialize data that wasn't serialized going in
1123
  if ($this->is_serialized($original)) {
1124
  return @unserialize($original);
1134
  */
1135
  protected function maybe_serialize($data)
1136
  {
1137
+ if (defined('WP_REDIS_IGBINARY') && WP_REDIS_IGBINARY) {
1138
+ return igbinary_serialize($data);
1139
+ }
1140
+
1141
  if (is_array($data) || is_object($data)) {
1142
  return serialize($data);
1143
  }
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: https://www.paypal.me/tillkruss
4
  Tags: redis, predis, phpredis, hhvm, pecl, caching, cache, object cache, performance, replication, clustering
5
  Requires at least: 3.3
6
  Tested up to: 5.0
7
- Stable tag: 1.3.9
8
  License: GPLv3
9
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
10
 
@@ -42,6 +42,10 @@ To adjust the connection parameters, define any of the following constants in yo
42
 
43
  Specifies the client used to communicate with Redis. Supports `hhvm`, `pecl` and `predis`.
44
 
 
 
 
 
45
  * `WP_REDIS_HOST` (default: `127.0.0.1`)
46
 
47
  IP or hostname of the target server. This is ignored when connecting to Redis using UNIX domain sockets.
@@ -50,6 +54,10 @@ To adjust the connection parameters, define any of the following constants in yo
50
 
51
  TCP/IP port of the target server. This is ignored when connecting to Redis using UNIX domain sockets.
52
 
 
 
 
 
53
  * `WP_REDIS_DATABASE` (default: `0`)
54
 
55
  Accepts a numeric value that is used to automatically select a logical database with the `SELECT` command.
@@ -87,6 +95,10 @@ To adjust the configuration, define any of the following constants in your `wp-c
87
 
88
  Set to `true` to disable the object cache at runtime.
89
 
 
 
 
 
90
 
91
  == Replication & Clustering ==
92
 
@@ -163,6 +175,11 @@ The following commands are supported:
163
 
164
  == Changelog ==
165
 
 
 
 
 
 
166
  = 1.3.9 =
167
 
168
  * Fixed `WP_REDIS_SHARDS` not showing up in server list
@@ -302,6 +319,10 @@ The following commands are supported:
302
 
303
  == Upgrade Notice ==
304
 
 
 
 
 
305
  = 1.3.9 =
306
 
307
  This update contains fixes for sharding.
4
  Tags: redis, predis, phpredis, hhvm, pecl, caching, cache, object cache, performance, replication, clustering
5
  Requires at least: 3.3
6
  Tested up to: 5.0
7
+ Stable tag: 1.4.0
8
  License: GPLv3
9
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
10
 
42
 
43
  Specifies the client used to communicate with Redis. Supports `hhvm`, `pecl` and `predis`.
44
 
45
+ * `WP_REDIS_SCHEME` (default: `tcp`)
46
+
47
+ Specifies the protocol used to communicate with an instance of Redis. Internally the client uses the connection class associated to the specified connection scheme. Supports `tcp` (TCP/IP), `unix` (UNIX domain sockets), `tls` (transport layer security) or `http` (HTTP protocol through Webdis).
48
+
49
  * `WP_REDIS_HOST` (default: `127.0.0.1`)
50
 
51
  IP or hostname of the target server. This is ignored when connecting to Redis using UNIX domain sockets.
54
 
55
  TCP/IP port of the target server. This is ignored when connecting to Redis using UNIX domain sockets.
56
 
57
+ * `WP_REDIS_PATH` (default: _not set_)
58
+
59
+ Path of the UNIX domain socket file used when connecting to Redis using UNIX domain sockets.
60
+
61
  * `WP_REDIS_DATABASE` (default: `0`)
62
 
63
  Accepts a numeric value that is used to automatically select a logical database with the `SELECT` command.
95
 
96
  Set to `true` to disable the object cache at runtime.
97
 
98
+ * `WP_REDIS_IGBINARY` (default: _not set_)
99
+
100
+ Set to `true` to enable the [igbinary](https://github.com/igbinary/igbinary) serializer.
101
+
102
 
103
  == Replication & Clustering ==
104
 
175
 
176
  == Changelog ==
177
 
178
+ = 1.4.0 =
179
+
180
+ * Added support for igbinary
181
+ * Added support for `wp_suspend_cache_addition()`
182
+
183
  = 1.3.9 =
184
 
185
  * Fixed `WP_REDIS_SHARDS` not showing up in server list
319
 
320
  == Upgrade Notice ==
321
 
322
+ = 1.4.0 =
323
+
324
+ This update adds support for igbinary and `wp_suspend_cache_addition()`.
325
+
326
  = 1.3.9 =
327
 
328
  This update contains fixes for sharding.
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.3.9
7
  Text Domain: redis-cache
8
  Domain Path: /languages
9
  Author: Till Krüss
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.4.0
7
  Text Domain: redis-cache
8
  Domain Path: /languages
9
  Author: Till Krüss