Redis Object Cache - Version 2.0.16

Version Description

  • Updated Credis to v1.11.4
  • Fixed drop-in notice styling
  • Moved metrics into dedicated class
  • Added redis_cache_validate_dropin filter
  • Use WP_DEBUG_DISPLAY (instead of WP_DEBUG) constant to display debug information
  • Fixed rare error in wp_cache_get_multiple()
  • Removed intval() usage
Download this release

Release Info

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

Code changes from version 2.0.15 to 2.0.16

dependencies/colinmollenhour/credis/.travis.yml CHANGED
@@ -8,27 +8,32 @@ matrix:
8
  - PHPUNIT_VERSION=^5.7
9
  - php: 7.0
10
  env:
11
- - PHPREDIS_VERSION=redis-5.0.0
12
- - PHPUNIT_VERSION=^6.4
13
  - php: 7.1
14
  env:
15
- - PHPREDIS_VERSION=redis-5.0.0
16
- - PHPUNIT_VERSION=^6.4
17
  - php: 7.2
18
  env:
19
- - PHPREDIS_VERSION=redis-5.0.0
20
  - PHPUNIT_VERSION=^7.5
21
  - php: 7.3
22
  env:
23
- - PHPREDIS_VERSION=redis-5.0.0
 
 
 
 
24
  - PHPUNIT_VERSION=^7.5
25
 
26
  install:
27
  - yes '' | pecl install -f $PHPREDIS_VERSION
28
- - wget http://download.redis.io/releases/redis-5.0.5.tar.gz
29
- - tar -xzf redis-5.0.5.tar.gz
30
- - make -s -C redis-5.0.5 -j4
31
- - export PATH=$PATH:$PWD/redis-5.0.5/src/
 
32
  - |
33
  if [ ! -z "$PHPUNIT_VERSION" ]; then
34
  composer require "phpunit/phpunit:${PHPUNIT_VERSION}" --dev --no-update -n
8
  - PHPUNIT_VERSION=^5.7
9
  - php: 7.0
10
  env:
11
+ - PHPREDIS_VERSION=redis-5.3.0
12
+ - PHPUNIT_VERSION=^6.5
13
  - php: 7.1
14
  env:
15
+ - PHPREDIS_VERSION=redis-5.3.0
16
+ - PHPUNIT_VERSION=^7.5
17
  - php: 7.2
18
  env:
19
+ - PHPREDIS_VERSION=redis-5.3.0
20
  - PHPUNIT_VERSION=^7.5
21
  - php: 7.3
22
  env:
23
+ - PHPREDIS_VERSION=redis-5.3.0
24
+ - PHPUNIT_VERSION=^7.5
25
+ - php: 7.4
26
+ env:
27
+ - PHPREDIS_VERSION=redis-5.3.0
28
  - PHPUNIT_VERSION=^7.5
29
 
30
  install:
31
  - yes '' | pecl install -f $PHPREDIS_VERSION
32
+ - wget http://download.redis.io/releases/redis-6.0.8.tar.gz
33
+ - tar -xzf redis-6.0.8.tar.gz
34
+ - export BUILD_TLS=yes
35
+ - make -s -C redis-6.0.8 -j4
36
+ - export PATH=$PWD/redis-6.0.8/src/:$PATH
37
  - |
38
  if [ ! -z "$PHPUNIT_VERSION" ]; then
39
  composer require "phpunit/phpunit:${PHPUNIT_VERSION}" --dev --no-update -n
dependencies/colinmollenhour/credis/Client.php CHANGED
@@ -168,7 +168,7 @@ class CredisException extends Exception
168
  */
169
  class Credis_Client {
170
 
171
- const VERSION = '1.11.2';
172
 
173
  const TYPE_STRING = 'string';
174
  const TYPE_LIST = 'list';
@@ -326,8 +326,8 @@ class Credis_Client {
326
  $this->authPassword = $password;
327
  $this->selectedDb = (int)$db;
328
  $this->convertHost();
329
- if ($this->scheme == 'tls') {
330
- // PHP Redis extension doesn't work with TLS
331
  $this->standalone = true;
332
  }
333
  }
@@ -423,8 +423,8 @@ class Credis_Client {
423
  throw new CredisException('Invalid host format; expected '.$this->scheme.'://host[:port][/persistence_identifier]');
424
  }
425
  $this->host = $matches[1];
426
- $this->port = (int) (isset($matches[3]) ? $matches[3] : 6379);
427
- $this->persistent = isset($matches[5]) ? $matches[5] : '';
428
  } else {
429
  $this->host = $matches[2];
430
  $this->port = NULL;
@@ -1231,6 +1231,10 @@ class Credis_Client {
1231
  }
1232
  }
1233
  break;
 
 
 
 
1234
  default:
1235
  $error = $this->redis->getLastError();
1236
  $this->redis->clearLastError();
168
  */
169
  class Credis_Client {
170
 
171
+ const VERSION = '1.11.4';
172
 
173
  const TYPE_STRING = 'string';
174
  const TYPE_LIST = 'list';
326
  $this->authPassword = $password;
327
  $this->selectedDb = (int)$db;
328
  $this->convertHost();
329
+ // PHP Redis extension support TLS since 5.3.0
330
+ if ($this->scheme == 'tls' && !$this->standalone && version_compare(phpversion('redis'),'5.3.0','<')){
331
  $this->standalone = true;
332
  }
333
  }
423
  throw new CredisException('Invalid host format; expected '.$this->scheme.'://host[:port][/persistence_identifier]');
424
  }
425
  $this->host = $matches[1];
426
+ $this->port = (int) (isset($matches[3]) ? $matches[3] : $this->port);
427
+ $this->persistent = isset($matches[5]) ? $matches[5] : $this->persistent;
428
  } else {
429
  $this->host = $matches[2];
430
  $this->port = NULL;
1231
  }
1232
  }
1233
  break;
1234
+ case 'auth':
1235
+ if (is_bool($response) && $response === true){
1236
+ $this->redis->clearLastError();
1237
+ }
1238
  default:
1239
  $error = $this->redis->getLastError();
1240
  $this->redis->clearLastError();
dependencies/colinmollenhour/credis/Sentinel.php CHANGED
@@ -200,17 +200,18 @@ class Credis_Sentinel
200
  * When $selectRandomSlave is true, only one random slave is passed.
201
  * When $selectRandomSlave is false, all clients are passed and hashing is applied in Credis_Cluster
202
  * When $writeOnly is false, the master server will also be used for read commands.
203
- *
204
  * @param string $name
205
  * @param int $db
206
  * @param int $replicas
207
  * @param bool $selectRandomSlave
208
  * @param bool $writeOnly
 
209
  * @return Credis_Cluster
210
  * @throws CredisException
211
  * @deprecated
212
  */
