Redis Object Cache - Version 1.3.5

Version Description

  • Added basic diagnostics to admin interface
    • Added WP_REDIS_DISABLED constant to disable cache at runtime
    • Prevent "Invalid plugin header" error
    • Return integer from increment() and decrement() methods
    • Prevent object cache from being instantiated more than once
    • Always separate cache key prefix and group by semicolon
    • Improved performance of build_key()
    • Only apply redis_object_cache_get filter if callbacks have been registered
    • Fixed add_or_replace() to only set cache key if it doesn't exist
    • Added redis_object_cache_flush action
    • Added redis_object_cache_enable action
    • Added redis_object_cache_disable action
    • Added redis_object_cache_update_dropin action
Download this release

Release Info

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

Code changes from version 1.3.4 to 1.3.5

includes/admin-page.php CHANGED
@@ -55,4 +55,16 @@
55
 
56
  <?php $this->show_servers_list(); ?>
57
 
 
 
 
 
 
 
 
 
 
 
 
 
58
  </div>
55
 
56
  <?php $this->show_servers_list(); ?>
57
 
58
+ <?php if ( isset( $_GET[ 'diagnostics' ] ) ) : ?>
59
+
60
+ <h2 class="title"><?php _e( 'Diagnostics', 'redis-cache' ); ?></h2>
61
+
62
+ <textarea class="large-text readonly" rows="20" readonly><?php include dirname( __FILE__ ) . '/diagnostics.php'; ?></textarea>
63
+
64
+ <?php else : ?>
65
+
66
+ <p><a href="<?php echo network_admin_url( add_query_arg( 'diagnostics', '1', $this->page ) ); ?>"><?php _e( 'Show Diagnostics', 'redis-cache' ); ?></a></p>
67
+
68
+ <?php endif; ?>
69
+
70
  </div>
includes/diagnostics.php ADDED
@@ -0,0 +1,59 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ $info = array();
4
+
5
+ if ( defined( 'PHP_VERSION' ) ) {
6
+ $info[ 'PHP Version' ] = PHP_VERSION;
7
+ }
8
+
9
+ if ( defined( 'HHVM_VERSION' ) ) {
10
+ $info[ 'HHVM Version' ] = HHVM_VERSION;
11
+ }
12
+
13
+ $info[ __( 'Multisite', 'redis-cache' ) ] = is_multisite() ? __( 'Yes', 'redis-cache' ) : __( 'No', 'redis-cache' );
14
+
15
+ $info[ __( 'Redis', 'redis-cache' ) ] = class_exists( 'Redis' ) ? phpversion( 'redis' ) : __( 'Not Found', 'redis-cache' );
16
+ $info[ __( 'Predis', 'redis-cache' ) ] = class_exists( 'Predis\Client' ) ? Predis\Client::VERSION : __( 'Not Found', 'redis-cache' );
17
+
18
+ $info[ __( 'Status', 'redis-cache' ) ] = $this->get_status();
19
+ $info[ __( 'Client', 'redis-cache' ) ] = $this->get_redis_client_name();
20
+
21
+ $constants = array(
22
+ 'WP_REDIS_DISABLED',
23
+ 'WP_REDIS_CLIENT',
24
+ 'WP_REDIS_SCHEME',
25
+ 'WP_REDIS_HOST',
26
+ 'WP_REDIS_PORT',
27
+ 'WP_REDIS_PATH',
28
+ 'WP_REDIS_DATABASE',
29
+ 'WP_REDIS_SERVERS',
30
+ 'WP_REDIS_CLUSTER',
31
+ 'WP_REDIS_MAXTTL',
32
+ 'WP_REDIS_GLOBAL_GROUPS',
33
+ 'WP_REDIS_IGNORED_GROUPS',
34
+ 'WP_CACHE_KEY_SALT',
35
+ );
36
+
37
+ foreach ( $constants as $constant ) {
38
+ if ( defined( $constant ) ) {
39
+ $info[$constant] = json_encode( constant( $constant ) );
40
+ }
41
+ }
42
+
43
+ if ( defined( 'WP_REDIS_PASSWORD' ) ) {
44
+ $info[ 'WP_REDIS_PASSWORD' ] = json_encode( empty( WP_REDIS_PASSWORD ) ? null : str_repeat( '*', strlen( WP_REDIS_PASSWORD ) ) );
45
+ }
46
+
47
+ if ( $this->validate_object_cache_dropin() ) {
48
+ $info[ __( 'Drop-in', 'redis-cache' ) ] = __( 'Valid', 'redis-cache' );
49
+ $info[ __( 'Global Prefix', 'redis-cache' ) ] = json_encode( $GLOBALS[ 'wp_object_cache' ]->global_prefix );
50
+ $info[ __( 'Blog Prefix', 'redis-cache' ) ] = json_encode( $GLOBALS[ 'wp_object_cache' ]->blog_prefix );
51
+ $info[ __( 'Global Groups', 'redis-cache' ) ] = json_encode( $GLOBALS[ 'wp_object_cache' ]->global_groups );
52
+ $info[ __( 'Ignored Groups', 'redis-cache' ) ] = json_encode( $GLOBALS[ 'wp_object_cache' ]->ignored_groups );
53
+ } else {
54
+ $info[ __( 'Drop-in', 'redis-cache' ) ] = __( 'Invalid', 'redis-cache' );
55
+ }
56
+
57
+ foreach ($info as $name => $value) {
58
+ echo "{$name}: {$value}\r\n";
59
+ }
includes/object-cache.php CHANGED
@@ -1,9 +1,9 @@
1
  <?php
2
  /*
3
- Plugin Name: Redis Object Cache
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.4
7
  Author: Till Krüss
8
  Author URI: https://till.im/
9
  License: GPLv3
@@ -13,6 +13,8 @@ Based on Eric Mann's and Erick Hitter's Redis Object Cache:
13
  https://github.com/ericmann/Redis-Object-Cache
14
  */
15
 
 
 
16
  /**
17
  * Adds a value to cache.
18
  *
@@ -30,6 +32,7 @@ https://github.com/ericmann/Redis-Object-Cache
30
  */
