Version Description
- Added WP-CLI support
- Show host and port unless scheme is unix
- Updated default global and ignored groups
- Do a cache flush when activating, deactivating and uninstalling
Download this release
Release Info
Developer | tillkruess |
Plugin | Redis Object Cache |
Version | 1.3.4 |
Comparing to | |
See all releases |
Code changes from version 1.3.3 to 1.3.4
- includes/object-cache.php +22 -4
- includes/servers-list.php +2 -3
- includes/wp-cli-commands.php +149 -0
- languages/redis-cache.pot +59 -41
- readme.txt +40 -8
- redis-cache.php +25 -11
- uninstall.php +2 -0
includes/object-cache.php
CHANGED
@@ -2,8 +2,8 @@
|
|
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
|
6 |
-
Version: 1.3.
|
7 |
Author: Till Krüss
|
8 |
Author URI: https://till.im/
|
9 |
License: GPLv3
|
@@ -280,14 +280,32 @@ class WP_Object_Cache {
|
|
280 |
*
|
281 |
* @var array
|
282 |
*/
|
283 |
-
public $global_groups = array(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
284 |
|
285 |
/**
|
286 |
* List of groups not saved to Redis.
|
287 |
*
|
288 |
* @var array
|
289 |
*/
|
290 |
-
public $ignored_groups = array( '
|
291 |
|
292 |
/**
|
293 |
* Prefix used for global groups.
|
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
|
280 |
*
|
281 |
* @var array
|
282 |
*/
|
283 |
+
public $global_groups = array(
|
284 |
+
'blog-details',
|
285 |
+
'blog-id-cache',
|
286 |
+
'blog-lookup',
|
287 |
+
'global-posts',
|
288 |
+
'networks',
|
289 |
+
'rss',
|
290 |
+
'sites',
|
291 |
+
'site-details',
|
292 |
+
'site-lookup',
|
293 |
+
'site-options',
|
294 |
+
'site-transient',
|
295 |
+
'users',
|
296 |
+
'useremail',
|
297 |
+
'userlogins',
|
298 |
+
'usermeta',
|
299 |
+
'user_meta',
|
300 |
+
'userslugs',
|
301 |
+
);
|
302 |
|
303 |
/**
|
304 |
* List of groups not saved to Redis.
|
305 |
*
|
306 |
* @var array
|
307 |
*/
|
308 |
+
public $ignored_groups = array( 'counts', 'plugins' );
|
309 |
|
310 |
/**
|
311 |
* Prefix used for global groups.
|
includes/servers-list.php
CHANGED
@@ -32,11 +32,10 @@ class Servers_List extends WP_List_Table {
|
|
32 |
|
33 |
array_walk_recursive( $this->items, function ( $value, $key ) use ( &$hidden ) {
|
34 |
if ( $key == 'scheme' ) {
|
35 |
-
if ( strcasecmp( 'tcp', $value ) === 0 ) {
|
36 |
-
$hidden = array_diff( $hidden, array( 'host', 'port' ) );
|
37 |
-
}
|
38 |
if ( strcasecmp( 'unix', $value ) === 0 ) {
|
39 |
$hidden = array_diff( $hidden, array( 'path' ) );
|
|
|
|
|
40 |
}
|
41 |
}
|
42 |
} );
|
32 |
|
33 |
array_walk_recursive( $this->items, function ( $value, $key ) use ( &$hidden ) {
|
34 |
if ( $key == 'scheme' ) {
|
|
|
|
|
|
|
35 |
if ( strcasecmp( 'unix', $value ) === 0 ) {
|
36 |
$hidden = array_diff( $hidden, array( 'path' ) );
|
37 |
+
} else {
|
38 |
+
$hidden = array_diff( $hidden, array( 'host', 'port' ) );
|
39 |
}
|
40 |
}
|
41 |
} );
|
includes/wp-cli-commands.php
ADDED
@@ -0,0 +1,149 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
WP_CLI::add_command( 'redis', 'RedisObjectCache_CLI_Commands' );
|
4 |
+
|
5 |
+
class RedisObjectCache_CLI_Commands extends WP_CLI_Command {
|
6 |
+
|
7 |
+
/**
|
8 |
+
* Show the Redis object cache status and (when possible) client.
|
9 |
+
*
|
10 |
+
* ## EXAMPLES
|
11 |
+
*
|
12 |
+
* wp redis status
|
13 |
+
*
|
14 |
+
*/
|
15 |
+
public function status() {
|
16 |
+
|
17 |
+
$plugin = $GLOBALS[ 'redisObjectCache' ];
|
18 |
+
$status = $plugin->get_status();
|
19 |
+
$client = $plugin->get_redis_client_name();
|
20 |
+
|
21 |
+
|
22 |
+
switch ($status) {
|
23 |
+
case __( 'Disabled', 'redis-cache' ):
|
24 |
+
$status = WP_CLI::colorize( "%y{$status}%n" );
|
25 |
+
break;
|
26 |
+
case __( 'Connected', 'redis-cache' ):
|
27 |
+
$status = WP_CLI::colorize( "%g{$status}%n" );
|
28 |
+
break;
|
29 |
+
case __( 'Not Connected', 'redis-cache' ):
|
30 |
+
$status = WP_CLI::colorize( "%r{$status}%n" );
|
31 |
+
break;
|
32 |
+
}
|
33 |
+
|
34 |
+
WP_CLI::line( 'Status: ' . $status );
|
35 |
+
|
36 |
+
if ( ! is_null( $client ) ) {
|
37 |
+
WP_CLI::line( 'Client: ' . $client );
|
38 |
+
}
|
39 |
+
|
40 |
+
}
|
41 |
+
|
42 |
+
/**
|
43 |
+
* Enables the Redis object cache.
|
44 |
+
*
|
45 |
+
* Default behavior is to create the object cache drop-in,
|
46 |
+
* unless an unknown object cache drop-in is present.
|
47 |
+
*
|
48 |
+
* ## EXAMPLES
|
49 |
+
*
|
50 |
+
* wp redis enable
|
51 |
+
*
|
52 |
+
*/
|
53 |
+
public function enable() {
|
54 |
+
|
55 |
+
global $wp_filesystem;
|
56 |
+
|
57 |
+
$plugin = $GLOBALS[ 'redisObjectCache' ];
|
58 |
+
|
59 |
+
if ( $plugin->object_cache_dropin_exists() ) {
|
60 |
+
|
61 |
+
if ($plugin->validate_object_cache_dropin()) {
|
62 |
+
WP_CLI::line( __( 'Redis object cache already enabled.', 'redis-cache' ) );
|
63 |
+
} else {
|
64 |
+
WP_CLI::error( __('An unknown object cache drop-in was found. To use Redis run: wp redis update-dropin.', 'redis-cache') );
|
65 |
+
}
|
66 |
+
|
67 |
+
} else {
|
68 |
+
|
69 |
+
WP_Filesystem();
|
70 |
+
|
71 |
+
if ($wp_filesystem->copy( WP_PLUGIN_DIR . '/redis-cache/includes/object-cache.php', WP_CONTENT_DIR . '/object-cache.php', true )) {
|
72 |
+
WP_CLI::success( __( 'Object Cache enabled.', 'redis-cache' ) );
|
73 |
+
} else {
|
74 |
+
WP_CLI::error( __( 'Object Cache could not be enabled.', 'redis-cache' ) );
|
75 |
+
}
|
76 |
+
|
77 |
+
}
|
78 |
+
|
79 |
+
}
|
80 |
+
|
81 |
+
/**
|
82 |
+
* Disables the Redis object cache.
|
83 |
+
*
|
84 |
+
* Default behavior is to delete the object cache drop-in,
|
85 |
+
* unless an unknown object cache drop-in is present.
|
86 |
+
*
|
87 |
+
* ## EXAMPLES
|
88 |
+
*
|
89 |
+
* wp redis disable
|
90 |
+
*
|
91 |
+
*/
|
92 |
+
public function disable() {
|
93 |
+
|
94 |
+
global $wp_filesystem;
|
95 |
+
|
96 |
+
$plugin = $GLOBALS[ 'redisObjectCache' ];
|
97 |
+
|
98 |
+
if ( ! $plugin->object_cache_dropin_exists() ) {
|
99 |
+
|
100 |
+
WP_CLI::error( __( 'No object cache drop-in found.', 'redis-cache' ) );
|
101 |
+
|
102 |
+
} else {
|
103 |
+
|
104 |
+
if ( ! $plugin->validate_object_cache_dropin() ) {
|
105 |
+
|
106 |
+
WP_CLI::error( __('An unknown object cache drop-in was found. To use Redis run: wp redis update-dropin.', 'redis-cache') );
|
107 |
+
|
108 |
+
} else {
|
109 |
+
|
110 |
+
WP_Filesystem();
|
111 |
+
|
112 |
+
if ($wp_filesystem->delete( WP_CONTENT_DIR . '/object-cache.php' )) {
|
113 |
+
WP_CLI::success( __( 'Object Cache disabled.', 'redis-cache' ) );
|
114 |
+
} else {
|
115 |
+
WP_CLI::error( __( 'Object Cache could not be disabled.', 'redis-cache' ) );
|
116 |
+
}
|
117 |
+
|
118 |
+
}
|
119 |
+
|
120 |
+
}
|
121 |
+
|
122 |
+
}
|
123 |
+
|
124 |
+
/**
|
125 |
+
* Updates the Redis object cache drop-in.
|
126 |
+
*
|
127 |
+
* Default behavior is to overwrite any existing object cache drop-in.
|
128 |
+
*
|
129 |
+
* ## EXAMPLES
|
130 |
+
*
|
131 |
+
* wp redis update-dropin
|
132 |
+
*
|
133 |
+
* @subcommand update-dropin
|
134 |
+
*/
|
135 |
+
public function update_dropin() {
|
136 |
+
|
137 |
+
global $wp_filesystem;
|
138 |
+
|
139 |
+
WP_Filesystem();
|
140 |
+
|
141 |
+
if ($wp_filesystem->copy( WP_PLUGIN_DIR . '/redis-cache/includes/object-cache.php', WP_CONTENT_DIR . '/object-cache.php', true )) {
|
142 |
+
WP_CLI::success( __( 'Updated object cache drop-in and enabled Redis object cache.', 'redis-cache' ) );
|
143 |
+
} else {
|
144 |
+
WP_CLI::error( __( 'Object Cache drop-in could not be updated.', 'redis-cache' ) );
|
145 |
+
}
|
146 |
+
|
147 |
+
}
|
148 |
+
|
149 |
+
}
|
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.
|
6 |
"Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/redis-cache\n"
|
7 |
-
"POT-Creation-Date: 2016-
|
8 |
"MIME-Version: 1.0\n"
|
9 |
"Content-Type: text/plain; charset=UTF-8\n"
|
10 |
"Content-Transfer-Encoding: 8bit\n"
|
@@ -12,9 +12,9 @@ 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.
|
16 |
#. Plugin Name of the plugin/theme
|
17 |
-
#: includes/admin-page.php:6 redis-cache.php:
|
18 |
msgid "Redis Object Cache"
|
19 |
msgstr ""
|
20 |
|
@@ -58,80 +58,98 @@ msgstr ""
|
|
58 |
msgid "Server"
|
59 |
msgstr ""
|
60 |
|
61 |
-
#: includes/servers-list.php:
|
62 |
msgid "Yes"
|
63 |
msgstr ""
|
64 |
|
65 |
-
#: includes/servers-list.php:
|
66 |
msgid "No"
|
67 |
msgstr ""
|
68 |
|
69 |
-
#: redis-cache.php:
|
70 |
-
msgid "Redis"
|
71 |
-
msgstr ""
|
72 |
-
|
73 |
-
#: redis-cache.php:141
|
74 |
msgid "Disabled"
|
75 |
msgstr ""
|
76 |
|
77 |
-
#: redis-cache.php:
|
78 |
msgid "Connected"
|
79 |
msgstr ""
|
80 |
|
81 |
-
#: redis-cache.php:
|
82 |
msgid "Not Connected"
|
83 |
msgstr ""
|
84 |
|
85 |
-
#:
|
86 |
-
msgid "
|
87 |
-
msgstr ""
|
88 |
-
|
89 |
-
#: redis-cache.php:211
|
90 |
-
msgid ""
|
91 |
-
"The Redis object cache drop-in is outdated. Please <a href=\"%s\">update it "
|
92 |
-
"now</a>."
|
93 |
msgstr ""
|
94 |
|
95 |
-
#:
|
96 |
msgid ""
|
97 |
-
"
|
98 |
-
"
|
99 |
msgstr ""
|
100 |
|
101 |
-
#: redis-cache.php:
|
102 |
-
msgid "This plugin requires PHP 5.4 or greater."
|
103 |
-
msgstr ""
|
104 |
-
|
105 |
-
#: redis-cache.php:241
|
106 |
msgid "Object Cache enabled."
|
107 |
msgstr ""
|
108 |
|
109 |
-
#: redis-cache.php:
|
110 |
msgid "Object Cache could not be enabled."
|
111 |
msgstr ""
|
112 |
|
113 |
-
#:
|
|
|
|
|
|
|
|
|
114 |
msgid "Object Cache disabled."
|
115 |
msgstr ""
|
116 |
|
117 |
-
#: redis-cache.php:
|
118 |
msgid "Object Cache could not be disabled."
|
119 |
msgstr ""
|
120 |
|
121 |
-
#: redis-cache.php:
|
122 |
-
msgid "
|
123 |
msgstr ""
|
124 |
|
125 |
-
#:
|
126 |
-
msgid "Object Cache could not be
|
|
|
|
|
|
|
|
|
127 |
msgstr ""
|
128 |
|
129 |
-
#: redis-cache.php:
|
130 |
-
msgid "
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
131 |
msgstr ""
|
132 |
|
133 |
-
#: redis-cache.php:
|
134 |
-
msgid "
|
135 |
msgstr ""
|
136 |
|
137 |
#. Plugin URI of the plugin/theme
|
@@ -141,7 +159,7 @@ msgstr ""
|
|
141 |
#. Description of the plugin/theme
|
142 |
msgid ""
|
143 |
"A persistent object cache backend powered by Redis. Supports Predis, "
|
144 |
-
"PhpRedis, HHVM, replication and
|
145 |
msgstr ""
|
146 |
|
147 |
#. Author of the plugin/theme
|
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 |
"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"
|
19 |
msgstr ""
|
20 |
|
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 ""
|
72 |
|
73 |
+
#: includes/wp-cli-commands.php:26 redis-cache.php:154
|
74 |
msgid "Connected"
|
75 |
msgstr ""
|
76 |
|
77 |
+
#: includes/wp-cli-commands.php:29 redis-cache.php:158
|
78 |
msgid "Not Connected"
|
79 |
msgstr ""
|
80 |
|
81 |
+
#: includes/wp-cli-commands.php:62
|
82 |
+
msgid "Redis object cache already enabled."
|
|
|
|
|
|
|
|
|
|
|
|
|
83 |
msgstr ""
|
84 |
|
85 |
+
#: includes/wp-cli-commands.php:64 includes/wp-cli-commands.php:106
|
86 |
msgid ""
|
87 |
+
"An unknown object cache drop-in was found. To use Redis run: wp redis update-"
|
88 |
+
"dropin."
|
89 |
msgstr ""
|
90 |
|
91 |
+
#: includes/wp-cli-commands.php:72 redis-cache.php:249
|
|
|
|
|
|
|
|
|
92 |
msgid "Object Cache enabled."
|
93 |
msgstr ""
|
94 |
|
95 |
+
#: includes/wp-cli-commands.php:74 redis-cache.php:252
|
96 |
msgid "Object Cache could not be enabled."
|
97 |
msgstr ""
|
98 |
|
99 |
+
#: includes/wp-cli-commands.php:100
|
100 |
+
msgid "No object cache drop-in found."
|
101 |
+
msgstr ""
|
102 |
+
|
103 |
+
#: includes/wp-cli-commands.php:113 redis-cache.php:255
|
104 |
msgid "Object Cache disabled."
|
105 |
msgstr ""
|
106 |
|
107 |
+
#: includes/wp-cli-commands.php:115 redis-cache.php:258
|
108 |
msgid "Object Cache could not be disabled."
|
109 |
msgstr ""
|
110 |
|
111 |
+
#: includes/wp-cli-commands.php:142 redis-cache.php:267
|
112 |
+
msgid "Updated object cache drop-in and enabled Redis object cache."
|
113 |
msgstr ""
|
114 |
|
115 |
+
#: includes/wp-cli-commands.php:144
|
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 ""
|
126 |
+
|
127 |
+
#: redis-cache.php:219
|
128 |
+
msgid ""
|
129 |
+
"The Redis object cache drop-in is outdated. Please <a href=\"%s\">update it "
|
130 |
+
"now</a>."
|
131 |
+
msgstr ""
|
132 |
+
|
133 |
+
#: redis-cache.php:224
|
134 |
+
msgid ""
|
135 |
+
"An unknown object cache drop-in was found. To use Redis, <a href=\"%s"
|
136 |
+
"\">please replace it now</a>."
|
137 |
+
msgstr ""
|
138 |
+
|
139 |
+
#: redis-cache.php:240
|
140 |
+
msgid "This plugin requires PHP 5.4 or greater."
|
141 |
+
msgstr ""
|
142 |
+
|
143 |
+
#: redis-cache.php:261
|
144 |
+
msgid "Object Cache flushed."
|
145 |
+
msgstr ""
|
146 |
+
|
147 |
+
#: redis-cache.php:264
|
148 |
+
msgid "Object Cache could not be flushed."
|
149 |
msgstr ""
|
150 |
|
151 |
+
#: redis-cache.php:270
|
152 |
+
msgid "Object cache drop-in could not be updated."
|
153 |
msgstr ""
|
154 |
|
155 |
#. Plugin URI of the plugin/theme
|
159 |
#. Description of the plugin/theme
|
160 |
msgid ""
|
161 |
"A persistent object cache backend powered by Redis. Supports Predis, "
|
162 |
+
"PhpRedis, HHVM, replication, clustering and WP-CLI."
|
163 |
msgstr ""
|
164 |
|
165 |
#. Author of the plugin/theme
|
readme.txt
CHANGED
@@ -4,16 +4,16 @@ 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.
|
8 |
License: GPLv3
|
9 |
License URI: http://www.gnu.org/licenses/gpl-3.0.html
|
10 |
|
11 |
-
A persistent object cache backend powered by Redis. Supports Predis, PhpRedis
|
12 |
|
13 |
|
14 |
== Description ==
|
15 |
|
16 |
-
A persistent object cache backend powered by Redis. Supports [Predis](https://github.com/nrk/predis/), [PhpRedis (PECL)](https://github.com/phpredis/phpredis), [HHVM](https://github.com/facebook/hhvm/tree/master/hphp/system/php/redis), replication and
|
17 |
|
18 |
To adjust the connection parameters, prefix cache keys or configure replication/clustering, please see [Other Notes](http://wordpress.org/extend/plugins/redis-cache/other_notes/).
|
19 |
|
@@ -24,7 +24,7 @@ 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.
|
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/).
|
@@ -44,7 +44,7 @@ To adjust the connection parameters, define any of following constants in your `
|
|
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) or `http` (HTTP protocol through Webdis).
|
48 |
|
49 |
* `WP_REDIS_HOST` [default: `127.0.0.1`]
|
50 |
|
@@ -79,11 +79,11 @@ To adjust the configuration, define any of the following constants in your `wp-c
|
|
79 |
|
80 |
Set maximum time-to-live (in seconds) for cache keys with an expiration time of `0`.
|
81 |
|
82 |
-
* `WP_REDIS_GLOBAL_GROUPS` (default: `['
|
83 |
|
84 |
Set the list of network-wide cache groups that should not be prefixed with the blog-id _(Multisite only)_.
|
85 |
|
86 |
-
* `WP_REDIS_IGNORED_GROUPS` (default: `['
|
87 |
|
88 |
Set the cache groups that should not be cached in Redis.
|
89 |
|
@@ -112,6 +112,31 @@ __Clustering via Client-side Sharding Example:__
|
|
112 |
] );
|
113 |
|
114 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
115 |
== Screenshots ==
|
116 |
|
117 |
1. Plugin settings, connected to a single Redis server.
|
@@ -121,6 +146,13 @@ __Clustering via Client-side Sharding Example:__
|
|
121 |
|
122 |
== Changelog ==
|
123 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
124 |
= 1.3.3 =
|
125 |
|
126 |
* Updated Predis to `v1.1.1`
|
@@ -183,7 +215,7 @@ __Clustering via Client-side Sharding Example:__
|
|
183 |
|
184 |
* Added support for HHVM's Redis extension
|
185 |
* Added support for PECL Redis extension
|
186 |
-
* Added `WP_REDIS_CLIENT` constant, to set
|
187 |
* Added `WP_REDIS_MAXTTL` constant, to force expiration of cache keys
|
188 |
* Improved `add_or_replace()`, `get()`, `set()` and `delete()` methods
|
189 |
* Improved admin screen styles
|
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 |
|
11 |
+
A persistent object cache backend powered by Redis. Supports Predis, PhpRedis, HHVM, replication, clustering and WP-CLI.
|
12 |
|
13 |
|
14 |
== Description ==
|
15 |
|
16 |
+
A persistent object cache backend powered by Redis. Supports [Predis](https://github.com/nrk/predis/), [PhpRedis (PECL)](https://github.com/phpredis/phpredis), [HHVM](https://github.com/facebook/hhvm/tree/master/hphp/system/php/redis), replication, clustering and [WP-CLI](http://wp-cli.org/).
|
17 |
|
18 |
To adjust the connection parameters, prefix cache keys or configure replication/clustering, please see [Other Notes](http://wordpress.org/extend/plugins/redis-cache/other_notes/).
|
19 |
|
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/).
|
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 |
|
79 |
|
80 |
Set maximum time-to-live (in seconds) for cache keys with an expiration time of `0`.
|
81 |
|
82 |
+
* `WP_REDIS_GLOBAL_GROUPS` (default: `['blog-details', 'blog-id-cache', 'blog-lookup', 'global-posts', 'networks', 'rss', 'sites', 'site-details', 'site-lookup', 'site-options', 'site-transient', 'users', 'useremail', 'userlogins', 'usermeta', 'user_meta', 'userslugs']`)
|
83 |
|
84 |
Set the list of network-wide cache groups that should not be prefixed with the blog-id _(Multisite only)_.
|
85 |
|
86 |
+
* `WP_REDIS_IGNORED_GROUPS` (default: `['counts', 'plugins']`)
|
87 |
|
88 |
Set the cache groups that should not be cached in Redis.
|
89 |
|
112 |
] );
|
113 |
|
114 |
|
115 |
+
== WP-CLI Commands ==
|
116 |
+
|
117 |
+
To use the WP-CLI commands, make sure the plugin is activated:
|
118 |
+
|
119 |
+
wp plugin activate redis-cache
|
120 |
+
|
121 |
+
The following commands are supported:
|
122 |
+
|
123 |
+
* `wp redis status`
|
124 |
+
|
125 |
+
Show the Redis object cache status and (when possible) client.
|
126 |
+
|
127 |
+
* `wp redis enable`
|
128 |
+
|
129 |
+
Enables the Redis object cache. Default behavior is to create the object cache drop-in, unless an unknown object cache drop-in is present.
|
130 |
+
|
131 |
+
* `wp redis disable`
|
132 |
+
|
133 |
+
Disables the Redis object cache. Default behavior is to delete the object cache drop-in, unless an unknown object cache drop-in is present.
|
134 |
+
|
135 |
+
* `wp redis update-dropin`
|
136 |
+
|
137 |
+
Updates the Redis object cache drop-in. Default behavior is to overwrite any existing object cache drop-in.
|
138 |
+
|
139 |
+
|
140 |
== Screenshots ==
|
141 |
|
142 |
1. Plugin settings, connected to a single Redis server.
|
146 |
|
147 |
== Changelog ==
|
148 |
|
149 |
+
= 1.3.4 =
|
150 |
+
|
151 |
+
* Added WP-CLI support
|
152 |
+
* Show host and port unless scheme is unix
|
153 |
+
* Updated default global and ignored groups
|
154 |
+
* Do a cache flush when activating, deactivating and uninstalling
|
155 |
+
|
156 |
= 1.3.3 =
|
157 |
|
158 |
* Updated Predis to `v1.1.1`
|
215 |
|
216 |
* Added support for HHVM's Redis extension
|
217 |
* Added support for PECL Redis extension
|
218 |
+
* Added `WP_REDIS_CLIENT` constant, to set preferred Redis client
|
219 |
* Added `WP_REDIS_MAXTTL` constant, to force expiration of cache keys
|
220 |
* Improved `add_or_replace()`, `get()`, `set()` and `delete()` methods
|
221 |
* Improved admin screen styles
|
redis-cache.php
CHANGED
@@ -2,8 +2,8 @@
|
|
2 |
/*
|
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 and
|
6 |
-
Version: 1.3.
|
7 |
Text Domain: redis-cache
|
8 |
Domain Path: /languages
|
9 |
Author: Till Krüss
|
@@ -12,7 +12,13 @@ License: GPLv3
|
|
12 |
License URI: http://www.gnu.org/licenses/gpl-3.0.html
|
13 |
*/
|
14 |
|
15 |
-
if ( ! defined( 'ABSPATH' ) )
|
|
|
|
|
|
|
|
|
|
|
|
|
16 |
|
17 |
class RedisObjectCache {
|
18 |
|
@@ -24,10 +30,12 @@ class RedisObjectCache {
|
|
24 |
|
25 |
load_plugin_textdomain( 'redis-cache', false, 'redis-cache/languages' );
|
26 |
|
27 |
-
|
28 |
|
29 |
$this->page = is_multisite() ? 'settings.php?page=redis-cache' : 'options-general.php?page=redis-cache';
|
30 |
|
|
|
|
|
31 |
add_action( is_multisite() ? 'network_admin_menu' : 'admin_menu', array( $this, 'add_admin_menu_page' ) );
|
32 |
add_action( 'admin_notices', array( $this, 'show_admin_notices' ) );
|
33 |
add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_admin_styles' ) );
|
@@ -213,7 +221,7 @@ class RedisObjectCache {
|
|
213 |
|
214 |
} else {
|
215 |
|
216 |
-
$message = sprintf( __( '
|
217 |
|
218 |
}
|
219 |
|
@@ -256,10 +264,10 @@ class RedisObjectCache {
|
|
256 |
$error = __( 'Object Cache could not be flushed.', 'redis-cache' );
|
257 |
break;
|
258 |
case 'dropin-updated':
|
259 |
-
$message = __( '
|
260 |
break;
|
261 |
case 'update-dropin-failed':
|
262 |
-
$error = __( '
|
263 |
break;
|
264 |
|
265 |
}
|
@@ -361,16 +369,22 @@ class RedisObjectCache {
|
|
361 |
|
362 |
}
|
363 |
|
364 |
-
public function on_deactivation() {
|
365 |
|
366 |
global $wp_filesystem;
|
367 |
|
368 |
-
if ( $
|
369 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
370 |
}
|
371 |
|
372 |
}
|
373 |
|
374 |
}
|
375 |
|
376 |
-
new RedisObjectCache;
|
2 |
/*
|
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
|
12 |
License URI: http://www.gnu.org/licenses/gpl-3.0.html
|
13 |
*/
|
14 |
|
15 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
16 |
+
exit;
|
17 |
+
}
|
18 |
+
|
19 |
+
if ( defined( 'WP_CLI' ) && WP_CLI ) {
|
20 |
+
require_once dirname( __FILE__ ) . '/includes/wp-cli-commands.php';
|
21 |
+
}
|
22 |
|
23 |
class RedisObjectCache {
|
24 |
|
30 |
|
31 |
load_plugin_textdomain( 'redis-cache', false, 'redis-cache/languages' );
|
32 |
|
33 |
+
register_activation_hook( __FILE__, 'wp_cache_flush' );
|
34 |
|
35 |
$this->page = is_multisite() ? 'settings.php?page=redis-cache' : 'options-general.php?page=redis-cache';
|
36 |
|
37 |
+
add_action( 'deactivate_plugin', array( $this, 'on_deactivation' ) );
|
38 |
+
|
39 |
add_action( is_multisite() ? 'network_admin_menu' : 'admin_menu', array( $this, 'add_admin_menu_page' ) );
|
40 |
add_action( 'admin_notices', array( $this, 'show_admin_notices' ) );
|
41 |
add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_admin_styles' ) );
|
221 |
|
222 |
} else {
|
223 |
|
224 |
+
$message = sprintf( __( 'An unknown object cache drop-in was found. To use Redis, <a href="%s">please replace it now</a>.', 'redis-cache' ), $url );
|
225 |
|
226 |
}
|
227 |
|
264 |
$error = __( 'Object Cache could not be flushed.', 'redis-cache' );
|
265 |
break;
|
266 |
case 'dropin-updated':
|
267 |
+
$message = __( 'Updated object cache drop-in and enabled Redis object cache.', 'redis-cache' );
|
268 |
break;
|
269 |
case 'update-dropin-failed':
|
270 |
+
$error = __( 'Object cache drop-in could not be updated.', 'redis-cache' );
|
271 |
break;
|
272 |
|
273 |
}
|
369 |
|
370 |
}
|
371 |
|
372 |
+
public function on_deactivation( $plugin ) {
|
373 |
|
374 |
global $wp_filesystem;
|
375 |
|
376 |
+
if ( $plugin === plugin_basename( __FILE__ ) ) {
|
377 |
+
|
378 |
+
wp_cache_flush();
|
379 |
+
|
380 |
+
if ( $this->validate_object_cache_dropin() && $this->initialize_filesystem( '', true ) ) {
|
381 |
+
$wp_filesystem->delete( WP_CONTENT_DIR . '/object-cache.php' );
|
382 |
+
}
|
383 |
+
|
384 |
}
|
385 |
|
386 |
}
|
387 |
|
388 |
}
|
389 |
|
390 |
+
$GLOBALS[ 'redisObjectCache' ] = new RedisObjectCache;
|
uninstall.php
CHANGED
@@ -8,6 +8,8 @@ ob_start();
|
|
8 |
|
9 |
if ( file_exists( WP_CONTENT_DIR . '/object-cache.php' ) && method_exists( $GLOBALS[ 'wp_object_cache' ], 'redis_status' ) ) {
|
10 |
|
|
|
|
|
11 |
if ( WP_Filesystem( request_filesystem_credentials( '' ) ) ) {
|
12 |
$wp_filesystem->delete( WP_CONTENT_DIR . '/object-cache.php' );
|
13 |
}
|
8 |
|
9 |
if ( file_exists( WP_CONTENT_DIR . '/object-cache.php' ) && method_exists( $GLOBALS[ 'wp_object_cache' ], 'redis_status' ) ) {
|
10 |
|
11 |
+
wp_cache_flush();
|
12 |
+
|
13 |
if ( WP_Filesystem( request_filesystem_credentials( '' ) ) ) {
|
14 |
$wp_filesystem->delete( WP_CONTENT_DIR . '/object-cache.php' );
|
15 |
}
|