213
- public function createCluster($name, $db=0, $replicas=128, $selectRandomSlave=true, $writeOnly=false)
214
  {
215
  $clients = array();
216
  $workingClients = array();
@@ -218,21 +219,25 @@ class Credis_Sentinel
218
  if(strstr($master[9],'s_down') || strstr($master[9],'disconnected')) {
219
  throw new CredisException('The master is down');
220
  }
221
- $slaves = $this->slaves($name);
222
- foreach($slaves as $slave){
223
- if(!strstr($slave[9],'s_down') && !strstr($slave[9],'disconnected')) {
224
- $workingClients[] = array('host'=>$slave[3],'port'=>$slave[5],'master'=>false,'db'=>$db,'password'=>$this->_password);
 
 
225
  }
226
- }
227
- if(count($workingClients)>0){
228
- if($selectRandomSlave){
229
- if(!$writeOnly){
230
- $workingClients[] = array('host'=>$master[3],'port'=>$master[5],'master'=>false,'db'=>$db,'password'=>$this->_password);
 
 
 
231
  }
232
- $clients[] = $workingClients[rand(0,count($workingClients)-1)];
233
- } else {
234
- $clients = $workingClients;
235
  }
 
 
236
  }
237
  $clients[] = array('host'=>$master[3],'port'=>$master[5], 'db'=>$db ,'master'=>true,'write_only'=>$writeOnly,'password'=>$this->_password);
238
  return new Credis_Cluster($clients,$replicas,$this->_standAlone);
@@ -245,13 +250,15 @@ class Credis_Sentinel
245
  * @param int $replicas
246
  * @param bool $selectRandomSlave
247
  * @param bool $writeOnly
 
248
  * @return Credis_Cluster
 
249
  * @deprecated
250
  */
251
- public function getCluster($name, $db=0, $replicas=128, $selectRandomSlave=true, $writeOnly=false)
252
  {
253
  if(!isset($this->_cluster[$name])){
254
- $this->_cluster[$name] = $this->createCluster($name, $db, $replicas, $selectRandomSlave, $writeOnly);
255
  }
256
  return $this->_cluster[$name];
257
  }
200
  * When $selectRandomSlave is true, only one random slave is passed.
201
  * When $selectRandomSlave is false, all clients are passed and hashing is applied in Credis_Cluster
202
  * When $writeOnly is false, the master server will also be used for read commands.
203
+ * When $masterOnly is true, only the master server will also be used for both read and write commands. $writeOnly will be ignored and forced to set to false.
204
  * @param string $name
205
  * @param int $db
206
  * @param int $replicas
207
  * @param bool $selectRandomSlave
208
  * @param bool $writeOnly
209
+ * @param bool $masterOnly
210
  * @return Credis_Cluster
211
  * @throws CredisException
212
  * @deprecated
213
  */
214
+ public function createCluster($name, $db=0, $replicas=128, $selectRandomSlave=true, $writeOnly=false, $masterOnly=false)
215
  {
216
  $clients = array();
217
  $workingClients = array();
219
  if(strstr($master[9],'s_down') || strstr($master[9],'disconnected')) {
220
  throw new CredisException('The master is down');
221
  }
222
+ if (!$masterOnly) {
223
+ $slaves = $this->slaves($name);
224
+ foreach($slaves as $slave){
225
+ if(!strstr($slave[9],'s_down') && !strstr($slave[9],'disconnected')) {
226
+ $workingClients[] = array('host'=>$slave[3],'port'=>$slave[5],'master'=>false,'db'=>$db,'password'=>$this->_password);
227
+ }
228
  }
229
+ if(count($workingClients)>0){
230
+ if($selectRandomSlave){
231
+ if(!$writeOnly){
232
+ $workingClients[] = array('host'=>$master[3],'port'=>$master[5],'master'=>false,'db'=>$db,'password'=>$this->_password);
233
+ }
234
+ $clients[] = $workingClients[rand(0,count($workingClients)-1)];
235
+ } else {
236
+ $clients = $workingClients;
237
  }
 
 
 
238
  }
239
+ } else {
240
+ $writeOnly = false;
241
  }
242
  $clients[] = array('host'=>$master[3],'port'=>$master[5], 'db'=>$db ,'master'=>true,'write_only'=>$writeOnly,'password'=>$this->_password);
243
  return new Credis_Cluster($clients,$replicas,$this->_standAlone);
250
  * @param int $replicas
251
  * @param bool $selectRandomSlave
252
  * @param bool $writeOnly
253
+ * @param bool $masterOnly
254
  * @return Credis_Cluster
255
+ * @throws CredisException
256
  * @deprecated
257
  */
258
+ public function getCluster($name, $db=0, $replicas=128, $selectRandomSlave=true, $writeOnly=false, $masterOnly=false)
259
  {
260
  if(!isset($this->_cluster[$name])){
261
+ $this->_cluster[$name] = $this->createCluster($name, $db, $replicas, $selectRandomSlave, $writeOnly, $masterOnly);
262
  }
263
  return $this->_cluster[$name];
264
  }
dependencies/colinmollenhour/credis/testenv/docker-compose.yml CHANGED
@@ -1,11 +1,6 @@
1
  version: '2'
2
  services:
3
 
4
- php-55:
5
- build: env/php-5.5/
6
- volumes:
7
- - ../:/src/
8
-
9
  php-56:
10
  build: env/php-5.6/
11
  volumes:
@@ -30,3 +25,8 @@ services:
30
  build: env/php-7.3/
31
  volumes:
32
  - ../:/src/
 
 
 
 
 
1
  version: '2'
2
  services:
3
 
 
 
 
 
 
4
  php-56:
5
  build: env/php-5.6/
6
  volumes:
25
  build: env/php-7.3/
26
  volumes:
27
  - ../:/src/
28
+
29
+ php-74:
30
+ build: env/php-7.4/
31
+ volumes:
32
+ - ../:/src/
dependencies/colinmollenhour/credis/testenv/env/php-5.6/Dockerfile CHANGED
@@ -10,7 +10,7 @@ RUN wget https://phar.phpunit.de/phpunit-${phpunit_verison}.phar && \
10
  mv phpunit-${phpunit_verison}.phar /usr/local/bin/phpunit
11
 
12
  # install php extension
13
- RUN yes '' | pecl install -f redis && \
14
  docker-php-ext-enable redis
15
 
16
  # install redis server
10
  mv phpunit-${phpunit_verison}.phar /usr/local/bin/phpunit
11
 
12
  # install php extension
13
+ RUN yes '' | pecl install -f redis-4.3.0 && \
14
  docker-php-ext-enable redis
15
 
16
  # install redis server
dependencies/colinmollenhour/credis/testenv/env/php-7.0/Dockerfile CHANGED
@@ -1,9 +1,9 @@
1
  FROM php:7.0
2
- ENV phpunit_verison 6.4
3
- ENV redis_version 4.0.11
4
 
5
  RUN apt-get update && \
6
- apt-get install -y wget
7
 
8
  RUN wget https://phar.phpunit.de/phpunit-${phpunit_verison}.phar && \
9
  chmod +x phpunit-${phpunit_verison}.phar && \
@@ -16,6 +16,7 @@ RUN yes '' | pecl install -f redis && \
16
  # install redis server
17
  RUN wget http://download.redis.io/releases/redis-${redis_version}.tar.gz && \
18
  tar -xzf redis-${redis_version}.tar.gz && \
 
19
  make -s -C redis-${redis_version} -j
20
 
21
  CMD PATH=$PATH:/usr/local/bin/:/redis-${redis_version}/src/ && \
1
  FROM php:7.0
2
+ ENV phpunit_verison 6.5
3
+ ENV redis_version 6.0.8
4
 
5
  RUN apt-get update && \
6
+ apt-get install -y wget libssl-dev
7
 
8
  RUN wget https://phar.phpunit.de/phpunit-${phpunit_verison}.phar && \
9
  chmod +x phpunit-${phpunit_verison}.phar && \
16
  # install redis server
17
  RUN wget http://download.redis.io/releases/redis-${redis_version}.tar.gz && \
18
  tar -xzf redis-${redis_version}.tar.gz && \
19
+ export BUILD_TLS=yes && \
20
  make -s -C redis-${redis_version} -j
21
 
22
  CMD PATH=$PATH:/usr/local/bin/:/redis-${redis_version}/src/ && \
dependencies/colinmollenhour/credis/testenv/env/php-7.1/Dockerfile CHANGED
@@ -1,9 +1,9 @@
1
  FROM php:7.1
2
- ENV phpunit_verison 6.4
3
- ENV redis_version 4.0.11
4
 
5
  RUN apt-get update && \
6
- apt-get install -y wget
7
 
8
  RUN wget https://phar.phpunit.de/phpunit-${phpunit_verison}.phar && \
9
  chmod +x phpunit-${phpunit_verison}.phar && \
@@ -16,6 +16,7 @@ RUN yes '' | pecl install -f redis && \
16
  # install redis server
17
  RUN wget http://download.redis.io/releases/redis-${redis_version}.tar.gz && \
18
  tar -xzf redis-${redis_version}.tar.gz && \
 
19
  make -s -C redis-${redis_version} -j
20
 
21
  CMD PATH=$PATH:/usr/local/bin/:/redis-${redis_version}/src/ && \
1
  FROM php:7.1
2
+ ENV phpunit_verison 7.5
3
+ ENV redis_version 6.0.8
4
 
5
  RUN apt-get update && \
6
+ apt-get install -y wget libssl-dev
7
 
8
  RUN wget https://phar.phpunit.de/phpunit-${phpunit_verison}.phar && \
9
  chmod +x phpunit-${phpunit_verison}.phar && \
16
  # install redis server
17
  RUN wget http://download.redis.io/releases/redis-${redis_version}.tar.gz && \
18
  tar -xzf redis-${redis_version}.tar.gz && \
19
+ export BUILD_TLS=yes && \
20
  make -s -C redis-${redis_version} -j
21
 
22
  CMD PATH=$PATH:/usr/local/bin/:/redis-${redis_version}/src/ && \
dependencies/colinmollenhour/credis/testenv/env/php-7.2/Dockerfile CHANGED
@@ -1,9 +1,9 @@
1
  FROM php:7.2
2
  ENV phpunit_verison 7.5
3
- ENV redis_version 4.0.11
4
 
5
  RUN apt-get update && \
6
- apt-get install -y wget
7
 
8
  RUN wget https://phar.phpunit.de/phpunit-${phpunit_verison}.phar && \
9
  chmod +x phpunit-${phpunit_verison}.phar && \
@@ -16,6 +16,7 @@ RUN yes '' | pecl install -f redis && \
16
  # install redis server
17
  RUN wget http://download.redis.io/releases/redis-${redis_version}.tar.gz && \
18
  tar -xzf redis-${redis_version}.tar.gz && \
 
19
  make -s -C redis-${redis_version} -j
20
 
21
  CMD PATH=$PATH:/usr/local/bin/:/redis-${redis_version}/src/ && \
1
  FROM php:7.2
2
  ENV phpunit_verison 7.5
3
+ ENV redis_version 6.0.8
4
 
5
  RUN apt-get update && \
6
+ apt-get install -y wget libssl-dev
7
 
8
  RUN wget https://phar.phpunit.de/phpunit-${phpunit_verison}.phar && \
9
  chmod +x phpunit-${phpunit_verison}.phar && \
16
  # install redis server
17
  RUN wget http://download.redis.io/releases/redis-${redis_version}.tar.gz && \
18
  tar -xzf redis-${redis_version}.tar.gz && \
19
+ export BUILD_TLS=yes && \
20
  make -s -C redis-${redis_version} -j
21
 
22
  CMD PATH=$PATH:/usr/local/bin/:/redis-${redis_version}/src/ && \
dependencies/colinmollenhour/credis/testenv/env/php-7.3/Dockerfile CHANGED
@@ -1,9 +1,9 @@
1
  FROM php:7.3
2
  ENV phpunit_verison 7.5
3
- ENV redis_version 4.0.11
4
 
5
  RUN apt-get update && \
6
- apt-get install -y wget
7
 
8
  RUN wget https://phar.phpunit.de/phpunit-${phpunit_verison}.phar && \
9
  chmod +x phpunit-${phpunit_verison}.phar && \
@@ -16,6 +16,7 @@ RUN yes '' | pecl install -f redis && \
16
  # install redis server
17
  RUN wget http://download.redis.io/releases/redis-${redis_version}.tar.gz && \
18
  tar -xzf redis-${redis_version}.tar.gz && \
 
19
  make -s -C redis-${redis_version} -j
20
 
21
  CMD PATH=$PATH:/usr/local/bin/:/redis-${redis_version}/src/ && \
1
  FROM php:7.3
2
  ENV phpunit_verison 7.5
3
+ ENV redis_version 6.0.8
4
 
5
  RUN apt-get update && \
6
+ apt-get install -y wget libssl-dev
7
 
8
  RUN wget https://phar.phpunit.de/phpunit-${phpunit_verison}.phar && \
9
  chmod +x phpunit-${phpunit_verison}.phar && \
16
  # install redis server
17
  RUN wget http://download.redis.io/releases/redis-${redis_version}.tar.gz && \
18
  tar -xzf redis-${redis_version}.tar.gz && \
19
+ export BUILD_TLS=yes && \
20
  make -s -C redis-${redis_version} -j
21
 
22
  CMD PATH=$PATH:/usr/local/bin/:/redis-${redis_version}/src/ && \
dependencies/colinmollenhour/credis/testenv/env/php-7.4/Dockerfile ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM php:7.4
2
+ ENV phpunit_verison 7.5
3
+ ENV redis_version 6.0.8
4
+
5
+ RUN apt-get update && \
6
+ apt-get install -y wget libssl-dev
7
+
8
+ RUN wget https://phar.phpunit.de/phpunit-${phpunit_verison}.phar && \
9
+ chmod +x phpunit-${phpunit_verison}.phar && \
10
+ mv phpunit-${phpunit_verison}.phar /usr/local/bin/phpunit
11
+
12
+ # install php extension
13
+ RUN yes '' | pecl install -f redis && \
14
+ docker-php-ext-enable redis
15
+
16
+ # install redis server
17
+ RUN wget http://download.redis.io/releases/redis-${redis_version}.tar.gz && \
18
+ tar -xzf redis-${redis_version}.tar.gz && \
19
+ export BUILD_TLS=yes && \
20
+ make -s -C redis-${redis_version} -j
21
+
22
+ CMD PATH=$PATH:/usr/local/bin/:/redis-${redis_version}/src/ && \
23
+ cp -rp /src /app && \
24
+ cd /app && \
25
+ phpunit
dependencies/colinmollenhour/credis/tests/CredisClusterTest.php CHANGED
@@ -106,7 +106,11 @@ class CredisClusterTest extends CredisTestCommon
106
  }
107
  public function testDontHashForCodeCoverage()
108
  {
109
- $this->assertInternalType('array',$this->cluster->info());
 
 
 
 
110
  }
111
  public function testByHash()
112
  {
106
  }
107
  public function testDontHashForCodeCoverage()
108
  {
109
+ if (method_exists($this,'assertIsArray')){
110
+ $this->assertIsArray($this->cluster->info());
111
+ } else {
112
+ $this->assertInternalType('array',$this->cluster->info());
113
+ }
114
  }
115
  public function testByHash()
116
  {
dependencies/colinmollenhour/credis/tests/CredisSentinelTest.php CHANGED
@@ -76,7 +76,11 @@ class CredisSentinelTest extends CredisTestCommon
76
  public function testMasters()
77
  {
78
  $masters = $this->sentinel->masters();
79
- $this->assertInternalType('array',$masters);
 
 
 
 
80
  $this->assertCount(2,$masters);
81
  $this->assertArrayHasKey(0,$masters);
82
  $this->assertArrayHasKey(1,$masters);
@@ -95,7 +99,11 @@ class CredisSentinelTest extends CredisTestCommon
95
  public function testMaster()
96
  {
97
  $master = $this->sentinel->master($this->sentinelConfig->clustername);
98
- $this->assertInternalType('array',$master);
 
 
 
 
99
  $this->assertArrayHasKey(1,$master);
100
  $this->assertArrayHasKey(5,$master);
101
  $this->assertEquals($this->sentinelConfig->clustername,$master[1]);
@@ -107,7 +115,11 @@ class CredisSentinelTest extends CredisTestCommon
107
  public function testSlaveClient()
108
  {
109
  $slaves = $this->sentinel->getSlaveClients($this->sentinelConfig->clustername);
110
- $this->assertInternalType('array',$slaves);
 
 
 
 
111
  $this->assertCount(1,$slaves);
112
  foreach($slaves as $slave){
113
  $this->assertInstanceOf('Credis_Client',$slave);
@@ -118,14 +130,22 @@ class CredisSentinelTest extends CredisTestCommon
118
  public function testSlaves()
119
  {
120
  $slaves = $this->sentinel->slaves($this->sentinelConfig->clustername);
121
- $this->assertInternalType('array',$slaves);
 
 
 
 
122
  $this->assertCount(1,$slaves);
123
  $this->assertArrayHasKey(0,$slaves);
124
  $this->assertArrayHasKey(5,$slaves[0]);
125
  $this->assertEquals(6385,$slaves[0][5]);
126
 
127
  $slaves = $this->sentinel->slaves('masterdown');
128
- $this->assertInternalType('array',$slaves);
 
 
 
 
129
  $this->assertCount(0,$slaves);
130
 
131
  $this->setExpectedExceptionShim('CredisException','No such master with that name');
@@ -165,7 +185,11 @@ class CredisSentinelTest extends CredisTestCommon
165
  public function testGetMasterAddressByName()
166
  {
167
  $address = $this->sentinel->getMasterAddressByName($this->sentinelConfig->clustername);
168
- $this->assertInternalType('array',$address);
 
 
 
 
169
  $this->assertCount(2,$address);
170
  $this->assertArrayHasKey(0,$address);
171
  $this->assertArrayHasKey(1,$address);
@@ -184,7 +208,7 @@ class CredisSentinelTest extends CredisTestCommon
184
  $host = 'localhost';
185
  $port = '123456';
186
 
187
- $client = $this->createMockShim('\Credis_Client');
188
  $sentinel = new Credis_Sentinel($client);
189
 
190
  $client->expects($this->once())->method('getHost')->willReturn($host);
76
  public function testMasters()
77
  {
78
  $masters = $this->sentinel->masters();
79
+ if (method_exists($this,'assertIsArray')){
80
+ $this->assertIsArray($masters);
81
+ } else {
82
+ $this->assertInternalType('array',$masters);
83
+ }
84
  $this->assertCount(2,$masters);
85
  $this->assertArrayHasKey(0,$masters);
86
  $this->assertArrayHasKey(1,$masters);
99
  public function testMaster()
100
  {
101
  $master = $this->sentinel->master($this->sentinelConfig->clustername);
102
+ if (method_exists($this,'assertIsArray')){
103
+ $this->assertIsArray($master);
104
+ } else {
105
+ $this->assertInternalType('array',$master);
106
+ }
107
  $this->assertArrayHasKey(1,$master);
108
  $this->assertArrayHasKey(5,$master);
109
  $this->assertEquals($this->sentinelConfig->clustername,$master[1]);
115
  public function testSlaveClient()
116
  {
117
  $slaves = $this->sentinel->getSlaveClients($this->sentinelConfig->clustername);
118
+ if (method_exists($this,'assertIsArray')){
119
+ $this->assertIsArray($slaves);
120
+ } else {
121
+ $this->assertInternalType('array',$slaves);
122
+ }
123
  $this->assertCount(1,$slaves);
124
  foreach($slaves as $slave){
125
  $this->assertInstanceOf('Credis_Client',$slave);
130
  public function testSlaves()
131
  {
132
  $slaves = $this->sentinel->slaves($this->sentinelConfig->clustername);
133
+ if (method_exists($this,'assertIsArray')){
134
+ $this->assertIsArray($slaves);
135
+ } else {
136
+ $this->assertInternalType('array',$slaves);
137
+ }
138
  $this->assertCount(1,$slaves);
139
  $this->assertArrayHasKey(0,$slaves);
140
  $this->assertArrayHasKey(5,$slaves[0]);
141
  $this->assertEquals(6385,$slaves[0][5]);
142
 
143
  $slaves = $this->sentinel->slaves('masterdown');
144
+ if (method_exists($this,'assertIsArray')){
145
+ $this->assertIsArray($slaves);
146
+ } else {
147
+ $this->assertInternalType('array',$slaves);
148
+ }
149
  $this->assertCount(0,$slaves);
150
 
151
  $this->setExpectedExceptionShim('CredisException','No such master with that name');
185
  public function testGetMasterAddressByName()
186
  {
187
  $address = $this->sentinel->getMasterAddressByName($this->sentinelConfig->clustername);
188
+ if (method_exists($this,'assertIsArray')){
189
+ $this->assertIsArray($address);
190
+ } else {
191
+ $this->assertInternalType('array',$address);
192
+ }
193
  $this->assertCount(2,$address);
194
  $this->assertArrayHasKey(0,$address);
195
  $this->assertArrayHasKey(1,$address);
208
  $host = 'localhost';
209
  $port = '123456';
210
 
211
+ $client = $this->createMock('\Credis_Client');
212
  $sentinel = new Credis_Sentinel($client);
213
 
214
  $client->expects($this->once())->method('getHost')->willReturn($host);
dependencies/colinmollenhour/credis/tests/CredisTest.php CHANGED
@@ -578,7 +578,7 @@ class CredisTest extends CredisTestCommon
578
  }
579
  catch(CredisException $e)
580
  {
581
- $this->assertStringStartsWith('ERR invalid password', $e->getMessage());
582
  $this->credis->close();
583
  }
584
  $this->credis = new Credis_Client($this->redisConfig[4]['host'], $this->redisConfig[4]['port'], $this->redisConfig[4]['timeout'], false, 0);
@@ -592,7 +592,6 @@ class CredisTest extends CredisTestCommon
592
  catch(CredisException $e)
593
  {
594
  $this->assertStringStartsWith('NOAUTH Authentication required', $e->getMessage());
595
-
596
  }
597
  try
598
  {
@@ -600,7 +599,7 @@ class CredisTest extends CredisTestCommon
600
  }
601
  catch(CredisException $e)
602
  {
603
- $this->assertStringStartsWith('ERR invalid password', $e->getMessage());
604
  }
605
  $this->assertTrue($this->credis->auth('thepassword'));
606
  $this->assertTrue($this->credis->set('key','value'));
@@ -632,44 +631,32 @@ class CredisTest extends CredisTestCommon
632
 
633
  public function testConnectionStrings()
634
  {
635
- $this->credis->close();
636
  $this->credis = new Credis_Client('tcp://'.$this->redisConfig[0]['host'] . ':' . $this->redisConfig[0]['port']);
637
- if ($this->useStandalone) {
638
- $this->credis->forceStandalone();
639
- }
640
  $this->assertEquals($this->credis->getHost(),$this->redisConfig[0]['host']);
641
  $this->assertEquals($this->credis->getPort(),$this->redisConfig[0]['port']);
642
  $this->credis = new Credis_Client('tcp://'.$this->redisConfig[0]['host']);
643
- if ($this->useStandalone) {
644
- $this->credis->forceStandalone();
645
- }
646
- $this->assertEquals($this->credis->getPort(),$this->redisConfig[0]['port']);
647
  $this->credis = new Credis_Client('tcp://'.$this->redisConfig[0]['host'] . ':' . $this->redisConfig[0]['port'] . '/abc123');
648
- if ($this->useStandalone) {
649
- $this->credis->forceStandalone();
650
- }
651
- $this->assertEquals('abc123',$this->credis->getPersistence());
 
652
  }
653
 
654
  public function testConnectionStringsTls()
655
  {
656
- $this->credis->close();
657
  $this->credis = new Credis_Client('tls://'.$this->redisConfig[0]['host'] . ':' . $this->redisConfig[0]['port']);
658
- if ($this->useStandalone) {
659
- $this->credis->forceStandalone();
660
- }
661
  $this->assertEquals($this->credis->getHost(),$this->redisConfig[0]['host']);
662
  $this->assertEquals($this->credis->getPort(),$this->redisConfig[0]['port']);
663
  $this->credis = new Credis_Client('tls://'.$this->redisConfig[0]['host']);
664
- if ($this->useStandalone) {
665
- $this->credis->forceStandalone();
666
- }
667
- $this->assertEquals($this->credis->getPort(),$this->redisConfig[0]['port']);
668
  $this->credis = new Credis_Client('tls://'.$this->redisConfig[0]['host'] . ':' . $this->redisConfig[0]['port'] . '/abc123');
669
- if ($this->useStandalone) {
670
- $this->credis->forceStandalone();
671
- }
672
- $this->assertEquals('abc123',$this->credis->getPersistence());
 
673
  }
674
 
675
  /**
578
  }
579
  catch(CredisException $e)
580
  {
581
+ $this->assertStringStartsWith('WRONGPASS invalid username-password pair', $e->getMessage());
582
  $this->credis->close();
583
  }
584
  $this->credis = new Credis_Client($this->redisConfig[4]['host'], $this->redisConfig[4]['port'], $this->redisConfig[4]['timeout'], false, 0);
592
  catch(CredisException $e)
593
  {
594
  $this->assertStringStartsWith('NOAUTH Authentication required', $e->getMessage());
 
595
  }
596
  try
597
  {
599
  }
600
  catch(CredisException $e)
601
  {
602
+ $this->assertStringStartsWith('WRONGPASS invalid username-password pair', $e->getMessage());
603
  }
604
  $this->assertTrue($this->credis->auth('thepassword'));
605
  $this->assertTrue($this->credis->set('key','value'));
631
 
632
  public function testConnectionStrings()
633
  {
 
634
  $this->credis = new Credis_Client('tcp://'.$this->redisConfig[0]['host'] . ':' . $this->redisConfig[0]['port']);
 
 
 
635
  $this->assertEquals($this->credis->getHost(),$this->redisConfig[0]['host']);
636
  $this->assertEquals($this->credis->getPort(),$this->redisConfig[0]['port']);
637
  $this->credis = new Credis_Client('tcp://'.$this->redisConfig[0]['host']);
638
+ $this->assertEquals($this->credis->getPort(),6379);
 
 
 
639
  $this->credis = new Credis_Client('tcp://'.$this->redisConfig[0]['host'] . ':' . $this->redisConfig[0]['port'] . '/abc123');
640
+ $this->assertEquals($this->credis->getPersistence(),'abc123');
641
+ $this->credis = new Credis_Client('tcp://'.$this->redisConfig[0]['host'],6380);
642
+ $this->assertEquals($this->credis->getPort(),6380);
643
+ $this->credis = new Credis_Client('tcp://'.$this->redisConfig[0]['host'],NULL,NULL,"abc123");
644
+ $this->assertEquals($this->credis->getPersistence(),'abc123');
645
  }
646
 
647
  public function testConnectionStringsTls()
648
  {
 
649
  $this->credis = new Credis_Client('tls://'.$this->redisConfig[0]['host'] . ':' . $this->redisConfig[0]['port']);
 
 
 
650
  $this->assertEquals($this->credis->getHost(),$this->redisConfig[0]['host']);
651
  $this->assertEquals($this->credis->getPort(),$this->redisConfig[0]['port']);
652
  $this->credis = new Credis_Client('tls://'.$this->redisConfig[0]['host']);
653
+ $this->assertEquals($this->credis->getPort(),6379);
 
 
 
654
  $this->credis = new Credis_Client('tls://'.$this->redisConfig[0]['host'] . ':' . $this->redisConfig[0]['port'] . '/abc123');
655
+ $this->assertEquals($this->credis->getPersistence(),'abc123');
656
+ $this->credis = new Credis_Client('tls://'.$this->redisConfig[0]['host'],6380);
657
+ $this->assertEquals($this->credis->getPort(),6380);
658
+ $this->credis = new Credis_Client('tls://'.$this->redisConfig[0]['host'],NULL,NULL,"abc123");
659
+ $this->assertEquals($this->credis->getPersistence(),'abc123');
660
  }
661
 
662
  /**
dependencies/colinmollenhour/credis/tests/CredisTestCommon.php CHANGED
@@ -149,23 +149,6 @@ class CredisTestCommon extends \PHPUnit\Framework\TestCase
149
  }
150
  }
151
 
152
-
153
- //
154
- /**
155
- * php 7.2 compat fix, as directly polyfilling for older PHPUnit causes a function signature compatibility issue
156
- * This is due to the defined return type
157
- *
158
- * Polyfill for older PHPUnit
159
- */
160
- protected function createMockShim($originalClassName)
161
- {
162
- if (method_exists($this, 'getMock')) {
163
- return $this->getMock($originalClassName);
164
- } else {
165
- return parent::createMock($originalClassName);
166
- }
167
- }
168
-
169
  /**
170
  * php 7.2 compat fix, as directly polyfilling for older PHPUnit causes a function signature compatibility issue
171
  * This is due to the defined return type
149
  }
150
  }
151
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
152
  /**
153
  * php 7.2 compat fix, as directly polyfilling for older PHPUnit causes a function signature compatibility issue
154
  * This is due to the defined return type
includes/class-metrics.php ADDED
@@ -0,0 +1,253 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Metrics collection
4
+ *
5
+ * @package Rhubarb\RedisCache
6
+ */
7
+
8
+ namespace Rhubarb\RedisCache;
9
+
10
+ use Exception;
11
+
12
+ defined( '\\ABSPATH' ) || exit;
13
+
14
+ /**
15
+ * Metrics collection class
16
+ */
17
+ class Metrics {
18
+
19
+ /**
20
+ * Unique identifier
21
+ *
22
+ * @var string
23
+ */
24
+ public $id;
25
+
26
+ /**
27
+ * Cache hits
28
+ *
29
+ * @var int
30
+ */
31
+ public $hits;
32
+
33
+ /**
34
+ * Cache misses
35
+ *
36
+ * @var int
37
+ */
38
+ public $misses;
39
+
40
+ /**
41
+ * Cache ratio
42
+ *
43
+ * @var float
44
+ */
45
+ public $ratio;
46
+
47
+ /**
48
+ * Bytes retrieves
49
+ *
50
+ * @var int
51
+ */
52
+ public $bytes;
53
+
54
+ /**
55
+ * Cache needed time
56
+ *
57
+ * @var float
58
+ */
59
+ public $time;
60
+
61
+ /**
62
+ * Cache calls
63
+ *
64
+ * @var int
65
+ */
66
+ public $calls;
67
+
68
+ /**
69
+ * Metrics timestamp
70
+ *
71
+ * @var int
72
+ */
73
+ public $timestamp;
74
+
75
+ /**
76
+ * Initializes the metrics collection
77
+ *
78
+ * @return void
79
+ */
80
+ public static function init() {
81
+ if ( ! self::is_enabled() ) {
82
+ return;
83
+ }
84
+
85
+ add_action( 'shutdown', [ self::class, 'record' ] );
86
+ add_action( 'rediscache_discard_metrics', [ self::class, 'discard' ] );
87
+ }
88
+
89
+ /**
90
+ * Checks if the collection of metrics is enabled.
91
+ *
92
+ * @return bool
93
+ */
94
+ public static function is_enabled() {
95
+ return ! defined( 'WP_REDIS_DISABLE_METRICS' )
96
+ || WP_REDIS_DISABLE_METRICS;
97
+ }
98
+
99
+ /**
100
+ * Checks if metrics can be recorded.
101
+ *
102
+ * @return bool
103
+ */
104
+ public static function is_active() {
105
+ global $wp_object_cache;
106
+
107
+ return self::is_enabled()
108
+ && Plugin::instance()->get_redis_status()
109
+ && method_exists( $wp_object_cache, 'info' )
110
+ && method_exists( $wp_object_cache, 'redis_instance' );
111
+ }
112
+
113
+ /**
114
+ * Retrieves metrics max time
115
+ *
116
+ * @return int
117
+ */
118
+ public static function max_time() {
119
+ if ( defined( 'WP_REDIS_METRICS_MAX_TIME' ) ) {
120
+ return (int) WP_REDIS_METRICS_MAX_TIME;
121
+ }
122
+
123
+ return HOUR_IN_SECONDS;
124
+ }
125
+
126
+ /**
127
+ * Records metrics and adds them to redis
128
+ *
129
+ * @return void
130
+ */
131
+ public static function record() {
132
+ global $wp_object_cache;
133
+
134
+ if ( ! self::is_active() ) {
135
+ return;
136
+ }
137
+
138
+ $metrics = new self();
139
+ $metrics->collect();
140
+ $metrics->save();
141
+ }
142
+
143
+ /**
144
+ * Collect metrics from object cache instance.
145
+ */
146
+ public function collect() {
147
+ global $wp_object_cache;
148
+
149
+ $info = $wp_object_cache->info();
150
+
151
+ $this->id = substr( uniqid(), -7 );
152
+ $this->hits = $info->hits;
153
+ $this->misses = $info->misses;
154
+ $this->ratio = $info->ratio;
155
+ $this->bytes = $info->bytes;
156
+ $this->time = round( $info->time, 5 );
157
+ $this->calls = $info->calls;
158
+ $this->timestamp = time();
159
+ }
160
+
161
+ /**
162
+ * Retrieves metrics from redis
163
+ *
164
+ * @param int $seconds Number of seconds of the oldest entry to retrieve.
165
+ * @return Metrics[]
166
+ */
167
+ public static function get( $seconds = null ) {
168
+ global $wp_object_cache;
169
+
170
+ if ( ! self::is_active() ) {
171
+ return [];
172
+ }
173
+
174
+ if ( null === $seconds ) {
175
+ $seconds = self::max_time();
176
+ }
177
+
178
+ try {
179
+ $serialied_metrics = $wp_object_cache->redis_instance()->zrangebyscore(
180
+ $wp_object_cache->build_key( 'metrics', 'redis-cache' ),
181
+ time() - $seconds,
182
+ time() - MINUTE_IN_SECONDS,
183
+ [ 'withscores' => true ]
184
+ );
185
+ } catch ( Exception $exception ) {
186
+ // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_error_log
187
+ error_log( $exception );
188
+
189
+ return [];
190
+ }
191
+
192
+ $metrics = [];
193
+ $prefix = sprintf( 'O:%d:"%s', strlen( self::class ), self::class );
194
+
195
+ foreach ( $serialied_metrics as $serialized => $timestamp ) {
196
+ // Compatibility: Ignore all non serialized entries as they were used by prior versions.
197
+ if ( strpos( $serialized, $prefix ) !== 0 ) {
198
+ continue;
199
+ }
200
+
201
+ // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions.serialize_unserialize
202
+ $metrics[] = unserialize( $serialized );
203
+ }
204
+
205
+ return $metrics;
206
+ }
207
+
208
+ /**
209
+ * Saves the current metrics to redis
210
+ *
211
+ * @return void
212
+ */
213
+ public function save() {
214
+ global $wp_object_cache;
215
+
216
+ try {
217
+ $wp_object_cache->redis_instance()->zadd(
218
+ $wp_object_cache->build_key( 'metrics', 'redis-cache' ),
219
+ $this->timestamp,
220
+ // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions.serialize_serialize
221
+ serialize( $this )
222
+ );
223
+ } catch ( Exception $exception ) {
224
+ // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_error_log
225
+ error_log( $exception );
226
+ }
227
+ }
228
+
229
+ /**
230
+ * Removes recorded metrics after an hour
231
+ *
232
+ * @return void
233
+ */
234
+ public static function discard() {
235
+ global $wp_object_cache;
236
+
237
+ if ( ! self::is_active() ) {
238
+ return;
239
+ }
240
+
241
+ try {
242
+ $wp_object_cache->redis_instance()->zremrangebyscore(
243
+ $wp_object_cache->build_key( 'metrics', 'redis-cache' ),
244
+ 0,
245
+ time() - self::max_time()
246
+ );
247
+ } catch ( Exception $exception ) {
248
+ // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_error_log
249
+ error_log( $exception );
250
+ }
251
+ }
252
+
253
+ }
includes/class-plugin.php CHANGED
@@ -8,7 +8,6 @@
8
  namespace Rhubarb\RedisCache;
9
 
10
  use WP_Error;
11
- use Exception;
12
 
13
  defined( '\\ABSPATH' ) || exit;
14
 
@@ -79,6 +78,8 @@ class Plugin {
79
  $this->screen = 'settings_page_redis-cache';
80
  }
81
 
 
 
82
  $this->add_actions_and_filters();
83
  }
84
 
@@ -112,8 +113,6 @@ class Plugin {
112
  add_filter( $links, [ $this, 'add_plugin_actions_links' ] );
113
 
114
  add_action( 'wp_head', [ $this, 'register_shutdown_hooks' ] );
115
- add_action( 'shutdown', [ $this, 'record_metrics' ] );
116
- add_action( 'rediscache_discard_metrics', [ $this, 'discard_metrics' ] );
117
 
118
  add_filter( 'qm/collectors', [ $this, 'register_qm_collector' ], 25 );
119
  add_filter( 'qm/outputter/html', [ $this, 'register_qm_output' ] );
@@ -126,7 +125,7 @@ class Plugin {
126
  */
127
  public function init() {
128
  load_plugin_textdomain( 'redis-cache', false, 'redis-cache/languages' );
129
-
130
  if ( is_admin() && ! wp_next_scheduled( 'rediscache_discard_metrics' ) ) {
131
  wp_schedule_event( time(), 'hourly', 'rediscache_discard_metrics' );
132
  }
@@ -229,10 +228,19 @@ class Plugin {
229
  * @return string[]
230
  */
231
  public function add_plugin_actions_links( $links ) {
232
- return array_merge(
233
- [ sprintf( '<a href="%s">%s</a>', network_admin_url( $this->page ), esc_html__( 'Settings', 'redis-cache' ) ) ],
234
- $links
 
 
 
 
 
 
 
235
  );
 
 
236
  }
237
 
238
  /**
@@ -319,9 +327,7 @@ class Plugin {
319
  * @return void
320
  */
321
  public function enqueue_redis_metrics() {
322
- global $wp_object_cache;
323
-
324
- if ( defined( 'WP_REDIS_DISABLE_METRICS' ) && WP_REDIS_DISABLE_METRICS ) {
325
  return;
326
  }
327
 
@@ -343,26 +349,13 @@ class Plugin {
343
  true
344
  );
345
 
346
- if ( ! method_exists( $wp_object_cache, 'redis_instance' ) ) {
347
- return;
348
- }
349
 
350
- try {
351
- $min_time = $screen->id === $this->screen
352
- ? self::metrics_max_time()
353
- : MINUTE_IN_SECONDS * 30;
354
-
355
- $metrics = $wp_object_cache->redis_instance()->zrangebyscore(
356
- $wp_object_cache->build_key( 'metrics', 'redis-cache' ),
357
- time() - $min_time,
358
- time() - MINUTE_IN_SECONDS,
359
- [ 'withscores' => true ]
360
- );
361
 
362
- wp_localize_script( 'redis-cache', 'rediscache_metrics', $metrics );
363
- } catch ( Exception $exception ) {
364
- error_log( $exception ); // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_error_log
365
- }
366
  }
367
 
368
  /**
@@ -418,7 +411,20 @@ class Plugin {
418
  $dropin = get_plugin_data( WP_CONTENT_DIR . '/object-cache.php' );
419
  $plugin = get_plugin_data( WP_REDIS_PLUGIN_PATH . '/includes/object-cache.php' );
420
 
421
- return $dropin['PluginURI'] === $plugin['PluginURI'];
 
 
 
 
 
 
 
 
 
 
 
 
 
422
  }
423
 
424
  /**
@@ -574,6 +580,11 @@ class Plugin {
574
  if ( ! current_user_can( is_multisite() ? 'manage_network_options' : 'manage_options' ) ) {
575
  return;
576
  }
 
 
 
 
 
577
 
578
  if ( $this->object_cache_dropin_exists() ) {
579
  $url = $this->action_link( 'update-dropin' );
@@ -589,7 +600,7 @@ class Plugin {
589
  }
590
 
591
  if ( isset( $message ) ) {
592
- printf( '<div class="update-nag">%s</div>', wp_kses_post( $message ) );
593
  }
594
  }
595
  }
@@ -845,80 +856,6 @@ class Plugin {
845
  }
846
  }
847
 
848
- /**
849
- * Adds the recorded metrics to redis
850
- *
851
- * @return void
852
- */
853
- public function record_metrics() {
854
- global $wp_object_cache;
855
-
856
- if ( defined( 'WP_REDIS_DISABLE_METRICS' ) && WP_REDIS_DISABLE_METRICS ) {
857
- return;
858
- }
859
-
860
- if ( ! $this->get_redis_status() ) {
861
- return;
862
- }
863
-
864
- if ( ! method_exists( $wp_object_cache, 'info' ) || ! method_exists( $wp_object_cache, 'redis_instance' ) ) {
865
- return;
866
- }
867
-
868
- $info = $wp_object_cache->info();
869
-
870
- $metrics = [
871
- 'i' => substr( uniqid(), -7 ),
872
- 'h' => $info->hits,
873
- 'm' => $info->misses,
874
- 'r' => $info->ratio,
875
- 'b' => $info->bytes,
876
- 't' => number_format( $info->time, 5 ),
877
- 'c' => $info->calls,
878
- ];
879
-
880
- try {
881
- $wp_object_cache->redis_instance()->zadd(
882
- $wp_object_cache->build_key( 'metrics', 'redis-cache' ),
883
- time(),
884
- http_build_query( $metrics, null, ';' )
885
- );
886
- } catch ( Exception $exception ) {
887
- error_log( $exception ); // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_error_log
888
- }
889
- }
890
-
891
- /**
892
- * Removes recorded metrics after an hour
893
- *
894
- * @return void
895
- */
896
- public function discard_metrics() {
897
- global $wp_object_cache;
898
-
899
- if ( defined( 'WP_REDIS_DISABLE_METRICS' ) && WP_REDIS_DISABLE_METRICS ) {
900
- return;
901
- }
902
-
903
- if ( ! $this->get_redis_status() ) {
904
- return;
905
- }
906
-
907
- if ( ! method_exists( $wp_object_cache, 'redis_instance' ) ) {
908
- return;
909
- }
910
-
911
- try {
912
- $wp_object_cache->redis_instance()->zremrangebyscore(
913
- $wp_object_cache->build_key( 'metrics', 'redis-cache' ),
914
- 0,
915
- time() - self::metrics_max_time()
916
- );
917
- } catch ( Exception $exception ) {
918
- error_log( $exception ); // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_error_log
919
- }
920
- }
921
-
922
  /**
923
  * Displays the redis cache html comment
924
  *
@@ -956,7 +893,7 @@ class Plugin {
956
  'https://wprediscache.com'
957
  );
958
 
959
- if ( ! WP_DEBUG ) {
960
  // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
961
  printf( "\n<!-- %s -->\n", $message );
962
 
@@ -980,19 +917,6 @@ class Plugin {
980
  );
981
  }
982
 
983
- /**
984
- * Retrieves metrix max time
985
- *
986
- * @return int
987
- */
988
- public static function metrics_max_time() {
989
- if ( defined( 'WP_REDIS_METRICS_MAX_TIME' ) ) {
990
- return intval( WP_REDIS_METRICS_MAX_TIME );
991
- }
992
-
993
- return HOUR_IN_SECONDS;
994
- }
995
-
996
  /**
997
  * Initializes the WP filesystem API to be ready for use
998
  *
8
  namespace Rhubarb\RedisCache;
9
 
10
  use WP_Error;
 
11
 
12
  defined( '\\ABSPATH' ) || exit;
13
 
78
  $this->screen = 'settings_page_redis-cache';
79
  }
80
 
81
+ Metrics::init();
82
+
83
  $this->add_actions_and_filters();
84
  }
85
 
113
  add_filter( $links, [ $this, 'add_plugin_actions_links' ] );
114
 
115
  add_action( 'wp_head', [ $this, 'register_shutdown_hooks' ] );
 
 
116
 
117
  add_filter( 'qm/collectors', [ $this, 'register_qm_collector' ], 25 );
118
  add_filter( 'qm/outputter/html', [ $this, 'register_qm_output' ] );
125
  */
126
  public function init() {
127
  load_plugin_textdomain( 'redis-cache', false, 'redis-cache/languages' );
128
+
129
  if ( is_admin() && ! wp_next_scheduled( 'rediscache_discard_metrics' ) ) {
130
  wp_schedule_event( time(), 'hourly', 'rediscache_discard_metrics' );
131
  }
228
  * @return string[]
229
  */
230
  public function add_plugin_actions_links( $links ) {
231
+ $upgrade = sprintf(
232
+ '<a href="%s">%s</a>',
233
+ 'https://objectcache.pro/?utm_source=wp-plugin&amp;utm_medium=action-link',
234
+ esc_html__( 'Upgrade', 'redis-cache' )
235
+ );
236
+
237
+ $settings = sprintf(
238
+ '<a href="%s">%s</a>',
239
+ network_admin_url( $this->page ),
240
+ esc_html__( 'Settings', 'redis-cache' )
241
  );
242
+
243
+ return array_merge( [ $upgrade, $settings ], $links );
244
  }
245
 
246
  /**
327
  * @return void
328
  */
329
  public function enqueue_redis_metrics() {
330
+ if ( ! Metrics::is_enabled() ) {
 
 
331
  return;
332
  }
333
 
349
  true
350
  );
351
 
352
+ $min_time = $screen->id === $this->screen
353
+ ? Metrics::max_time()
354
+ : MINUTE_IN_SECONDS * 30;
355
 
356
+ $metrics = Metrics::get( $min_time );
 
 
 
 
 
 
 
 
 
 
357
 
358
+ wp_localize_script( 'redis-cache', 'rediscache_metrics', $metrics );
 
 
 
359
  }
360
 
361
  /**
411
  $dropin = get_plugin_data( WP_CONTENT_DIR . '/object-cache.php' );
412
  $plugin = get_plugin_data( WP_REDIS_PLUGIN_PATH . '/includes/object-cache.php' );
413
 
414
+ /**
415
+ * Filters the drop-in validation state
416
+ *
417
+ * @since 2.0.16
418
+ * @param bool $state The validation state of the drop-in.
419
+ * @param string $dropin The `PluginURI` of the drop-in.
420
+ * @param string $plugin The `PluginURI` of the plugin.
421
+ */
422
+ return apply_filters(
423
+ 'redis_cache_validate_dropin',
424
+ $dropin['PluginURI'] === $plugin['PluginURI'],
425
+ $dropin['PluginURI'],
426
+ $plugin['PluginURI']
427
+ );
428
  }
429
 
430
  /**
580
  if ( ! current_user_can( is_multisite() ? 'manage_network_options' : 'manage_options' ) ) {
581
  return;
582
  }
583
+
584
+ // Do not display the dropin message if you want
585
+ if ( defined( 'WP_REDIS_DISABLE_DROPIN_BANNERS' ) && WP_REDIS_DISABLE_DROPIN_BANNERS ) {
586
+ return;
587
+ }
588
 
589
  if ( $this->object_cache_dropin_exists() ) {
590
  $url = $this->action_link( 'update-dropin' );
600
  }
601
 
602
  if ( isset( $message ) ) {
603
+ printf( '<div class="update-nag notice notice-warning inline">%s</div>', wp_kses_post( $message ) );
604
  }
605
  }
606
  }
856
  }
857
  }
858
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
859
  /**
860
  * Displays the redis cache html comment
861
  *
893
  'https://wprediscache.com'
894
  );
895
 
896
+ if ( ! WP_DEBUG_DISPLAY ) {
897
  // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
898
  printf( "\n<!-- %s -->\n", $message );
899
 
917
  );
918
  }
919
 
 
 
 
 
 
 
 
 
 
 
 
 
 
920
  /**
921
  * Initializes the WP filesystem API to be ready for use
922
  *
includes/cli/class-commands.php CHANGED
@@ -36,6 +36,42 @@ class Commands extends WP_CLI_Command {
36
  require_once __DIR__ . '/../ui/diagnostics.php';
37
  }
38
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
39
  /**
40
  * Enables the Redis object cache.
41
  *
36
  require_once __DIR__ . '/../ui/diagnostics.php';
37
  }
38
 
39
+ /**
40
+ * Show the Redis object cache status and (when possible) client.
41
+ *
42
+ * ## EXAMPLES
43
+ *
44
+ * wp redis metrics
45
+ */
46
+ public function metrics() {
47
+ global $wp_object_cache;
48
+
49
+ if ( defined( 'WP_REDIS_DISABLE_METRICS' ) && WP_REDIS_DISABLE_METRICS ) {
50
+ WP_CLI::error( __( 'Enable object cache to collect data.', 'redis-cache' ) );
51
+
52
+ return;
53
+ }
54
+
55
+ if ( ! method_exists( $wp_object_cache, 'redis_instance' ) ) {
56
+ return;
57
+ }
58
+
59
+ try {
60
+ $metrics = $wp_object_cache->redis_instance()->zrangebyscore(
61
+ $wp_object_cache->build_key( 'metrics', 'redis-cache' ),
62
+ time() - ( MINUTE_IN_SECONDS * 30 ),
63
+ time() - MINUTE_IN_SECONDS,
64
+ [ 'withscores' => true ]
65
+ );
66
+
67
+ wp_localize_script( 'redis-cache', 'rediscache_metrics', $metrics );
68
+ } catch ( Exception $exception ) {
69
+ error_log( $exception ); // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_error_log
70
+ }
71
+
72
+ var_dump($metrics);
73
+ }
74
+
75
  /**
76
  * Enables the Redis object cache.
77
  *
includes/object-cache.php CHANGED
@@ -380,7 +380,7 @@ class WP_Object_Cache {
380
  /**
381
  * Track how long request took.
382
  *
383
- * @var int
384
  */
385
  public $cache_time = 0;
386
 
@@ -511,12 +511,8 @@ class WP_Object_Cache {
511
  }
512
  }
513
 
514
- if ( isset( $parameters['password'] ) ) {
515
- $password = $parameters['password'];
516
-
517
- if ( is_null( $password ) || $password === '' ) {
518
- unset( $parameters['password'] );
519
- }
520
  }
521
 
522
  return $parameters;
@@ -588,7 +584,7 @@ class WP_Object_Cache {
588
 
589
  if ( isset( $parameters['database'] ) ) {
590
  if ( ctype_digit( $parameters['database'] ) ) {
591
- $parameters['database'] = intval( $parameters['database'] );
592
  }
593
 
594
  $args['database'] = $parameters['database'];
@@ -847,7 +843,7 @@ class WP_Object_Cache {
847
 
848
  if ( isset( $parameters['database'] ) ) {
849
  if ( ctype_digit( $parameters['database'] ) ) {
850
- $parameters['database'] = intval( $parameters['database'] );
851
  }
852
 
853
  if ( $parameters['database'] ) {
@@ -1103,7 +1099,7 @@ class WP_Object_Cache {
1103
  * @return bool Returns TRUE on success or FALSE on failure.
1104
  */
1105
  public function flush( $delay = 0 ) {
1106
- $delay = abs( intval( $delay ) );
1107
 
1108
  if ( $delay ) {
1109
  sleep( $delay );
@@ -1480,6 +1476,7 @@ LUA;
1480
  $results = array_combine(
1481
  $remaining_keys,
1482
  $this->redis->mget( $remaining_ids )
 
1483
  );
1484
  } catch ( Exception $exception ) {
1485
  $this->handle_exception( $exception );
@@ -1723,10 +1720,10 @@ LUA;
1723
  <?php echo $this->diagnostics['client'] ?: 'Unknown'; ?>
1724
  <br />
1725
  <strong>Cache Hits:</strong>
1726
- <?php echo intval( $this->cache_hits ); ?>
1727
  <br />
1728
  <strong>Cache Misses:</strong>
1729
- <?php echo intval( $this->cache_misses ); ?>
1730
  <br />
1731
  <strong>Cache Size:</strong>
1732
  <?php echo number_format( strlen( serialize( $this->cache ) ) / 1024, 2 ); ?> kB
380
  /**
381
  * Track how long request took.
382
  *
383
+ * @var float
384
  */
385
  public $cache_time = 0;
386
 
511
  }
512
  }
513
 
514
+ if ( isset( $parameters[ 'password' ] ) && $parameters[ 'password' ] === '' ) {
515
+ unset( $parameters[ 'password' ] );
 
 
 
 
516
  }
517
 
518
  return $parameters;
584
 
585
  if ( isset( $parameters['database'] ) ) {
586
  if ( ctype_digit( $parameters['database'] ) ) {
587
+ $parameters['database'] = (int) $parameters['database'];
588
  }
589
 
590
  $args['database'] = $parameters['database'];
843
 
844
  if ( isset( $parameters['database'] ) ) {
845
  if ( ctype_digit( $parameters['database'] ) ) {
846
+ $parameters['database'] = (int) $parameters['database'];
847
  }
848
 
849
  if ( $parameters['database'] ) {
1099
  * @return bool Returns TRUE on success or FALSE on failure.
1100
  */
1101
  public function flush( $delay = 0 ) {
1102
+ $delay = abs( (int) $delay );
1103
 
1104
  if ( $delay ) {
1105
  sleep( $delay );
1476
  $results = array_combine(
1477
  $remaining_keys,
1478
  $this->redis->mget( $remaining_ids )
1479
+ ?: array_fill( 0, count( $remaining_ids ), false )
1480
  );
1481
  } catch ( Exception $exception ) {
1482
  $this->handle_exception( $exception );
1720
  <?php echo $this->diagnostics['client'] ?: 'Unknown'; ?>
1721
  <br />
1722
  <strong>Cache Hits:</strong>
1723
+ <?php echo (int) $this->cache_hits; ?>
1724
  <br />
1725
  <strong>Cache Misses:</strong>
1726
+ <?php echo (int) $this->cache_misses; ?>
1727
  <br />
1728
  <strong>Cache Size:</strong>
1729
  <?php echo number_format( strlen( serialize( $this->cache ) ) / 1024, 2 ); ?> kB
includes/ui/class-tab.php CHANGED
@@ -132,7 +132,7 @@ class Tab {
132
  /**
133
  * Getter for tab custom data
134
  *
135
- * @param $string $key Custom data key.
136
  * @return mixed
137
  */
138
  public function custom( $key ) {
132
  /**
133
  * Getter for tab custom data
134
  *
135
+ * @param string $key Custom data key.
136
  * @return mixed
137
  */
138
  public function custom( $key ) {
includes/ui/query-monitor.php CHANGED
@@ -23,12 +23,12 @@ echo $this->before_non_tabular_output();
23
 
24
  <section>
25
  <h3><?php esc_html_e( 'Hits', 'redis-cache' ); ?></h3>
26
- <p class="qm-ltr"><code><?php echo intval( $data['hits'] ); ?></code></p>
27
  </section>
28
 
29
  <section>
30
  <h3><?php esc_html_e( 'Misses', 'redis-cache' ); ?></h3>
31
- <p class="qm-ltr"><code><?php echo intval( $data['misses'] ); ?></code></p>
32
  </section>
33
 
34
  <section>
23
 
24
  <section>
25
  <h3><?php esc_html_e( 'Hits', 'redis-cache' ); ?></h3>
26
+ <p class="qm-ltr"><code><?php echo (int) $data['hits']; ?></code></p>
27
  </section>
28
 
29
  <section>
30
  <h3><?php esc_html_e( 'Misses', 'redis-cache' ); ?></h3>
31
+ <p class="qm-ltr"><code><?php echo (int) $data['misses']; ?></code></p>
32
  </section>
33
 
34
  <section>
includes/ui/settings.php CHANGED
@@ -84,7 +84,7 @@ defined( '\\ABSPATH' ) || exit;
84
  <li><?php esc_html_e( '100% WordPress API compliant', 'redis-cache' ); ?></li>
85
  <li><?php esc_html_e( 'Faster serialization and compression', 'redis-cache' ); ?></li>
86
  <li><?php esc_html_e( 'Easy debugging & logging', 'redis-cache' ); ?></li>
87
- <li><?php esc_html_e( 'Cache analytics and preloading', 'redis-cache' ); ?></li>
88
  <li><?php esc_html_e( 'Fully unit tested (100% code coverage)', 'redis-cache' ); ?></li>
89
  <li><?php esc_html_e( 'Secure connections with TLS', 'redis-cache' ); ?></li>
90
  <li><?php esc_html_e( 'Health checks via WordPress & WP CLI', 'redis-cache' ); ?></li>
84
  <li><?php esc_html_e( '100% WordPress API compliant', 'redis-cache' ); ?></li>
85
  <li><?php esc_html_e( 'Faster serialization and compression', 'redis-cache' ); ?></li>
86
  <li><?php esc_html_e( 'Easy debugging & logging', 'redis-cache' ); ?></li>
87
+ <li><?php esc_html_e( 'Cache prefetching and analytics', 'redis-cache' ); ?></li>
88
  <li><?php esc_html_e( 'Fully unit tested (100% code coverage)', 'redis-cache' ); ?></li>
89
  <li><?php esc_html_e( 'Secure connections with TLS', 'redis-cache' ); ?></li>
90
  <li><?php esc_html_e( 'Health checks via WordPress & WP CLI', 'redis-cache' ); ?></li>
languages/redis-cache.pot CHANGED
@@ -2,21 +2,21 @@
2
  # This file is distributed under the GPLv3.
3
  msgid ""
4
  msgstr ""
5
- "Project-Id-Version: Redis Object Cache 2.0.14\n"
6
  "Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/redis-cache\n"
7
  "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
8
  "Language-Team: LANGUAGE <LL@li.org>\n"
9
  "MIME-Version: 1.0\n"
10
  "Content-Type: text/plain; charset=UTF-8\n"
11
  "Content-Transfer-Encoding: 8bit\n"
12
- "POT-Creation-Date: 2020-09-24T23:36:57+00:00\n"
13
  "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
14
  "X-Generator: WP-CLI 2.4.0\n"
15
  "X-Domain: redis-cache\n"
16
 
17
  #. Plugin Name of the plugin
18
- #: includes/class-plugin.php:143
19
- #: includes/class-plugin.php:211
20
  #: includes/ui/settings.php:18
21
  msgid "Redis Object Cache"
22
  msgstr ""
@@ -37,181 +37,185 @@ msgstr ""
37
  msgid "https://objectcache.pro"
38
  msgstr ""
39
 
40
- #: includes/class-plugin.php:144
41
  msgid "Redis"
42
  msgstr ""
43
 
44
- #: includes/class-plugin.php:180
45
  #: includes/ui/tabs/overview.php:20
46
  msgid "Overview"
47
  msgstr ""
48
 
49
- #: includes/class-plugin.php:186
50
  msgid "Metrics"
51
  msgstr ""
52
 
53
- #: includes/class-plugin.php:192
54
  msgid "Diagnostics"
55
  msgstr ""
56
 
57
- #: includes/class-plugin.php:233
 
 
 
 
58
  msgid "Settings"
59
  msgstr ""
60
 
61
- #: includes/class-plugin.php:304
62
  #: includes/ui/tabs/metrics.php:17
63
  #: includes/ui/widget.php:16
64
  msgid "Time"
65
  msgstr ""
66
 
67
- #: includes/class-plugin.php:305
68
  #: includes/ui/tabs/metrics.php:22
69
  #: includes/ui/widget.php:21
70
  msgid "Bytes"
71
  msgstr ""
72
 
73
- #: includes/class-plugin.php:306
74
  #: includes/ui/tabs/metrics.php:27
75
  #: includes/ui/widget.php:26
76
  msgid "Ratio"
77
  msgstr ""
78
 
79
- #: includes/class-plugin.php:307
80
  #: includes/ui/tabs/metrics.php:32
81
  #: includes/ui/widget.php:31
82
  msgid "Calls"
83
  msgstr ""
84
 
85
- #: includes/class-plugin.php:308
86
  msgid "Not enough data collected, yet."
87
  msgstr ""
88
 
89
- #: includes/class-plugin.php:309
90
  msgid "Enable object cache to collect data."
91
  msgstr ""
92
 
93
- #: includes/class-plugin.php:453
94
  #: includes/class-qm-collector.php:66
95
  msgid "Disabled"
96
  msgstr ""
97
 
98
- #: includes/class-plugin.php:457
99
  msgid "Drop-in not installed"
100
  msgstr ""
101
 
102
- #: includes/class-plugin.php:461
103
  msgid "Drop-in is invalid"
104
  msgstr ""
105
 
106
- #: includes/class-plugin.php:466
107
  msgid "Connected"
108
  msgstr ""
109
 
110
- #: includes/class-plugin.php:467
111
  msgid "Not connected"
112
  msgstr ""
113
 
114
- #: includes/class-plugin.php:470
115
  #: includes/ui/tabs/overview.php:229
116
  msgid "Unknown"
117
  msgstr ""
118
 
119
  #. translators: %s = Action link to update the drop-in.
120
- #: includes/class-plugin.php:584
121
  msgid "The Redis object cache drop-in is outdated. Please <a href=\"%s\">update the drop-in</a>."
122
  msgstr ""
123
 
124
  #. translators: %s = Action link to update the drop-in.
125
- #: includes/class-plugin.php:588
126
  msgid "A foreign object cache drop-in was found. To use Redis for object caching, please <a href=\"%s\">enable the drop-in</a>."
127
  msgstr ""
128
 
129
- #: includes/class-plugin.php:624
130
  msgid "Object cache flushed."
131
  msgstr ""
132
 
133
- #: includes/class-plugin.php:630
134
  msgid "Object cache could not be flushed."
135
  msgstr ""
136
 
137
- #: includes/class-plugin.php:658
138
  #: includes/cli/class-commands.php:74
139
  msgid "Object cache enabled."
140
  msgstr ""
141
 
142
- #: includes/class-plugin.php:664
143
  #: includes/cli/class-commands.php:76
144
  msgid "Object cache could not be enabled."
145
  msgstr ""
146
 
147
- #: includes/class-plugin.php:684
148
  #: includes/cli/class-commands.php:113
149
  msgid "Object cache disabled."
150
  msgstr ""
151
 
152
- #: includes/class-plugin.php:690
153
  #: includes/cli/class-commands.php:115
154
  msgid "Object cache could not be disabled."
155
  msgstr ""
156
 
157
- #: includes/class-plugin.php:715
158
  #: includes/cli/class-commands.php:147
159
  msgid "Updated object cache drop-in and enabled Redis object cache."
160
  msgstr ""
161
 
162
- #: includes/class-plugin.php:721
163
  #: includes/cli/class-commands.php:149
164
  msgid "Object cache drop-in could not be updated."
165
  msgstr ""
166
 
167
- #: includes/class-plugin.php:788
168
  msgid "Object Cache Pro is out!"
169
  msgstr ""
170
 
171
  #. translators: %s = Link to the plugin setting screen.
172
- #: includes/class-plugin.php:791
173
  msgid "A <u>business class</u> object cache backend. Truly reliable, highly-optimized and fully customizable, with a <u>dedicated engineer</u> when you most need it. <a href=\"%s\">Learn more »</a>"
174
  msgstr ""
175
 
176
- #: includes/class-plugin.php:828
177
  msgid "Object Cache Pro + WooCommerce = ❤️"
178
  msgstr ""
179
 
180
  #. translators: %s = Link to the plugin's settings screen.
181
- #: includes/class-plugin.php:831
182
  msgid "Object Cache Pro is a <u>business class</u> object cache that’s highly-optimized for WooCommerce to provide true reliability, peace of mind and faster load times for your store. <a style=\"color: #bb77ae;\" href=\"%s\">Learn more »</a>"
183
  msgstr ""
184
 
185
  #. translators: %1$d = number of objects. %2$s = human-readable size of cache. %3$s = name of the used client.
186
- #: includes/class-plugin.php:970
187
  msgid "Retrieved %1$d objects (%2$s) from Redis using %3$s."
188
  msgstr ""
189
 
190
- #: includes/class-plugin.php:1040
191
  msgid "Could not initialize filesystem."
192
  msgstr ""
193
 
194
- #: includes/class-plugin.php:1047
195
  msgid "Object cache file doesn’t exist."
196
  msgstr ""
197
 
198
- #: includes/class-plugin.php:1052
199
  msgid "Test file exists, but couldn’t be deleted."
200
  msgstr ""
201
 
202
- #: includes/class-plugin.php:1057
203
  msgid "Failed to copy test file."
204
  msgstr ""
205
 
206
- #: includes/class-plugin.php:1061
207
  msgid "Copied test file doesn’t exist."
208
  msgstr ""
209
 
210
- #: includes/class-plugin.php:1067
211
  msgid "Couldn’t verify test file contents."
212
  msgstr ""
213
 
214
- #: includes/class-plugin.php:1071
215
  msgid "Copied test file couldn’t be deleted."
216
  msgstr ""
217
 
@@ -315,7 +319,7 @@ msgid "Easy debugging & logging"
315
  msgstr ""
316
 
317
  #: includes/ui/settings.php:87
318
- msgid "Cache analytics and preloading"
319
  msgstr ""
320
 
321
  #: includes/ui/settings.php:88
2
  # This file is distributed under the GPLv3.
3
  msgid ""
4
  msgstr ""
5
+ "Project-Id-Version: Redis Object Cache 2.0.16\n"
6
  "Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/redis-cache\n"
7
  "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
8
  "Language-Team: LANGUAGE <LL@li.org>\n"
9
  "MIME-Version: 1.0\n"
10
  "Content-Type: text/plain; charset=UTF-8\n"
11
  "Content-Transfer-Encoding: 8bit\n"
12
+ "POT-Creation-Date: 2020-12-25T02:24:58+00:00\n"
13
  "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
14
  "X-Generator: WP-CLI 2.4.0\n"
15
  "X-Domain: redis-cache\n"
16
 
17
  #. Plugin Name of the plugin
18
+ #: includes/class-plugin.php:142
19
+ #: includes/class-plugin.php:210
20
  #: includes/ui/settings.php:18
21
  msgid "Redis Object Cache"
22
  msgstr ""
37
  msgid "https://objectcache.pro"
38
  msgstr ""
39
 
40
+ #: includes/class-plugin.php:143
41
  msgid "Redis"
42
  msgstr ""
43
 
44
+ #: includes/class-plugin.php:179
45
  #: includes/ui/tabs/overview.php:20
46
  msgid "Overview"
47
  msgstr ""
48
 
49
+ #: includes/class-plugin.php:185
50
  msgid "Metrics"
51
  msgstr ""
52
 
53
+ #: includes/class-plugin.php:191
54
  msgid "Diagnostics"
55
  msgstr ""
56
 
57
+ #: includes/class-plugin.php:234
58
+ msgid "Upgrade"
59
+ msgstr ""
60
+
61
+ #: includes/class-plugin.php:240
62
  msgid "Settings"
63
  msgstr ""
64
 
65
+ #: includes/class-plugin.php:312
66
  #: includes/ui/tabs/metrics.php:17
67
  #: includes/ui/widget.php:16
68
  msgid "Time"
69
  msgstr ""
70
 
71
+ #: includes/class-plugin.php:313
72
  #: includes/ui/tabs/metrics.php:22
73
  #: includes/ui/widget.php:21
74
  msgid "Bytes"
75
  msgstr ""
76
 
77
+ #: includes/class-plugin.php:314
78
  #: includes/ui/tabs/metrics.php:27
79
  #: includes/ui/widget.php:26
80
  msgid "Ratio"
81
  msgstr ""
82
 
83
+ #: includes/class-plugin.php:315
84
  #: includes/ui/tabs/metrics.php:32
85
  #: includes/ui/widget.php:31
86
  msgid "Calls"
87
  msgstr ""
88
 
89
+ #: includes/class-plugin.php:316
90
  msgid "Not enough data collected, yet."
91
  msgstr ""
92
 
93
+ #: includes/class-plugin.php:317
94
  msgid "Enable object cache to collect data."
95
  msgstr ""
96
 
97
+ #: includes/class-plugin.php:459
98
  #: includes/class-qm-collector.php:66
99
  msgid "Disabled"
100
  msgstr ""
101
 
102
+ #: includes/class-plugin.php:463
103
  msgid "Drop-in not installed"
104
  msgstr ""
105
 
106
+ #: includes/class-plugin.php:467
107
  msgid "Drop-in is invalid"
108
  msgstr ""
109
 
110
+ #: includes/class-plugin.php:472
111
  msgid "Connected"
112
  msgstr ""
113
 
114
+ #: includes/class-plugin.php:473
115
  msgid "Not connected"
116
  msgstr ""
117
 
118
+ #: includes/class-plugin.php:476
119
  #: includes/ui/tabs/overview.php:229
120
  msgid "Unknown"
121
  msgstr ""
122
 
123
  #. translators: %s = Action link to update the drop-in.
124
+ #: includes/class-plugin.php:595
125
  msgid "The Redis object cache drop-in is outdated. Please <a href=\"%s\">update the drop-in</a>."
126
  msgstr ""
127
 
128
  #. translators: %s = Action link to update the drop-in.
129
+ #: includes/class-plugin.php:599
130
  msgid "A foreign object cache drop-in was found. To use Redis for object caching, please <a href=\"%s\">enable the drop-in</a>."
131
  msgstr ""
132
 
133
+ #: includes/class-plugin.php:635
134
  msgid "Object cache flushed."
135
  msgstr ""
136
 
137
+ #: includes/class-plugin.php:641
138
  msgid "Object cache could not be flushed."
139
  msgstr ""
140
 
141
+ #: includes/class-plugin.php:669
142
  #: includes/cli/class-commands.php:74
143
  msgid "Object cache enabled."
144
  msgstr ""
145
 
146
+ #: includes/class-plugin.php:675
147
  #: includes/cli/class-commands.php:76
148
  msgid "Object cache could not be enabled."
149
  msgstr ""
150
 
151
+ #: includes/class-plugin.php:695
152
  #: includes/cli/class-commands.php:113
153
  msgid "Object cache disabled."
154
  msgstr ""
155
 
156
+ #: includes/class-plugin.php:701
157
  #: includes/cli/class-commands.php:115
158
  msgid "Object cache could not be disabled."
159
  msgstr ""
160
 
161
+ #: includes/class-plugin.php:726
162
  #: includes/cli/class-commands.php:147
163
  msgid "Updated object cache drop-in and enabled Redis object cache."
164
  msgstr ""
165
 
166
+ #: includes/class-plugin.php:732
167
  #: includes/cli/class-commands.php:149
168
  msgid "Object cache drop-in could not be updated."
169
  msgstr ""
170
 
171
+ #: includes/class-plugin.php:799
172
  msgid "Object Cache Pro is out!"
173
  msgstr ""
174
 
175
  #. translators: %s = Link to the plugin setting screen.
176
+ #: includes/class-plugin.php:802
177
  msgid "A <u>business class</u> object cache backend. Truly reliable, highly-optimized and fully customizable, with a <u>dedicated engineer</u> when you most need it. <a href=\"%s\">Learn more »</a>"
178
  msgstr ""
179
 
180
+ #: includes/class-plugin.php:839
181
  msgid "Object Cache Pro + WooCommerce = ❤️"
182
  msgstr ""
183
 
184
  #. translators: %s = Link to the plugin's settings screen.
185
+ #: includes/class-plugin.php:842
186
  msgid "Object Cache Pro is a <u>business class</u> object cache that’s highly-optimized for WooCommerce to provide true reliability, peace of mind and faster load times for your store. <a style=\"color: #bb77ae;\" href=\"%s\">Learn more »</a>"
187
  msgstr ""
188
 
189
  #. translators: %1$d = number of objects. %2$s = human-readable size of cache. %3$s = name of the used client.
190
+ #: includes/class-plugin.php:907
191
  msgid "Retrieved %1$d objects (%2$s) from Redis using %3$s."
192
  msgstr ""
193
 
194
+ #: includes/class-plugin.php:964
195
  msgid "Could not initialize filesystem."
196
  msgstr ""
197
 
198
+ #: includes/class-plugin.php:971
199
  msgid "Object cache file doesn’t exist."
200
  msgstr ""
201
 
202
+ #: includes/class-plugin.php:976
203
  msgid "Test file exists, but couldn’t be deleted."
204
  msgstr ""
205
 
206
+ #: includes/class-plugin.php:981
207
  msgid "Failed to copy test file."
208
  msgstr ""
209
 
210
+ #: includes/class-plugin.php:985
211
  msgid "Copied test file doesn’t exist."
212
  msgstr ""
213
 
214
+ #: includes/class-plugin.php:991
215
  msgid "Couldn’t verify test file contents."
216
  msgstr ""
217
 
218
+ #: includes/class-plugin.php:995
219
  msgid "Copied test file couldn’t be deleted."
220
  msgstr ""
221
 
319
  msgstr ""
320
 
321
  #: includes/ui/settings.php:87
322
+ msgid "Cache prefetching and analytics"
323
  msgstr ""
324
 
325
  #: includes/ui/settings.php:88
readme.txt CHANGED
@@ -5,7 +5,7 @@ Tags: redis, predis, phpredis, credis, hhvm, pecl, caching, cache, object cache,
5
  Requires at least: 3.3
6
  Tested up to: 5.6
7
  Requires PHP: 5.6
8
- Stable tag: 2.0.15
9
  License: GPLv3
10
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
11
 
@@ -26,7 +26,7 @@ A **business class** Redis object cache backend. Truly reliable, highly optimize
26
  * 100% WordPress API compliant
27
  * Faster serialization and compression
28
  * Easy debugging & logging
29
- * Cache analytics and preloading
30
  * Fully unit tested (100% code coverage)
31
  * Secure connections with TLS
32
  * Health checks via WordPress & WP CLI
@@ -83,6 +83,16 @@ To see a list of all available WP-CLI commands, please see the [WP CLI commands
83
 
84
  == Changelog ==
85
 
 
 
 
 
 
 
 
 
 
 
86
  = 2.0.15 =
87
 
88
  - Reverted `build_key()` changes due to issues in multisite environments
@@ -474,6 +484,6 @@ Since Predis isn't maintained any longer, it's highly recommended to switch over
474
 
475
  == Upgrade Notice ==
476
 
477
- = 2.0.15 =
478
 
479
  Version 2.0 is a significant rewrite of the plugin. Please read the v2.0.0 release notes.
5
  Requires at least: 3.3
6
  Tested up to: 5.6
7
  Requires PHP: 5.6
8
+ Stable tag: 2.0.16
9
  License: GPLv3
10
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
11
 
26
  * 100% WordPress API compliant
27
  * Faster serialization and compression
28
  * Easy debugging & logging
29
+ * Cache prefetching and analytics
30
  * Fully unit tested (100% code coverage)
31
  * Secure connections with TLS
32
  * Health checks via WordPress & WP CLI
83
 
84
  == Changelog ==
85
 
86
+ = 2.0.16 =
87
+
88
+ - Updated Credis to v1.11.4
89
+ - Fixed drop-in notice styling
90
+ - Moved metrics into dedicated class
91
+ - Added `redis_cache_validate_dropin` filter
92
+ - Use `WP_DEBUG_DISPLAY` (instead of `WP_DEBUG`) constant to display debug information
93
+ - Fixed rare error in `wp_cache_get_multiple()`
94
+ - Removed `intval()` usage
95
+
96
  = 2.0.15 =
97
 
98
  - Reverted `build_key()` changes due to issues in multisite environments
484
 
485
  == Upgrade Notice ==
486
 
487
+ = 2.0.16 =
488
 
489
  Version 2.0 is a significant rewrite of the plugin. Please read the v2.0.0 release notes.
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, Credis, HHVM, replication, clustering and WP-CLI.
6
- * Version: 2.0.15
7
  * Text Domain: redis-cache
8
  * Domain Path: /languages
9
  * Network: true
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, Credis, HHVM, replication, clustering and WP-CLI.
6
+ * Version: 2.0.16
7
  * Text Domain: redis-cache
8
  * Domain Path: /languages
9
  * Network: true