31
  function wp_cache_add( $key, $value, $group = '', $expiration = 0 ) {
32
  global $wp_object_cache;
 
33
  return $wp_object_cache->add( $key, $value, $group, $expiration );
34
  }
35
 
@@ -60,6 +63,7 @@ function wp_cache_close() {
60
  */
61
  function wp_cache_decr( $key, $offset = 1, $group = '' ) {
62
  global $wp_object_cache;
 
63
  return $wp_object_cache->decrement( $key, $offset, $group );
64
  }
65
 
@@ -76,6 +80,7 @@ function wp_cache_decr( $key, $offset = 1, $group = '' ) {
76
  */
77
  function wp_cache_delete( $key, $group = '', $time = 0 ) {
78
  global $wp_object_cache;
 
79
  return $wp_object_cache->delete( $key, $group, $time );
80
  }
81
 
@@ -90,6 +95,7 @@ function wp_cache_delete( $key, $group = '', $time = 0 ) {
90
  */
91
  function wp_cache_flush( $delay = 0 ) {
92
  global $wp_object_cache;
 
93
  return $wp_object_cache->flush( $delay );
94
  }
95
 
@@ -111,6 +117,7 @@ function wp_cache_flush( $delay = 0 ) {
111
  */
112
  function wp_cache_get( $key, $group = '', $force = false, &$found = null ) {
113
  global $wp_object_cache;
 
114
  return $wp_object_cache->get( $key, $group, $force, $found );
115
  }
116
 
@@ -131,6 +138,7 @@ function wp_cache_get( $key, $group = '', $force = false, &$found = null ) {
131
  */
132
  function wp_cache_get_multi( $groups ) {
133
  global $wp_object_cache;
 
134
  return $wp_object_cache->get_multi( $groups );
135
  }
136
 
@@ -147,6 +155,7 @@ function wp_cache_get_multi( $groups ) {
147
  */
148
  function wp_cache_incr( $key, $offset = 1, $group = '' ) {
149
  global $wp_object_cache;
 
150
  return $wp_object_cache->increment( $key, $offset, $group );
151
  }
152
 
@@ -159,7 +168,10 @@ function wp_cache_incr( $key, $offset = 1, $group = '' ) {
159
  */
160
  function wp_cache_init() {
161
  global $wp_object_cache;
162
- $wp_object_cache = new WP_Object_Cache;
 
 
 
163
  }
164
 
165
  /**
@@ -179,6 +191,7 @@ function wp_cache_init() {
179
  */
180
  function wp_cache_replace( $key, $value, $group = '', $expiration = 0 ) {
181
  global $wp_object_cache;
 
182
  return $wp_object_cache->replace( $key, $value, $group, $expiration );
183
  }
184
 
@@ -198,6 +211,7 @@ function wp_cache_replace( $key, $value, $group = '', $expiration = 0 ) {
198
  */
199
  function wp_cache_set( $key, $value, $group = '', $expiration = 0 ) {
200
  global $wp_object_cache;
 
201
  return $wp_object_cache->set( $key, $value, $group, $expiration );
202
  }
203
 
@@ -214,6 +228,7 @@ function wp_cache_set( $key, $value, $group = '', $expiration = 0 ) {
214
  */
215
  function wp_cache_switch_to_blog( $_blog_id ) {
216
  global $wp_object_cache;
 
217
  return $wp_object_cache->switch_to_blog( $_blog_id );
218
  }
219
 
@@ -228,6 +243,7 @@ function wp_cache_switch_to_blog( $_blog_id ) {
228
  */
229
  function wp_cache_add_global_groups( $groups ) {
230
  global $wp_object_cache;
 
231
  $wp_object_cache->add_global_groups( $groups );
232
  }
233
 
@@ -242,6 +258,7 @@ function wp_cache_add_global_groups( $groups ) {
242
  */
243
  function wp_cache_add_non_persistent_groups( $groups ) {
244
  global $wp_object_cache;
 
245
  $wp_object_cache->add_non_persistent_groups( $groups );
246
  }
247
 
@@ -392,7 +409,7 @@ class WP_Object_Cache {
392
 
393
  if ( strcasecmp( 'pecl', $client ) === 0 ) {
394
 
395
- $this->redis_client = sprintf( 'PECL Extension (v%s)', phpversion('redis') );
396
  $this->redis = new Redis();
397
 
398
  if ( strcasecmp( 'unix', $parameters[ 'scheme' ] ) === 0 ) {
@@ -476,7 +493,7 @@ class WP_Object_Cache {
476
  // Assign global and blog prefixes for use with keys
477
  if ( function_exists( 'is_multisite' ) ) {
478
  $this->global_prefix = ( is_multisite() || defined( 'CUSTOM_USER_TABLE' ) && defined( 'CUSTOM_USER_META_TABLE' ) ) ? '' : $table_prefix;
479
- $this->blog_prefix = ( is_multisite() ? $blog_id : $table_prefix ) . ':';
480
  }
481
  }
482
 
@@ -542,16 +559,15 @@ class WP_Object_Cache {
542
  * @param int $expiration The expiration time, defaults to 0.
543
  * @return bool Returns TRUE on success or FALSE on failure.
544
  */
545
-
546
  protected function add_or_replace( $add, $key, $value, $group = 'default', $expiration = 0 ) {
547
- $derived_key = $this->build_key( $key, $group );
548
  $result = true;
 
549
 
550
  // save if group not excluded and redis is up
551
  if ( ! in_array( $group, $this->ignored_groups ) && $this->redis_status() ) {
552
  $exists = $this->redis->exists( $derived_key );
553
 
554
- if ( $add === $exists ) {
555
  return false;
556
  }
557
 
@@ -565,7 +581,8 @@ class WP_Object_Cache {
565
  }
566
 
567
  $exists = isset( $this->cache[ $derived_key ] );
568
- if ( $add === $exists ) {
 
569
  return false;
570
  }
571
 
@@ -584,9 +601,9 @@ class WP_Object_Cache {
584
  * @return bool Returns TRUE on success or FALSE on failure.
585
  */
586
  public function delete( $key, $group = 'default' ) {
 
587
  $derived_key = $this->build_key( $key, $group );
588
 
589
- $result = false;
590
  if ( isset( $this->cache[ $derived_key ] ) ) {
591
  unset( $this->cache[ $derived_key ] );
592
  $result = true;
@@ -596,7 +613,9 @@ class WP_Object_Cache {
596
  $result = $this->parse_redis_response( $this->redis->del( $derived_key ) );
597
  }
598
 
599
- do_action('redis_object_cache_delete', $key, $group);
 
 
600
 
601
  return $result;
602
  }
@@ -609,14 +628,20 @@ class WP_Object_Cache {
609
  */
610
  public function flush( $delay = 0 ) {
611
  $delay = abs( intval( $delay ) );
 
612
  if ( $delay ) {
613
  sleep( $delay );
614
  }
615
 
 
616
  $this->cache = array();
617
 
618
  if ( $this->redis_status() ) {
619
  $result = $this->parse_redis_response( $this->redis->flushdb() );
 
 
 
 
620
  }
621
 
622
  return $result;
@@ -652,7 +677,7 @@ class WP_Object_Cache {
652
 
653
  $result = $this->redis->get( $derived_key );
654
 
655
- if ($result === null || $result === false) {
656
  $found = false;
657
  $this->cache_misses++;
658
 
@@ -671,11 +696,13 @@ class WP_Object_Cache {
671
  do_action( 'redis_object_cache_get', $key, $value, $group, $force, $found );
672
  }
673
 
674
- if ( function_exists( 'apply_filters' ) ) {
675
- return apply_filters( 'redis_object_cache_get', $value, $key, $group, $force, $found );
676
- } else {
677
- return $value;
678
  }
 
 
679
  }
680
 
681
  /**
@@ -706,6 +733,7 @@ class WP_Object_Cache {
706
  } else {
707
  // Reformat arguments as expected by Redis
708
  $derived_keys = array();
 
709
  foreach ( $keys as $key ) {
710
  $derived_keys[] = $this->build_key( $key, $group );
711
  }
@@ -751,12 +779,13 @@ class WP_Object_Cache {
751
  * @return bool Returns TRUE on success or FALSE on failure.
752
  */
753
  public function set( $key, $value, $group = 'default', $expiration = 0 ) {
754
- $derived_key = $this->build_key( $key, $group );
755
  $result = true;
 
756
 
757
  // save if group not excluded from redis and redis is up
758
  if ( ! in_array( $group, $this->ignored_groups ) && $this->redis_status() ) {
759
- $expiration = $this->validate_expiration($expiration);
 
760
  if ( $expiration ) {
761
  $result = $this->parse_redis_response( $this->redis->setex( $derived_key, $expiration, $this->maybe_serialize( $value ) ) );
762
  } else {
@@ -782,7 +811,7 @@ class WP_Object_Cache {
782
  * @param string $key
783
  * @param int $offset
784
  * @param string $group
785
- * @return bool
786
  */
787
  public function increment( $key, $offset = 1, $group = 'default' ) {
788
  $derived_key = $this->build_key( $key, $group );
@@ -794,7 +823,7 @@ class WP_Object_Cache {
794
  $value += $offset;
795
  $this->add_to_internal_cache( $derived_key, $value );
796
 
797
- return true;
798
  }
799
 
800
  // Save to Redis
@@ -823,7 +852,7 @@ class WP_Object_Cache {
823
  * @param string $key
824
  * @param int $offset
825
  * @param string $group
826
- * @return bool
827
  */
828
  public function decrement( $key, $offset = 1, $group = 'default' ) {
829
  $derived_key = $this->build_key( $key, $group );
@@ -835,7 +864,7 @@ class WP_Object_Cache {
835
  $value -= $offset;
836
  $this->add_to_internal_cache( $derived_key, $value );
837
 
838
- return true;
839
  }
840
 
841
  // Save to Redis
@@ -869,10 +898,7 @@ class WP_Object_Cache {
869
  }
870
 
871
  /**
872
- * Builds a key for the cached object using the blog_id, key, and group values.
873
- *
874
- * @author Ryan Boren This function is inspired by the original WP Memcached Object cache.
875
- * @link http://wordpress.org/extend/plugins/memcached/
876
  *
877
  * @param string $key The key under which to store the value.
878
  * @param string $group The group value appended to the $key.
@@ -884,13 +910,13 @@ class WP_Object_Cache {
884
  $group = 'default';
885
  }
886
 
887
- if ( false !== array_search( $group, $this->global_groups ) ) {
888
  $prefix = $this->global_prefix;
889
  } else {
890
  $prefix = $this->blog_prefix;
891
  }
892
 
893
- return preg_replace( '/\s+/', '', WP_CACHE_KEY_SALT . "$prefix$group:$key" );
894
  }
895
 
896
  /**
@@ -922,11 +948,11 @@ class WP_Object_Cache {
922
  }
923
 
924
  if ( is_numeric( $response ) ) {
925
- return (bool) $response;
926
  }
927
 
928
  if ( is_object( $response ) && method_exists( $response, 'getPayload' ) ) {
929
- return 'OK' === $response->getPayload();
930
  }
931
 
932
  return false;
@@ -971,7 +997,8 @@ class WP_Object_Cache {
971
  return false;
972
  }
973
 
974
- $this->blog_prefix = $_blog_id . ':';
 
975
  return true;
976
  }
977
 
@@ -1008,9 +1035,11 @@ class WP_Object_Cache {
1008
  */
1009
  protected function validate_expiration( $expiration ) {
1010
  $expiration = ( is_array( $expiration ) || is_object( $expiration ) ? 0 : abs( intval( $expiration ) ) );
 
1011
  if ( $expiration === 0 && defined( 'WP_REDIS_MAXTTL' ) ) {
1012
  $expiration = intval( WP_REDIS_MAXTTL );
1013
  }
 
1014
  return $expiration;
1015
  }
1016
 
@@ -1021,8 +1050,11 @@ class WP_Object_Cache {
1021
  * @return mixed Unserialized data can be any type.
1022
  */
1023
  protected function maybe_unserialize( $original ) {
1024
- if ( $this->is_serialized( $original ) ) // don't attempt to unserialize data that wasn't serialized going in
 
1025
  return @unserialize( $original );
 
 
1026
  return $original;
1027
  }
1028
 
@@ -1032,11 +1064,13 @@ class WP_Object_Cache {
1032
  * @return mixed A scalar data
1033
  */
1034
  protected function maybe_serialize( $data ) {
1035
- if ( is_array( $data ) || is_object( $data ) )
1036
  return serialize( $data );
 
1037
 
1038
- if ( $this->is_serialized( $data, false ) )
1039
  return serialize( $data );
 
1040
 
1041
  return $data;
1042
  }
@@ -1052,41 +1086,53 @@ class WP_Object_Cache {
1052
  * @return bool False if not serialized and true if it was.
1053
  */
1054
  protected function is_serialized( $data, $strict = true ) {
1055
-
1056
  // if it isn't a string, it isn't serialized.
1057
  if ( ! is_string( $data ) ) {
1058
  return false;
1059
  }
 
1060
  $data = trim( $data );
1061
- if ( 'N;' == $data ) {
 
1062
  return true;
1063
  }
 
1064
  if ( strlen( $data ) < 4 ) {
1065
  return false;
1066
  }
 
1067
  if ( ':' !== $data[1] ) {
1068
  return false;
1069
  }
 
1070
  if ( $strict ) {
1071
  $lastc = substr( $data, -1 );
 
1072
  if ( ';' !== $lastc && '}' !== $lastc ) {
1073
  return false;
1074
  }
1075
  } else {
1076
  $semicolon = strpos( $data, ';' );
1077
- $brace = strpos( $data, '}' );
 
1078
  // Either ; or } must exist.
1079
- if ( false === $semicolon && false === $brace )
1080
  return false;
 
 
1081
  // But neither must be in the first X characters.
1082
- if ( false !== $semicolon && $semicolon < 3 )
1083
  return false;
1084
- if ( false !== $brace && $brace < 4 )
 
 
1085
  return false;
 
1086
  }
1087
  $token = $data[0];
 
1088
  switch ( $token ) {
1089
- case 's' :
1090
  if ( $strict ) {
1091
  if ( '"' !== substr( $data, -2, 1 ) ) {
1092
  return false;
@@ -1095,16 +1141,20 @@ class WP_Object_Cache {
1095
  return false;
1096
  }
1097
  // or else fall through
1098
- case 'a' :
1099
- case 'O' :
1100
  return (bool) preg_match( "/^{$token}:[0-9]+:/s", $data );
1101
- case 'b' :
1102
- case 'i' :
1103
- case 'd' :
1104
  $end = $strict ? '$' : '';
 
1105
  return (bool) preg_match( "/^{$token}:[0-9.E-]+;$end/", $data );
1106
  }
 
1107
  return false;
1108
  }
1109
 
1110
  }
 
 
1
  <?php
2
  /*
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.5
7
  Author: Till Krüss
8
  Author URI: https://till.im/
9
  License: GPLv3
13
  https://github.com/ericmann/Redis-Object-Cache
14
  */
15
 
16
+ if ( ! defined( 'WP_REDIS_DISABLED' ) || ! WP_REDIS_DISABLED ) :
17
+
18
  /**
19
  * Adds a value to cache.
20
  *
32
  */
33
  function wp_cache_add( $key, $value, $group = '', $expiration = 0 ) {
34
  global $wp_object_cache;
35
+
36
  return $wp_object_cache->add( $key, $value, $group, $expiration );
37
  }
38
 
63
  */
64
  function wp_cache_decr( $key, $offset = 1, $group = '' ) {
65
  global $wp_object_cache;
66
+
67
  return $wp_object_cache->decrement( $key, $offset, $group );
68
  }
69
 
80
  */
81
  function wp_cache_delete( $key, $group = '', $time = 0 ) {
82
  global $wp_object_cache;
83
+
84
  return $wp_object_cache->delete( $key, $group, $time );
85
  }
86
 
95
  */
96
  function wp_cache_flush( $delay = 0 ) {
97
  global $wp_object_cache;
98
+
99
  return $wp_object_cache->flush( $delay );
100
  }
101
 
117
  */
118
  function wp_cache_get( $key, $group = '', $force = false, &$found = null ) {
119
  global $wp_object_cache;
120
+
121
  return $wp_object_cache->get( $key, $group, $force, $found );
122
  }
123
 
138
  */
139
  function wp_cache_get_multi( $groups ) {
140
  global $wp_object_cache;
141
+
142
  return $wp_object_cache->get_multi( $groups );
143
  }
144
 
155
  */
156
  function wp_cache_incr( $key, $offset = 1, $group = '' ) {
157
  global $wp_object_cache;
158
+
159
  return $wp_object_cache->increment( $key, $offset, $group );
160
  }
161
 
168
  */
169
  function wp_cache_init() {
170
  global $wp_object_cache;
171
+
172
+ if ( ! ( $wp_object_cache instanceof WP_Object_Cache ) ) {
173
+ $wp_object_cache = new WP_Object_Cache;
174
+ }
175
  }
176
 
177
  /**
191
  */
192
  function wp_cache_replace( $key, $value, $group = '', $expiration = 0 ) {
193
  global $wp_object_cache;
194
+
195
  return $wp_object_cache->replace( $key, $value, $group, $expiration );
196
  }
197
 
211
  */
212
  function wp_cache_set( $key, $value, $group = '', $expiration = 0 ) {
213
  global $wp_object_cache;
214
+
215
  return $wp_object_cache->set( $key, $value, $group, $expiration );
216
  }
217
 
228
  */
229
  function wp_cache_switch_to_blog( $_blog_id ) {
230
  global $wp_object_cache;
231
+
232
  return $wp_object_cache->switch_to_blog( $_blog_id );
233
  }
234
 
243
  */
244
  function wp_cache_add_global_groups( $groups ) {
245
  global $wp_object_cache;
246
+
247
  $wp_object_cache->add_global_groups( $groups );
248
  }
249
 
258
  */
259
  function wp_cache_add_non_persistent_groups( $groups ) {
260
  global $wp_object_cache;
261
+
262
  $wp_object_cache->add_non_persistent_groups( $groups );
263
  }
264
 
409
 
410
  if ( strcasecmp( 'pecl', $client ) === 0 ) {
411
 
412
+ $this->redis_client = sprintf( 'PECL Extension (v%s)', phpversion( 'redis' ) );
413
  $this->redis = new Redis();
414
 
415
  if ( strcasecmp( 'unix', $parameters[ 'scheme' ] ) === 0 ) {
493
  // Assign global and blog prefixes for use with keys
494
  if ( function_exists( 'is_multisite' ) ) {
495
  $this->global_prefix = ( is_multisite() || defined( 'CUSTOM_USER_TABLE' ) && defined( 'CUSTOM_USER_META_TABLE' ) ) ? '' : $table_prefix;
496
+ $this->blog_prefix = ( is_multisite() ? $blog_id : $table_prefix );
497
  }
498
  }
499
 
559
  * @param int $expiration The expiration time, defaults to 0.
560
  * @return bool Returns TRUE on success or FALSE on failure.
561
  */
 
562
  protected function add_or_replace( $add, $key, $value, $group = 'default', $expiration = 0 ) {
 
563
  $result = true;
564
+ $derived_key = $this->build_key( $key, $group );
565
 
566
  // save if group not excluded and redis is up
567
  if ( ! in_array( $group, $this->ignored_groups ) && $this->redis_status() ) {
568
  $exists = $this->redis->exists( $derived_key );
569
 
570
+ if ( $add == $exists ) {
571
  return false;
572
  }
573
 
581
  }
582
 
583
  $exists = isset( $this->cache[ $derived_key ] );
584
+
585
+ if ( $add == $exists ) {
586
  return false;
587
  }
588
 
601
  * @return bool Returns TRUE on success or FALSE on failure.
602
  */
603
  public function delete( $key, $group = 'default' ) {
604
+ $result = false;
605
  $derived_key = $this->build_key( $key, $group );
606
 
 
607
  if ( isset( $this->cache[ $derived_key ] ) ) {
608
  unset( $this->cache[ $derived_key ] );
609
  $result = true;
613
  $result = $this->parse_redis_response( $this->redis->del( $derived_key ) );
614
  }
615
 
616
+ if ( function_exists( 'do_action' ) ) {
617
+ do_action( 'redis_object_cache_delete', $key, $group );
618
+ }
619
 
620
  return $result;
621
  }
628
  */
629
  public function flush( $delay = 0 ) {
630
  $delay = abs( intval( $delay ) );
631
+
632
  if ( $delay ) {
633
  sleep( $delay );
634
  }
635
 
636
+ $result = false;
637
  $this->cache = array();
638
 
639
  if ( $this->redis_status() ) {
640
  $result = $this->parse_redis_response( $this->redis->flushdb() );
641
+
642
+ if ( function_exists( 'do_action' ) ) {
643
+ do_action( 'redis_object_cache_flush', $result, $delay );
644
+ }
645
  }
646
 
647
  return $result;
677
 
678
  $result = $this->redis->get( $derived_key );
679
 
680
+ if ( $result === null || $result === false ) {
681
  $found = false;
682
  $this->cache_misses++;
683
 
696
  do_action( 'redis_object_cache_get', $key, $value, $group, $force, $found );
697
  }
698
 
699
+ if ( function_exists( 'apply_filters' ) && function_exists( 'has_filter' ) ) {
700
+ if ( has_filter( 'redis_object_cache_get' ) ) {
701
+ return apply_filters( 'redis_object_cache_get', $value, $key, $group, $force, $found );
702
+ }
703
  }
704
+
705
+ return $value;
706
  }
707
 
708
  /**
733
  } else {
734
  // Reformat arguments as expected by Redis
735
  $derived_keys = array();
736
+
737
  foreach ( $keys as $key ) {
738
  $derived_keys[] = $this->build_key( $key, $group );
739
  }
779
  * @return bool Returns TRUE on success or FALSE on failure.
780
  */
781
  public function set( $key, $value, $group = 'default', $expiration = 0 ) {
 
782
  $result = true;
783
+ $derived_key = $this->build_key( $key, $group );
784
 
785
  // save if group not excluded from redis and redis is up
786
  if ( ! in_array( $group, $this->ignored_groups ) && $this->redis_status() ) {
787
+ $expiration = $this->validate_expiration( $expiration );
788
+
789
  if ( $expiration ) {
790
  $result = $this->parse_redis_response( $this->redis->setex( $derived_key, $expiration, $this->maybe_serialize( $value ) ) );
791
  } else {
811
  * @param string $key
812
  * @param int $offset
813
  * @param string $group
814
+ * @return int|bool
815
  */
816
  public function increment( $key, $offset = 1, $group = 'default' ) {
817
  $derived_key = $this->build_key( $key, $group );
823
  $value += $offset;
824
  $this->add_to_internal_cache( $derived_key, $value );
825
 
826
+ return $value;
827
  }
828
 
829
  // Save to Redis
852
  * @param string $key
853
  * @param int $offset
854
  * @param string $group
855
+ * @return int|bool
856
  */
857
  public function decrement( $key, $offset = 1, $group = 'default' ) {
858
  $derived_key = $this->build_key( $key, $group );
864
  $value -= $offset;
865
  $this->add_to_internal_cache( $derived_key, $value );
866
 
867
+ return $value;
868
  }
869
 
870
  // Save to Redis
898
  }
899
 
900
  /**
901
+ * Builds a key for the cached object using the prefix, group and key.
 
 
 
902
  *
903
  * @param string $key The key under which to store the value.
904
  * @param string $group The group value appended to the $key.
910
  $group = 'default';
911
  }
912
 
913
+ if ( in_array( $group, $this->global_groups ) ) {
914
  $prefix = $this->global_prefix;
915
  } else {
916
  $prefix = $this->blog_prefix;
917
  }
918
 
919
+ return WP_CACHE_KEY_SALT . "{$prefix}:{$group}:{$key}";
920
  }
921
 
922
  /**
948
  }
949
 
950
  if ( is_numeric( $response ) ) {
951
+ return $response;
952
  }
953
 
954
  if ( is_object( $response ) && method_exists( $response, 'getPayload' ) ) {
955
+ return $response->getPayload() === 'OK';
956
  }
957
 
958
  return false;
997
  return false;
998
  }
999
 
1000
+ $this->blog_prefix = $_blog_id;
1001
+
1002
  return true;
1003
  }
1004
 
1035
  */
1036
  protected function validate_expiration( $expiration ) {
1037
  $expiration = ( is_array( $expiration ) || is_object( $expiration ) ? 0 : abs( intval( $expiration ) ) );
1038
+
1039
  if ( $expiration === 0 && defined( 'WP_REDIS_MAXTTL' ) ) {
1040
  $expiration = intval( WP_REDIS_MAXTTL );
1041
  }
1042
+
1043
  return $expiration;
1044
  }
1045
 
1050
  * @return mixed Unserialized data can be any type.
1051
  */
1052
  protected function maybe_unserialize( $original ) {
1053
+ // don't attempt to unserialize data that wasn't serialized going in
1054
+ if ( $this->is_serialized( $original ) ) {
1055
  return @unserialize( $original );
1056
+ }
1057
+
1058
  return $original;
1059
  }
1060
 
1064
  * @return mixed A scalar data
1065
  */
1066
  protected function maybe_serialize( $data ) {
1067
+ if ( is_array( $data ) || is_object( $data ) ) {
1068
  return serialize( $data );
1069
+ }
1070
 
1071
+ if ( $this->is_serialized( $data, false ) ) {
1072
  return serialize( $data );
1073
+ }
1074
 
1075
  return $data;
1076
  }
1086
  * @return bool False if not serialized and true if it was.
1087
  */
1088
  protected function is_serialized( $data, $strict = true ) {
 
1089
  // if it isn't a string, it isn't serialized.
1090
  if ( ! is_string( $data ) ) {
1091
  return false;
1092
  }
1093
+
1094
  $data = trim( $data );
1095
+
1096
+ if ( 'N;' == $data ) {
1097
  return true;
1098
  }
1099
+
1100
  if ( strlen( $data ) < 4 ) {
1101
  return false;
1102
  }
1103
+
1104
  if ( ':' !== $data[1] ) {
1105
  return false;
1106
  }
1107
+
1108
  if ( $strict ) {
1109
  $lastc = substr( $data, -1 );
1110
+
1111
  if ( ';' !== $lastc && '}' !== $lastc ) {
1112
  return false;
1113
  }
1114
  } else {
1115
  $semicolon = strpos( $data, ';' );
1116
+ $brace = strpos( $data, '}' );
1117
+
1118
  // Either ; or } must exist.
1119
+ if ( false === $semicolon && false === $brace ) {
1120
  return false;
1121
+ }
1122
+
1123
  // But neither must be in the first X characters.
1124
+ if ( false !== $semicolon && $semicolon < 3 ) {
1125
  return false;
1126
+ }
1127
+
1128
+ if ( false !== $brace && $brace < 4 ) {
1129
  return false;
1130
+ }
1131
  }
1132
  $token = $data[0];
1133
+
1134
  switch ( $token ) {
1135
+ case 's':
1136
  if ( $strict ) {
1137
  if ( '"' !== substr( $data, -2, 1 ) ) {
1138
  return false;
1141
  return false;
1142
  }
1143
  // or else fall through
1144
+ case 'a':
1145
+ case 'O':
1146
  return (bool) preg_match( "/^{$token}:[0-9]+:/s", $data );
1147
+ case 'b':
1148
+ case 'i':
1149
+ case 'd':
1150
  $end = $strict ? '$' : '';
1151
+
1152
  return (bool) preg_match( "/^{$token}:[0-9.E-]+;$end/", $data );
1153
  }
1154
+
1155
  return false;
1156
  }
1157
 
1158
  }
1159
+
1160
+ endif;
languages/redis-cache.pot CHANGED
@@ -2,9 +2,9 @@
2
  # This file is distributed under the same license as the Redis Object Cache package.
3
  msgid ""
4
  msgstr ""
5
- "Project-Id-Version: Redis Object Cache 1.3.4\n"
6
  "Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/redis-cache\n"
7
- "POT-Creation-Date: 2016-09-21 22:54:28+00:00\n"
8
  "MIME-Version: 1.0\n"
9
  "Content-Type: text/plain; charset=UTF-8\n"
10
  "Content-Transfer-Encoding: 8bit\n"
@@ -12,7 +12,7 @@ msgstr ""
12
  "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
13
  "Language-Team: LANGUAGE <LL@li.org>\n"
14
 
15
- #. #-#-#-#-# plugin.pot (Redis Object Cache 1.3.4) #-#-#-#-#
16
  #. Plugin Name of the plugin/theme
17
  #: includes/admin-page.php:6 redis-cache.php:58
18
  msgid "Redis Object Cache"
@@ -54,18 +54,78 @@ msgstr ""
54
  msgid "Servers"
55
  msgstr ""
56
 
57
- #: includes/servers-list.php:8
58
- msgid "Server"
 
 
 
 
 
 
 
 
59
  msgstr ""
60
 
61
- #: includes/servers-list.php:77
62
  msgid "Yes"
63
  msgstr ""
64
 
65
- #: includes/servers-list.php:77
66
  msgid "No"
67
  msgstr ""
68
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
69
  #: includes/wp-cli-commands.php:23 redis-cache.php:149
70
  msgid "Disabled"
71
  msgstr ""
@@ -116,10 +176,6 @@ msgstr ""
116
  msgid "Object Cache drop-in could not be updated."
117
  msgstr ""
118
 
119
- #: redis-cache.php:59
120
- msgid "Redis"
121
- msgstr ""
122
-
123
  #: redis-cache.php:162
124
  msgid "Unknown"
125
  msgstr ""
2
  # This file is distributed under the same license as the Redis Object Cache package.
3
  msgid ""
4
  msgstr ""
5
+ "Project-Id-Version: Redis Object Cache 1.3.5\n"
6
  "Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/redis-cache\n"
7
+ "POT-Creation-Date: 2016-11-07 02:28:06+00:00\n"
8
  "MIME-Version: 1.0\n"
9
  "Content-Type: text/plain; charset=UTF-8\n"
10
  "Content-Transfer-Encoding: 8bit\n"
12
  "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
13
  "Language-Team: LANGUAGE <LL@li.org>\n"
14
 
15
+ #. #-#-#-#-# plugin.pot (Redis Object Cache 1.3.5) #-#-#-#-#
16
  #. Plugin Name of the plugin/theme
17
  #: includes/admin-page.php:6 redis-cache.php:58
18
  msgid "Redis Object Cache"
54
  msgid "Servers"
55
  msgstr ""
56
 
57
+ #: includes/admin-page.php:60
58
+ msgid "Diagnostics"
59
+ msgstr ""
60
+
61
+ #: includes/admin-page.php:66
62
+ msgid "Show Diagnostics"
63
+ msgstr ""
64
+
65
+ #: includes/diagnostics.php:13
66
+ msgid "Multisite"
67
  msgstr ""
68
 
69
+ #: includes/diagnostics.php:13 includes/servers-list.php:77
70
  msgid "Yes"
71
  msgstr ""
72
 
73
+ #: includes/diagnostics.php:13 includes/servers-list.php:77
74
  msgid "No"
75
  msgstr ""
76
 
77
+ #: includes/diagnostics.php:15 redis-cache.php:59
78
+ msgid "Redis"
79
+ msgstr ""
80
+
81
+ #: includes/diagnostics.php:15 includes/diagnostics.php:16
82
+ msgid "Not Found"
83
+ msgstr ""
84
+
85
+ #: includes/diagnostics.php:16
86
+ msgid "Predis"
87
+ msgstr ""
88
+
89
+ #: includes/diagnostics.php:18
90
+ msgid "Status"
91
+ msgstr ""
92
+
93
+ #: includes/diagnostics.php:19
94
+ msgid "Client"
95
+ msgstr ""
96
+
97
+ #: includes/diagnostics.php:48 includes/diagnostics.php:54
98
+ msgid "Drop-in"
99
+ msgstr ""
100
+
101
+ #: includes/diagnostics.php:48
102
+ msgid "Valid"
103
+ msgstr ""
104
+
105
+ #: includes/diagnostics.php:49
106
+ msgid "Global Prefix"
107
+ msgstr ""
108
+
109
+ #: includes/diagnostics.php:50
110
+ msgid "Blog Prefix"
111
+ msgstr ""
112
+
113
+ #: includes/diagnostics.php:51
114
+ msgid "Global Groups"
115
+ msgstr ""
116
+
117
+ #: includes/diagnostics.php:52
118
+ msgid "Ignored Groups"
119
+ msgstr ""
120
+
121
+ #: includes/diagnostics.php:54
122
+ msgid "Invalid"
123
+ msgstr ""
124
+
125
+ #: includes/servers-list.php:8
126
+ msgid "Server"
127
+ msgstr ""
128
+
129
  #: includes/wp-cli-commands.php:23 redis-cache.php:149
130
  msgid "Disabled"
131
  msgstr ""
176
  msgid "Object Cache drop-in could not be updated."
177
  msgstr ""
178
 
 
 
 
 
179
  #: redis-cache.php:162
180
  msgid "Unknown"
181
  msgstr ""
readme.txt CHANGED
@@ -3,8 +3,8 @@ Contributors: tillkruess
3
  Donate link: https://www.paypal.me/tillkruss
4
  Tags: redis, predis, hhvm, pecl, caching, cache, object cache, wp object cache, server, performance, optimize, speed, load, replication, clustering
5
  Requires at least: 3.3
6
- Tested up to: 4.6
7
- Stable tag: 1.3.4
8
  License: GPLv3
9
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
10
 
@@ -24,45 +24,45 @@ Forked from Eric Mann's and Erick Hitter's [Redis Object Cache](https://github.c
24
 
25
  For detailed installation instructions, please read the [standard installation procedure for WordPress plugins](http://codex.wordpress.org/Managing_Plugins#Installing_Plugins).
26
 
27
- 1. Make sure [Redis in installed and running](http://redis.io/topics/quickstart).
28
  2. Install and activate plugin.
29
  3. Enable the object cache under _Settings -> Redis_.
30
  4. If necessary, adjust [connection parameters](http://wordpress.org/extend/plugins/redis-cache/other_notes/).
31
 
32
- If you server doesn't support the [WordPress Filesystem API](https://codex.wordpress.org/Filesystem_API), you have to manually copy the `object-cache.php` file from the `/plugins/redis-cache/includes/` directory to the `/wp-content/` directory.
33
 
34
 
35
  == Connection Parameters ==
36
 
37
  By default the object cache drop-in will connect to Redis over TCP at `127.0.0.1:6379` and select database `0`.
38
 
39
- To adjust the connection parameters, define any of following constants in your `wp-config.php` file.
40
 
41
- * `WP_REDIS_CLIENT` [default: not set]
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.
52
 
53
- * `WP_REDIS_PORT` [default: `6379`]
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.
64
 
65
- * `WP_REDIS_PASSWORD` [default: not set]
66
 
67
  Accepts a value used to authenticate with a Redis server protected by password with the `AUTH` command.
68
 
@@ -71,11 +71,11 @@ To adjust the connection parameters, define any of following constants in your `
71
 
72
  To adjust the configuration, define any of the following constants in your `wp-config.php` file.
73
 
74
- * `WP_CACHE_KEY_SALT` [default: not set]
75
 
76
  Set the prefix for all cache keys. Useful in setups where multiple installs share a common `wp-config.php` or `$table_prefix`, to guarantee uniqueness of cache keys.
77
 
78
- * `WP_REDIS_MAXTTL` [default: not set]
79
 
80
  Set maximum time-to-live (in seconds) for cache keys with an expiration time of `0`.
81
 
@@ -87,6 +87,10 @@ To adjust the configuration, define any of the following constants in your `wp-c
87
 
88
  Set the cache groups that should not be cached in Redis.
89
 
 
 
 
 
90
 
91
  == Replication & Clustering ==
92
 
@@ -146,6 +150,22 @@ The following commands are supported:
146
 
147
  == Changelog ==
148
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
149
  = 1.3.4 =
150
 
151
  * Added WP-CLI support
@@ -243,6 +263,14 @@ The following commands are supported:
243
 
244
  == Upgrade Notice ==
245
 
 
 
 
 
 
 
 
 
246
  = 1.3.3 =
247
 
248
  This update contains several improvements.
3
  Donate link: https://www.paypal.me/tillkruss
4
  Tags: redis, predis, hhvm, pecl, caching, cache, object cache, wp object cache, server, performance, optimize, speed, load, replication, clustering
5
  Requires at least: 3.3
6
+ Tested up to: 4.9
7
+ Stable tag: 1.3.5
8
  License: GPLv3
9
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
10
 
24
 
25
  For detailed installation instructions, please read the [standard installation procedure for WordPress plugins](http://codex.wordpress.org/Managing_Plugins#Installing_Plugins).
26
 
27
+ 1. Make sure [Redis is installed and running](http://redis.io/topics/quickstart).
28
  2. Install and activate plugin.
29
  3. Enable the object cache under _Settings -> Redis_.
30
  4. If necessary, adjust [connection parameters](http://wordpress.org/extend/plugins/redis-cache/other_notes/).
31
 
32
+ If your server doesn't support the [WordPress Filesystem API](https://codex.wordpress.org/Filesystem_API), you have to manually copy the `object-cache.php` file from the `/plugins/redis-cache/includes/` directory to the `/wp-content/` directory.
33
 
34
 
35
  == Connection Parameters ==
36
 
37
  By default the object cache drop-in will connect to Redis over TCP at `127.0.0.1:6379` and select database `0`.
38
 
39
+ To adjust the connection parameters, define any of the following constants in your `wp-config.php` file.
40
 
41
+ * `WP_REDIS_CLIENT` (default: _not set_)
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.
52
 
53
+ * `WP_REDIS_PORT` (default: `6379`)
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.
64
 
65
+ * `WP_REDIS_PASSWORD` (default: _not set_)
66
 
67
  Accepts a value used to authenticate with a Redis server protected by password with the `AUTH` command.
68
 
71
 
72
  To adjust the configuration, define any of the following constants in your `wp-config.php` file.
73
 
74
+ * `WP_CACHE_KEY_SALT` (default: _not set_)
75
 
76
  Set the prefix for all cache keys. Useful in setups where multiple installs share a common `wp-config.php` or `$table_prefix`, to guarantee uniqueness of cache keys.
77
 
78
+ * `WP_REDIS_MAXTTL` (default: _not set_)
79
 
80
  Set maximum time-to-live (in seconds) for cache keys with an expiration time of `0`.
81
 
87
 
88
  Set the cache groups that should not be cached in Redis.
89
 
90
+ * `WP_REDIS_DISABLED` (default: _not set_)
91
+
92
+ Set to `true` to disable the object cache at runtime.
93
+
94
 
95
  == Replication & Clustering ==
96
 
150
 
151
  == Changelog ==
152
 
153
+ = 1.3.5 =
154
+
155
+ * Added basic diagnostics to admin interface
156
+ * Added `WP_REDIS_DISABLED` constant to disable cache at runtime
157
+ * Prevent "Invalid plugin header" error
158
+ * Return integer from `increment()` and `decrement()` methods
159
+ * Prevent object cache from being instantiated more than once
160
+ * Always separate cache key `prefix` and `group` by semicolon
161
+ * Improved performance of `build_key()`
162
+ * Only apply `redis_object_cache_get` filter if callbacks have been registered
163
+ * Fixed `add_or_replace()` to only set cache key if it doesn't exist
164
+ * Added `redis_object_cache_flush` action
165
+ * Added `redis_object_cache_enable` action
166
+ * Added `redis_object_cache_disable` action
167
+ * Added `redis_object_cache_update_dropin` action
168
+
169
  = 1.3.4 =
170
 
171
  * Added WP-CLI support
263
 
264
  == Upgrade Notice ==
265
 
266
+ = 1.3.5 =
267
+
268
+ This update contains various changes, including performance improvements and better Batcache compatibility.
269
+
270
+ = 1.3.4 =
271
+
272
+ This update contains several improvements, including WP CLI and WordPress 4.6 support.
273
+
274
  = 1.3.3 =
275
 
276
  This update contains several improvements.
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.4
7
  Text Domain: redis-cache
8
  Domain Path: /languages
9
  Author: Till Krüss
@@ -308,16 +308,19 @@ class RedisObjectCache {
308
 
309
  case 'enable-cache':
310
  $result = $wp_filesystem->copy( plugin_dir_path( __FILE__ ) . '/includes/object-cache.php', WP_CONTENT_DIR . '/object-cache.php', true );
 
311
  $message = $result ? 'cache-enabled' : 'enable-cache-failed';
312
  break;
313
 
314
  case 'disable-cache':
315
  $result = $wp_filesystem->delete( WP_CONTENT_DIR . '/object-cache.php' );
 
316
  $message = $result ? 'cache-disabled' : 'disable-cache-failed';
317
  break;
318
 
319
  case 'update-dropin':
320
  $result = $wp_filesystem->copy( plugin_dir_path( __FILE__ ) . '/includes/object-cache.php', WP_CONTENT_DIR . '/object-cache.php', true );
 
321
  $message = $result ? 'dropin-updated' : 'update-dropin-failed';
322
  break;
323
 
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.5
7
  Text Domain: redis-cache
8
  Domain Path: /languages
9
  Author: Till Krüss
308
 
309
  case 'enable-cache':
310
  $result = $wp_filesystem->copy( plugin_dir_path( __FILE__ ) . '/includes/object-cache.php', WP_CONTENT_DIR . '/object-cache.php', true );
311
+ do_action( 'redis_object_cache_enable', $result );
312
  $message = $result ? 'cache-enabled' : 'enable-cache-failed';
313
  break;
314
 
315
  case 'disable-cache':
316
  $result = $wp_filesystem->delete( WP_CONTENT_DIR . '/object-cache.php' );
317
+ do_action( 'redis_object_cache_disable', $result );
318
  $message = $result ? 'cache-disabled' : 'disable-cache-failed';
319
  break;
320
 
321
  case 'update-dropin':
322
  $result = $wp_filesystem->copy( plugin_dir_path( __FILE__ ) . '/includes/object-cache.php', WP_CONTENT_DIR . '/object-cache.php', true );
323
+ do_action( 'redis_object_cache_update_dropin', $result );
324
  $message = $result ? 'dropin-updated' : 'update-dropin-failed';
325
  break;
326