Version Description
- Removed broken
wp_cache_add_multiple()
function
Download this release
Release Info
Developer | tillkruess |
Plugin | Redis Object Cache |
Version | 2.0.25 |
Comparing to | |
See all releases |
Code changes from version 2.0.23 to 2.0.25
- assets/css/admin.css +1 -2
- assets/js/admin.js +9 -3
- dependencies/colinmollenhour/credis/.travis.yml +0 -44
- dependencies/colinmollenhour/credis/Client.php +52 -11
- dependencies/colinmollenhour/credis/README.markdown +1 -1
- dependencies/colinmollenhour/credis/composer.json +27 -0
- dependencies/colinmollenhour/credis/phpunit.xml +0 -17
- dependencies/colinmollenhour/credis/testenv/docker-compose.yml +32 -0
- dependencies/colinmollenhour/credis/tests/CredisClusterTest.php +0 -215
- dependencies/colinmollenhour/credis/tests/CredisSentinelTest.php +0 -225
- dependencies/colinmollenhour/credis/tests/CredisStandaloneClusterTest.php +0 -30
- dependencies/colinmollenhour/credis/tests/CredisStandaloneSentinelTest.php +0 -8
- dependencies/colinmollenhour/credis/tests/CredisStandaloneTest.php +0 -44
- dependencies/colinmollenhour/credis/tests/CredisTest.php +0 -780
- dependencies/colinmollenhour/credis/tests/CredisTestCommon.php +0 -170
- dependencies/colinmollenhour/credis/tests/keys.test +0 -100
- dependencies/colinmollenhour/credis/tests/redis-2.conf +0 -5
- dependencies/colinmollenhour/credis/tests/redis-3.conf +0 -5
- dependencies/colinmollenhour/credis/tests/redis-4.conf +0 -5
- dependencies/colinmollenhour/credis/tests/redis-auth.conf +0 -6
- dependencies/colinmollenhour/credis/tests/redis-master.conf +0 -8
- dependencies/colinmollenhour/credis/tests/redis-sentinel.conf +0 -6
- dependencies/colinmollenhour/credis/tests/redis-slave.conf +0 -7
- dependencies/colinmollenhour/credis/tests/redis-socket.conf +0 -6
- dependencies/colinmollenhour/credis/tests/redis_config.json +0 -9
- dependencies/colinmollenhour/credis/tests/sentinel_config.json +0 -1
- dependencies/predis/predis/CHANGELOG.md +10 -2
- dependencies/predis/predis/VERSION +1 -1
- dependencies/predis/predis/composer.json +48 -0
- dependencies/predis/predis/package.ini +1 -1
- dependencies/predis/predis/src/Client.php +1 -1
- dependencies/predis/predis/src/Connection/Aggregate/SentinelReplication.php +6 -1
- dependencies/predis/predis/src/Session/Handler.php +6 -0
- includes/class-plugin.php +9 -5
- includes/object-cache.php +181 -2
- languages/redis-cache.pot +45 -47
- readme.txt +21 -4
- redis-cache.php +1 -1
assets/css/admin.css
CHANGED
@@ -170,6 +170,7 @@
|
|
170 |
border: none;
|
171 |
box-shadow: none;
|
172 |
background: #fff;
|
|
|
173 |
}
|
174 |
|
175 |
#redis-stats-chart .apexcharts-tooltip-title {
|
@@ -177,8 +178,6 @@
|
|
177 |
padding: 0 15px;
|
178 |
border-bottom: none;
|
179 |
background-color: transparent;
|
180 |
-
font-weight: bold;
|
181 |
-
font-variant-numeric: tabular-nums;
|
182 |
}
|
183 |
|
184 |
#redis-stats-chart .apexcharts-tooltip-series-group {
|
170 |
border: none;
|
171 |
box-shadow: none;
|
172 |
background: #fff;
|
173 |
+
margin-top: 1px;
|
174 |
}
|
175 |
|
176 |
#redis-stats-chart .apexcharts-tooltip-title {
|
178 |
padding: 0 15px;
|
179 |
border-bottom: none;
|
180 |
background-color: transparent;
|
|
|
|
|
181 |
}
|
182 |
|
183 |
#redis-stats-chart .apexcharts-tooltip-series-group {
|
assets/js/admin.js
CHANGED
@@ -148,12 +148,18 @@
|
|
148 |
yaxis: {
|
149 |
labels: {
|
150 |
formatter: function ( value ) {
|
151 |
-
|
|
|
|
|
152 |
},
|
153 |
},
|
154 |
},
|
155 |
tooltip: {
|
156 |
custom: function ({ series, seriesIndex, dataPointIndex, w }) {
|
|
|
|
|
|
|
|
|
157 |
return [
|
158 |
rediscache.templates.tooltip_title({
|
159 |
title: new Date( w.globals.seriesX[ seriesIndex ][ dataPointIndex ] ).toTimeString().slice( 0, 5 ),
|
@@ -161,7 +167,7 @@
|
|
161 |
rediscache.templates.series_group({
|
162 |
color: rediscache.chart_defaults.colors[0],
|
163 |
name: w.globals.seriesNames[0],
|
164 |
-
value:
|
165 |
}),
|
166 |
rediscache.templates.series_pro({
|
167 |
color: rediscache.chart_defaults.colors[1],
|
@@ -385,7 +391,7 @@
|
|
385 |
}
|
386 |
);
|
387 |
|
388 |
-
var firstRender =
|
389 |
|
390 |
var show_tab = function ( name ) {
|
391 |
$tabs.find( '.nav-tab-active' ).removeClass( 'nav-tab-active' );
|
148 |
yaxis: {
|
149 |
labels: {
|
150 |
formatter: function ( value ) {
|
151 |
+
var i = value === 0 ? 0 : Math.floor( Math.log( value ) / Math.log( 1024 ) );
|
152 |
+
|
153 |
+
return parseFloat( (value / Math.pow( 1024, i ) ).toFixed( i ? 2 : 0 ) ) + ' ' + ['B', 'KB', 'MB', 'GB', 'TB'][i];
|
154 |
},
|
155 |
},
|
156 |
},
|
157 |
tooltip: {
|
158 |
custom: function ({ series, seriesIndex, dataPointIndex, w }) {
|
159 |
+
var value = series[0][ dataPointIndex ];
|
160 |
+
var i = value === 0 ? 0 : Math.floor( Math.log( value ) / Math.log( 1024 ) );
|
161 |
+
var bytes = parseFloat( (value / Math.pow( 1024, i ) ).toFixed( i ? 2 : 0 ) ) + ' ' + ['B', 'KB', 'MB', 'GB', 'TB'][i];
|
162 |
+
|
163 |
return [
|
164 |
rediscache.templates.tooltip_title({
|
165 |
title: new Date( w.globals.seriesX[ seriesIndex ][ dataPointIndex ] ).toTimeString().slice( 0, 5 ),
|
167 |
rediscache.templates.series_group({
|
168 |
color: rediscache.chart_defaults.colors[0],
|
169 |
name: w.globals.seriesNames[0],
|
170 |
+
value: bytes,
|
171 |
}),
|
172 |
rediscache.templates.series_pro({
|
173 |
color: rediscache.chart_defaults.colors[1],
|
391 |
}
|
392 |
);
|
393 |
|
394 |
+
var firstRender = window.location.hash.indexOf('metrics') === -1;
|
395 |
|
396 |
var show_tab = function ( name ) {
|
397 |
$tabs.find( '.nav-tab-active' ).removeClass( 'nav-tab-active' );
|
dependencies/colinmollenhour/credis/.travis.yml
DELETED
@@ -1,44 +0,0 @@
|
|
1 |
-
language: php
|
2 |
-
|
3 |
-
matrix:
|
4 |
-
include:
|
5 |
-
- php: 5.6
|
6 |
-
env:
|
7 |
-
- PHPREDIS_VERSION=redis-4.3.0
|
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
|
40 |
-
composer install --dev -n
|
41 |
-
fi
|
42 |
-
|
43 |
-
script:
|
44 |
-
- vendor/bin/phpunit
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
dependencies/colinmollenhour/credis/Client.php
CHANGED
@@ -56,6 +56,7 @@ class CredisException extends Exception
|
|
56 |
* @method bool|array|Credis_Client config(string $setGet, string $key, string $value = null)
|
57 |
* @method array|Credis_Client role()
|
58 |
* @method array|Credis_Client time()
|
|
|
59 |
*
|
60 |
* Keys:
|
61 |
* @method int|Credis_Client del(string $key)
|
@@ -200,7 +201,7 @@ class Credis_Client {
|
|
200 |
|
201 |
/**
|
202 |
* Port on which the Redis server is running
|
203 |
-
* @var integer
|
204 |
*/
|
205 |
protected $port;
|
206 |
|
@@ -272,6 +273,11 @@ class Credis_Client {
|
|
272 |
*/
|
273 |
protected $isWatching = FALSE;
|
274 |
|
|
|
|
|
|
|
|
|
|
|
275 |
/**
|
276 |
* @var string
|
277 |
*/
|
@@ -314,8 +320,9 @@ class Credis_Client {
|
|
314 |
* @param string $persistent Flag to establish persistent connection
|
315 |
* @param int $db The selected datbase of the Redis server
|
316 |
* @param string $password The authentication password of the Redis server
|
|
|
317 |
*/
|
318 |
-
public function __construct($host = '127.0.0.1', $port = 6379, $timeout = null, $persistent = '', $db = 0, $password = null)
|
319 |
{
|
320 |
$this->host = (string) $host;
|
321 |
$this->port = (int) $port;
|
@@ -324,10 +331,15 @@ class Credis_Client {
|
|
324 |
$this->persistent = (string) $persistent;
|
325 |
$this->standalone = ! extension_loaded('redis');
|
326 |
$this->authPassword = $password;
|
|
|
327 |
$this->selectedDb = (int)$db;
|
328 |
$this->convertHost();
|
329 |
-
// PHP Redis extension support TLS since 5.3.0
|
330 |
-
if (
|
|
|
|
|
|
|
|
|
331 |
$this->standalone = true;
|
332 |
}
|
333 |
}
|
@@ -357,7 +369,7 @@ class Credis_Client {
|
|
357 |
}
|
358 |
/**
|
359 |
* Return the port of the Redis instance
|
360 |
-
* @return int
|
361 |
*/
|
362 |
public function getPort()
|
363 |
{
|
@@ -473,8 +485,8 @@ class Credis_Client {
|
|
473 |
try
|
474 |
{
|
475 |
$result = $this->persistent
|
476 |
-
? $this->redis->pconnect($this->host, $this->port, $socketTimeout, $this->persistent)
|
477 |
-
: $this->redis->connect($this->host, $this->port, $socketTimeout);
|
478 |
}
|
479 |
catch(Exception $e)
|
480 |
{
|
@@ -503,9 +515,8 @@ class Credis_Client {
|
|
503 |
if ($this->readTimeout) {
|
504 |
$this->setReadTimeout($this->readTimeout);
|
505 |
}
|
506 |
-
|
507 |
if($this->authPassword) {
|
508 |
-
$this->auth($this->authPassword);
|
509 |
}
|
510 |
if($this->selectedDb !== 0) {
|
511 |
$this->select($this->selectedDb);
|
@@ -640,11 +651,17 @@ class Credis_Client {
|
|
640 |
|
641 |
/**
|
642 |
* @param string $password
|
|
|
643 |
* @return bool
|
644 |
*/
|
645 |
-
public function auth($password)
|
646 |
{
|
647 |
-
$
|
|
|
|
|
|
|
|
|
|
|
648 |
$this->authPassword = $password;
|
649 |
return $response;
|
650 |
}
|
@@ -808,6 +825,25 @@ class Credis_Client {
|
|
808 |
return $this->__call('ping', $name ? array($name) : array());
|
809 |
}
|
810 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
811 |
public function __call($name, $args)
|
812 |
{
|
813 |
// Lazy connection
|
@@ -1130,6 +1166,10 @@ class Credis_Client {
|
|
1130 |
// allow phpredis to see the caller's reference
|
1131 |
//$param_ref =& $args[0];
|
1132 |
break;
|
|
|
|
|
|
|
|
|
1133 |
default:
|
1134 |
// Flatten arguments
|
1135 |
$args = self::_flattenArguments($args);
|
@@ -1165,6 +1205,7 @@ class Credis_Client {
|
|
1165 |
return $this;
|
1166 |
}
|
1167 |
|
|
|
1168 |
// Send request, retry one time when using persistent connections on the first request only
|
1169 |
$this->requests++;
|
1170 |
try {
|
56 |
* @method bool|array|Credis_Client config(string $setGet, string $key, string $value = null)
|
57 |
* @method array|Credis_Client role()
|
58 |
* @method array|Credis_Client time()
|
59 |
+
* @method int|Credis_Client dbsize()
|
60 |
*
|
61 |
* Keys:
|
62 |
* @method int|Credis_Client del(string $key)
|
201 |
|
202 |
/**
|
203 |
* Port on which the Redis server is running
|
204 |
+
* @var integer|null
|
205 |
*/
|
206 |
protected $port;
|
207 |
|
273 |
*/
|
274 |
protected $isWatching = FALSE;
|
275 |
|
276 |
+
/**
|
277 |
+
* @var string
|
278 |
+
*/
|
279 |
+
protected $authUsername;
|
280 |
+
|
281 |
/**
|
282 |
* @var string
|
283 |
*/
|
320 |
* @param string $persistent Flag to establish persistent connection
|
321 |
* @param int $db The selected datbase of the Redis server
|
322 |
* @param string $password The authentication password of the Redis server
|
323 |
+
* @param string $username The authentication username of the Redis server
|
324 |
*/
|
325 |
+
public function __construct($host = '127.0.0.1', $port = 6379, $timeout = null, $persistent = '', $db = 0, $password = null, $username = null)
|
326 |
{
|
327 |
$this->host = (string) $host;
|
328 |
$this->port = (int) $port;
|
331 |
$this->persistent = (string) $persistent;
|
332 |
$this->standalone = ! extension_loaded('redis');
|
333 |
$this->authPassword = $password;
|
334 |
+
$this->authUsername = $username;
|
335 |
$this->selectedDb = (int)$db;
|
336 |
$this->convertHost();
|
337 |
+
// PHP Redis extension support TLS/ACL AUTH since 5.3.0
|
338 |
+
if ((
|
339 |
+
$this->scheme === 'tls'
|
340 |
+
|| $this->authUsername !== null
|
341 |
+
)
|
342 |
+
&& !$this->standalone && version_compare(phpversion('redis'),'5.3.0','<')){
|
343 |
$this->standalone = true;
|
344 |
}
|
345 |
}
|
369 |
}
|
370 |
/**
|
371 |
* Return the port of the Redis instance
|
372 |
+
* @return int|null
|
373 |
*/
|
374 |
public function getPort()
|
375 |
{
|
485 |
try
|
486 |
{
|
487 |
$result = $this->persistent
|
488 |
+
? $this->redis->pconnect($this->host, (int)$this->port, $socketTimeout, $this->persistent)
|
489 |
+
: $this->redis->connect($this->host, (int)$this->port, $socketTimeout);
|
490 |
}
|
491 |
catch(Exception $e)
|
492 |
{
|
515 |
if ($this->readTimeout) {
|
516 |
$this->setReadTimeout($this->readTimeout);
|
517 |
}
|
|
|
518 |
if($this->authPassword) {
|
519 |
+
$this->auth($this->authPassword, $this->authUsername);
|
520 |
}
|
521 |
if($this->selectedDb !== 0) {
|
522 |
$this->select($this->selectedDb);
|
651 |
|
652 |
/**
|
653 |
* @param string $password
|
654 |
+
* @param string|null $username
|
655 |
* @return bool
|
656 |
*/
|
657 |
+
public function auth($password, $username = null)
|
658 |
{
|
659 |
+
if ($username !== null) {
|
660 |
+
$response = $this->__call('auth', array($username, $password));
|
661 |
+
$this->authUsername= $username;
|
662 |
+
} else {
|
663 |
+
$response = $this->__call('auth', array($password));
|
664 |
+
}
|
665 |
$this->authPassword = $password;
|
666 |
return $response;
|
667 |
}
|
825 |
return $this->__call('ping', $name ? array($name) : array());
|
826 |
}
|
827 |
|
828 |
+
/**
|
829 |
+
* @param string $command
|
830 |
+
* @param array $args
|
831 |
+
*
|
832 |
+
* @return array|Credis_Client
|
833 |
+
*/
|
834 |
+
public function rawCommand($command, array $args)
|
835 |
+
{
|
836 |
+
if($this->standalone)
|
837 |
+
{
|
838 |
+
return $this->__call($command, $args);
|
839 |
+
}
|
840 |
+
else
|
841 |
+
{
|
842 |
+
\array_unshift($args, $command);
|
843 |
+
return $this->__call('rawCommand', $args);
|
844 |
+
}
|
845 |
+
}
|
846 |
+
|
847 |
public function __call($name, $args)
|
848 |
{
|
849 |
// Lazy connection
|
1166 |
// allow phpredis to see the caller's reference
|
1167 |
//$param_ref =& $args[0];
|
1168 |
break;
|
1169 |
+
case 'auth':
|
1170 |
+
// For phpredis pre-v5.3, the type signature is string, not array|string
|
1171 |
+
$args = (is_array($args) && count($args) === 1) ? $args : array($args);
|
1172 |
+
break;
|
1173 |
default:
|
1174 |
// Flatten arguments
|
1175 |
$args = self::_flattenArguments($args);
|
1205 |
return $this;
|
1206 |
}
|
1207 |
|
1208 |
+
|
1209 |
// Send request, retry one time when using persistent connections on the first request only
|
1210 |
$this->requests++;
|
1211 |
try {
|
dependencies/colinmollenhour/credis/README.markdown
CHANGED
@@ -1,4 +1,4 @@
|
|
1 |
-
|
2 |
|
3 |
# Credis
|
4 |
|
1 |
+
![Build Status](https://github.com/colinmollenhour/credis/actions/workflows/ci.yml/badge.svg)
|
2 |
|
3 |
# Credis
|
4 |
|
dependencies/colinmollenhour/credis/composer.json
ADDED
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"name": "colinmollenhour/credis",
|
3 |
+
"type": "library",
|
4 |
+
"description": "Credis is a lightweight interface to the Redis key-value store which wraps the phpredis library when available for better performance.",
|
5 |
+
"homepage": "https://github.com/colinmollenhour/credis",
|
6 |
+
"license": "MIT",
|
7 |
+
"authors": [
|
8 |
+
{
|
9 |
+
"name": "Colin Mollenhour",
|
10 |
+
"email": "colin@mollenhour.com"
|
11 |
+
}
|
12 |
+
],
|
13 |
+
"require": {
|
14 |
+
"php": ">=5.6.0"
|
15 |
+
},
|
16 |
+
"suggest": {
|
17 |
+
"ext-redis": "Improved performance for communicating with redis"
|
18 |
+
},
|
19 |
+
"autoload": {
|
20 |
+
"classmap": [
|
21 |
+
"Client.php",
|
22 |
+
"Cluster.php",
|
23 |
+
"Sentinel.php",
|
24 |
+
"Module.php"
|
25 |
+
]
|
26 |
+
}
|
27 |
+
}
|
dependencies/colinmollenhour/credis/phpunit.xml
DELETED
@@ -1,17 +0,0 @@
|
|
1 |
-
<?xml version="1.0"?>
|
2 |
-
<phpunit colors="true" verbose="true">
|
3 |
-
<testsuites>
|
4 |
-
<testsuite name="Basic">
|
5 |
-
<file>tests/CredisTest.php</file>
|
6 |
-
<file>tests/CredisStandaloneTest.php</file>
|
7 |
-
</testsuite>
|
8 |
-
<testsuite name="Cluster">
|
9 |
-
<file>tests/CredisClusterTest.php</file>
|
10 |
-
<file>tests/CredisStandaloneClusterTest.php</file>
|
11 |
-
</testsuite>
|
12 |
-
<testsuite name="Sentinel">
|
13 |
-
<file>tests/CredisSentinelTest.php</file>
|
14 |
-
<file>tests/CredisStandaloneSentinelTest.php</file>
|
15 |
-
</testsuite>
|
16 |
-
</testsuites>
|
17 |
-
</phpunit>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
dependencies/colinmollenhour/credis/testenv/docker-compose.yml
ADDED
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
version: '2'
|
2 |
+
services:
|
3 |
+
|
4 |
+
php-56:
|
5 |
+
build: env/php-5.6/
|
6 |
+
volumes:
|
7 |
+
- ../:/src/
|
8 |
+
|
9 |
+
php-70:
|
10 |
+
build: env/php-7.0/
|
11 |
+
volumes:
|
12 |
+
- ../:/src/
|
13 |
+
|
14 |
+
php-71:
|
15 |
+
build: env/php-7.1/
|
16 |
+
volumes:
|
17 |
+
- ../:/src/
|
18 |
+
|
19 |
+
php-72:
|
20 |
+
build: env/php-7.2/
|
21 |
+
volumes:
|
22 |
+
- ../:/src/
|
23 |
+
|
24 |
+
php-73:
|
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/tests/CredisClusterTest.php
DELETED
@@ -1,215 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
require_once dirname(__FILE__).'/../Client.php';
|
4 |
-
require_once dirname(__FILE__).'/../Cluster.php';
|
5 |
-
require_once dirname(__FILE__).'/CredisTestCommon.php';
|
6 |
-
|
7 |
-
class CredisClusterTest extends CredisTestCommon
|
8 |
-
{
|
9 |
-
/** @var Credis_Cluster */
|
10 |
-
protected $cluster;
|
11 |
-
|
12 |
-
protected function setUp()
|
13 |
-
{
|
14 |
-
parent::setUp();
|
15 |
-
|
16 |
-
$clients = array_slice($this->redisConfig,0,4);
|
17 |
-
$this->cluster = new Credis_Cluster($clients,2,$this->useStandalone);
|
18 |
-
}
|
19 |
-
|
20 |
-
protected function tearDown()
|
21 |
-
{
|
22 |
-
if($this->cluster) {
|
23 |
-
$this->cluster->flushAll();
|
24 |
-
foreach($this->cluster->clients() as $client){
|
25 |
-
if($client->isConnected()) {
|
26 |
-
$client->close();
|
27 |
-
}
|
28 |
-
}
|
29 |
-
$this->cluster = NULL;
|
30 |
-
}
|
31 |
-
}
|
32 |
-
|
33 |
-
public function testKeyHashing()
|
34 |
-
{
|
35 |
-
$this->tearDown();
|
36 |
-
$this->cluster = new Credis_Cluster(array_slice($this->redisConfig, 0, 3), 2, $this->useStandalone);
|
37 |
-
$keys = array();
|
38 |
-
$lines = explode("\n", file_get_contents("keys.test"));
|
39 |
-
foreach ($lines as $line) {
|
40 |
-
$pair = explode(':', trim($line));
|
41 |
-
if (count($pair) >= 2) {
|
42 |
-
$keys[$pair[0]] = $pair[1];
|
43 |
-
}
|
44 |
-
}
|
45 |
-
foreach ($keys as $key => $value) {
|
46 |
-
$this->assertTrue($this->cluster->set($key, $value));
|
47 |
-
}
|
48 |
-
$this->cluster = new Credis_Cluster(array_slice($this->redisConfig, 0, 4), 2, true, $this->useStandalone);
|
49 |
-
$hits = 0;
|
50 |
-
foreach ($keys as $key => $value) {
|
51 |
-
if ($this->cluster->all('get',$key)) {
|
52 |
-
$hits++;
|
53 |
-
}
|
54 |
-
}
|
55 |
-
$this->assertEquals(count($keys),$hits);
|
56 |
-
}
|
57 |
-
public function testAlias()
|
58 |
-
{
|
59 |
-
$slicedConfig = array_slice($this->redisConfig, 0, 4);
|
60 |
-
foreach($slicedConfig as $config) {
|
61 |
-
$this->assertEquals($config['port'],$this->cluster->client($config['alias'])->getPort());
|
62 |
-
}
|
63 |
-
foreach($slicedConfig as $offset => $config) {
|
64 |
-
$this->assertEquals($config['port'],$this->cluster->client($offset)->getPort());
|
65 |
-
}
|
66 |
-
$alias = "non-existent-alias";
|
67 |
-
$this->setExpectedExceptionShim('CredisException',"Client $alias does not exist.");
|
68 |
-
$this->cluster->client($alias);
|
69 |
-
}
|
70 |
-
public function testMasterSlave()
|
71 |
-
{
|
72 |
-
$this->tearDown();
|
73 |
-
$this->cluster = new Credis_Cluster(array($this->redisConfig[0],$this->redisConfig[6]), 2, $this->useStandalone);
|
74 |
-
$this->assertTrue($this->cluster->client('master')->set('key','value'));
|
75 |
-
$this->waitForSlaveReplication();
|
76 |
-
$this->assertEquals('value',$this->cluster->client('slave')->get('key'));
|
77 |
-
$this->assertEquals('value',$this->cluster->get('key'));
|
78 |
-
try
|
79 |
-
{
|
80 |
-
$this->cluster->client('slave')->set('key2', 'value');
|
81 |
-
$this->fail('Writing to readonly slave');
|
82 |
-
}
|
83 |
-
catch(CredisException $e)
|
84 |
-
{
|
85 |
-
}
|
86 |
-
|
87 |
-
$this->tearDown();
|
88 |
-
$writeOnlyConfig = $this->redisConfig[0];
|
89 |
-
$writeOnlyConfig['write_only'] = true;
|
90 |
-
$this->cluster = new Credis_Cluster(array($writeOnlyConfig,$this->redisConfig[6]), 2, $this->useStandalone);
|
91 |
-
$this->assertTrue($this->cluster->client('master')->set('key','value'));
|
92 |
-
$this->waitForSlaveReplication();
|
93 |
-
$this->assertEquals('value',$this->cluster->client('slave')->get('key'));
|
94 |
-
$this->assertEquals('value',$this->cluster->get('key'));
|
95 |
-
$this->setExpectedExceptionShim('CredisException');
|
96 |
-
$this->assertFalse($this->cluster->client('slave')->set('key2','value'));
|
97 |
-
}
|
98 |
-
public function testMasterWithoutSlavesAndWriteOnlyFlag()
|
99 |
-
{
|
100 |
-
$this->tearDown();
|
101 |
-
$writeOnlyConfig = $this->redisConfig[0];
|
102 |
-
$writeOnlyConfig['write_only'] = true;
|
103 |
-
$this->cluster = new Credis_Cluster(array($writeOnlyConfig),2,$this->useStandalone);
|
104 |
-
$this->assertTrue($this->cluster->set('key','value'));
|
105 |
-
$this->assertEquals('value',$this->cluster->get('key'));
|
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 |
-
{
|
117 |
-
$this->cluster->set('key','value');
|
118 |
-
$this->assertEquals(6379,$this->cluster->byHash('key')->getPort());
|
119 |
-
}
|
120 |
-
public function testRwsplit()
|
121 |
-
{
|
122 |
-
$readOnlyCommands = array(
|
123 |
-
'EXISTS',
|
124 |
-
'TYPE',
|
125 |
-
'KEYS',
|
126 |
-
'SCAN',
|
127 |
-
'RANDOMKEY',
|
128 |
-
'TTL',
|
129 |
-
'GET',
|
130 |
-
'MGET',
|
131 |
-
'SUBSTR',
|
132 |
-
'STRLEN',
|
133 |
-
'GETRANGE',
|
134 |
-
'GETBIT',
|
135 |
-
'LLEN',
|
136 |
-
'LRANGE',
|
137 |
-
'LINDEX',
|
138 |
-
'SCARD',
|
139 |
-
'SISMEMBER',
|
140 |
-
'SINTER',
|
141 |
-
'SUNION',
|
142 |
-
'SDIFF',
|
143 |
-
'SMEMBERS',
|
144 |
-
'SSCAN',
|
145 |
-
'SRANDMEMBER',
|
146 |
-
'ZRANGE',
|
147 |
-
'ZREVRANGE',
|
148 |
-
'ZRANGEBYSCORE',
|
149 |
-
'ZREVRANGEBYSCORE',
|
150 |
-
'ZCARD',
|
151 |
-
'ZSCORE',
|
152 |
-
'ZCOUNT',
|
153 |
-
'ZRANK',
|
154 |
-
'ZREVRANK',
|
155 |
-
'ZSCAN',
|
156 |
-
'HGET',
|
157 |
-
'HMGET',
|
158 |
-
'HEXISTS',
|
159 |
-
'HLEN',
|
160 |
-
'HKEYS',
|
161 |
-
'HVALS',
|
162 |
-
'HGETALL',
|
163 |
-
'HSCAN',
|
164 |
-
'PING',
|
165 |
-
'AUTH',
|
166 |
-
'SELECT',
|
167 |
-
'ECHO',
|
168 |
-
'QUIT',
|
169 |
-
'OBJECT',
|
170 |
-
'BITCOUNT',
|
171 |
-
'TIME',
|
172 |
-
'SORT'
|
173 |
-
);
|
174 |
-
foreach($readOnlyCommands as $command){
|
175 |
-
$this->assertTrue($this->cluster->isReadOnlyCommand($command));
|
176 |
-
}
|
177 |
-
$this->assertFalse($this->cluster->isReadOnlyCommand("SET"));
|
178 |
-
$this->assertFalse($this->cluster->isReadOnlyCommand("HDEL"));
|
179 |
-
$this->assertFalse($this->cluster->isReadOnlyCommand("RPUSH"));
|
180 |
-
$this->assertFalse($this->cluster->isReadOnlyCommand("SMOVE"));
|
181 |
-
$this->assertFalse($this->cluster->isReadOnlyCommand("ZADD"));
|
182 |
-
}
|
183 |
-
public function testCredisClientInstancesInConstructor()
|
184 |
-
{
|
185 |
-
$this->tearDown();
|
186 |
-
$two = new Credis_Client($this->redisConfig[1]['host'], $this->redisConfig[1]['port']);
|
187 |
-
$three = new Credis_Client($this->redisConfig[2]['host'], $this->redisConfig[2]['port']);
|
188 |
-
$four = new Credis_Client($this->redisConfig[3]['host'], $this->redisConfig[3]['port']);
|
189 |
-
$this->cluster = new Credis_Cluster(array($two,$three,$four),2,$this->useStandalone);
|
190 |
-
$this->assertTrue($this->cluster->set('key','value'));
|
191 |
-
$this->assertEquals('value',$this->cluster->get('key'));
|
192 |
-
$this->setExpectedExceptionShim('CredisException','Server should either be an array or an instance of Credis_Client');
|
193 |
-
new Credis_Cluster(array(new stdClass()),2,$this->useStandalone);
|
194 |
-
}
|
195 |
-
public function testSetMasterClient()
|
196 |
-
{
|
197 |
-
$this->tearDown();
|
198 |
-
$master = new Credis_Client($this->redisConfig[0]['host'], $this->redisConfig[0]['port']);
|
199 |
-
$slave = new Credis_Client($this->redisConfig[6]['host'], $this->redisConfig[6]['port']);
|
200 |
-
|
201 |
-
$this->cluster = new Credis_Cluster(array($slave),2,$this->useStandalone);
|
202 |
-
$this->assertInstanceOf('Credis_Cluster',$this->cluster->setMasterClient($master));
|
203 |
-
$this->assertCount(2,$this->cluster->clients());
|
204 |
-
$this->assertEquals($this->redisConfig[6]['port'], $this->cluster->client(0)->getPort());
|
205 |
-
$this->assertEquals($this->redisConfig[0]['port'], $this->cluster->client('master')->getPort());
|
206 |
-
|
207 |
-
$this->cluster = new Credis_Cluster(array($this->redisConfig[0]), 2, $this->useStandalone);
|
208 |
-
$this->assertInstanceOf('Credis_Cluster',$this->cluster->setMasterClient(new Credis_Client($this->redisConfig[1]['host'], $this->redisConfig[1]['port'])));
|
209 |
-
$this->assertEquals($this->redisConfig[0]['port'], $this->cluster->client('master')->getPort());
|
210 |
-
|
211 |
-
$this->cluster = new Credis_Cluster(array($slave),2,$this->useStandalone);
|
212 |
-
$this->assertInstanceOf('Credis_Cluster',$this->cluster->setMasterClient($master,true));
|
213 |
-
$this->assertCount(1,$this->cluster->clients());
|
214 |
-
}
|
215 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
dependencies/colinmollenhour/credis/tests/CredisSentinelTest.php
DELETED
@@ -1,225 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
require_once dirname(__FILE__).'/../Client.php';
|
4 |
-
require_once dirname(__FILE__).'/../Cluster.php';
|
5 |
-
require_once dirname(__FILE__).'/../Sentinel.php';
|
6 |
-
require_once dirname(__FILE__).'/CredisTestCommon.php';
|
7 |
-
|
8 |
-
class CredisSentinelTest extends CredisTestCommon
|
9 |
-
{
|
10 |
-
/** @var Credis_Sentinel */
|
11 |
-
protected $sentinel;
|
12 |
-
|
13 |
-
protected $sentinelConfig;
|
14 |
-
|
15 |
-
protected function setUp()
|
16 |
-
{
|
17 |
-
parent::setUp();
|
18 |
-
if($this->sentinelConfig === NULL) {
|
19 |
-
$configFile = dirname(__FILE__).'/sentinel_config.json';
|
20 |
-
if( ! file_exists($configFile) || ! ($config = file_get_contents($configFile))) {
|
21 |
-
$this->markTestSkipped('Could not load '.$configFile);
|
22 |
-
return;
|
23 |
-
}
|
24 |
-
$this->sentinelConfig = json_decode($config);
|
25 |
-
}
|
26 |
-
|
27 |
-
$sentinelClient = new Credis_Client($this->sentinelConfig->host, $this->sentinelConfig->port);
|
28 |
-
$this->sentinel = new Credis_Sentinel($sentinelClient);
|
29 |
-
if($this->useStandalone) {
|
30 |
-
$this->sentinel->forceStandalone();
|
31 |
-
}
|
32 |
-
$this->waitForSlaveReplication();
|
33 |
-
}
|
34 |
-
|
35 |
-
public static function setUpBeforeClass()
|
36 |
-
{
|
37 |
-
parent::setUpBeforeClass();
|
38 |
-
if(preg_match('/^WIN/',strtoupper(PHP_OS))){
|
39 |
-
echo "\tredis-server redis-sentinel.conf --sentinel".PHP_EOL.PHP_EOL;
|
40 |
-
} else {
|
41 |
-
sleep(2);
|
42 |
-
chdir(__DIR__);
|
43 |
-
copy('redis-sentinel.conf','redis-sentinel.conf.bak');
|
44 |
-
exec('redis-server redis-sentinel.conf --sentinel');
|
45 |
-
// wait for redis to initialize
|
46 |
-
sleep(1);
|
47 |
-
}
|
48 |
-
}
|
49 |
-
|
50 |
-
public static function tearDownAfterClass()
|
51 |
-
{
|
52 |
-
parent::tearDownAfterClass();
|
53 |
-
if(preg_match('/^WIN/',strtoupper(PHP_OS))){
|
54 |
-
echo "Please kill all Redis instances manually:".PHP_EOL;
|
55 |
-
} else {
|
56 |
-
chdir(__DIR__);
|
57 |
-
@unlink('redis-sentinel.conf');
|
58 |
-
@copy('redis-sentinel.conf.bak','redis-sentinel.conf');
|
59 |
-
}
|
60 |
-
}
|
61 |
-
|
62 |
-
protected function tearDown()
|
63 |
-
{
|
64 |
-
if($this->sentinel) {
|
65 |
-
$this->sentinel = NULL;
|
66 |
-
}
|
67 |
-
}
|
68 |
-
public function testMasterClient()
|
69 |
-
{
|
70 |
-
$master = $this->sentinel->getMasterClient($this->sentinelConfig->clustername);
|
71 |
-
$this->assertInstanceOf('Credis_Client',$master);
|
72 |
-
$this->assertEquals($this->redisConfig[0]['port'],$master->getPort());
|
73 |
-
$this->setExpectedExceptionShim('CredisException','Master not found');
|
74 |
-
$this->sentinel->getMasterClient('non-existing-cluster');
|
75 |
-
}
|
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);
|
87 |
-
$this->assertArrayHasKey(1,$masters[0]);
|
88 |
-
$this->assertArrayHasKey(1,$masters[1]);
|
89 |
-
$this->assertArrayHasKey(5,$masters[1]);
|
90 |
-
if($masters[0][1] == 'masterdown'){
|
91 |
-
$this->assertEquals($this->sentinelConfig->clustername,$masters[1][1]);
|
92 |
-
$this->assertEquals($this->redisConfig[0]['port'],$masters[1][5]);
|
93 |
-
} else {
|
94 |
-
$this->assertEquals('masterdown',$masters[1][1]);
|
95 |
-
$this->assertEquals($this->sentinelConfig->clustername,$masters[0][1]);
|
96 |
-
$this->assertEquals($this->redisConfig[0]['port'],$masters[0][5]);
|
97 |
-
}
|
98 |
-
}
|
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]);
|
110 |
-
$this->assertEquals($this->redisConfig[0]['port'],$master[5]);
|
111 |
-
|
112 |
-
$this->setExpectedExceptionShim('CredisException','No such master with that name');
|
113 |
-
$this->sentinel->master('non-existing-cluster');
|
114 |
-
}
|
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);
|
126 |
-
}
|
127 |
-
$this->setExpectedExceptionShim('CredisException','No such master with that name');
|
128 |
-
$this->sentinel->getSlaveClients('non-existing-cluster');
|
129 |
-
}
|
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');
|
152 |
-
$this->sentinel->slaves('non-existing-cluster');
|
153 |
-
}
|
154 |
-
public function testNonExistingClusterNameWhenCreatingSlaves()
|
155 |
-
{
|
156 |
-
$this->setExpectedExceptionShim('CredisException','No such master with that name');
|
157 |
-
$this->sentinel->createSlaveClients('non-existing-cluster');
|
158 |
-
}
|
159 |
-
public function testCreateCluster()
|
160 |
-
{
|
161 |
-
$cluster = $this->sentinel->createCluster($this->sentinelConfig->clustername);
|
162 |
-
$this->assertInstanceOf('Credis_Cluster',$cluster);
|
163 |
-
$this->assertCount(2,$cluster->clients());
|
164 |
-
$cluster = $this->sentinel->createCluster($this->sentinelConfig->clustername,0,1,false);
|
165 |
-
$this->assertInstanceOf('Credis_Cluster',$cluster);
|
166 |
-
$this->assertCount(2,$cluster->clients());
|
167 |
-
$this->setExpectedExceptionShim('CredisException','The master is down');
|
168 |
-
$this->sentinel->createCluster($this->sentinelConfig->downclustername);
|
169 |
-
}
|
170 |
-
public function testGetCluster()
|
171 |
-
{
|
172 |
-
$cluster = $this->sentinel->getCluster($this->sentinelConfig->clustername);
|
173 |
-
$this->assertInstanceOf('Credis_Cluster',$cluster);
|
174 |
-
$this->assertCount(2,$cluster->clients());
|
175 |
-
}
|
176 |
-
public function testGetClusterOnDbNumber2()
|
177 |
-
{
|
178 |
-
$cluster = $this->sentinel->getCluster($this->sentinelConfig->clustername,2);
|
179 |
-
$this->assertInstanceOf('Credis_Cluster',$cluster);
|
180 |
-
$this->assertCount(2,$cluster->clients());
|
181 |
-
$clients = $cluster->clients();
|
182 |
-
$this->assertEquals(2,$clients[0]->getSelectedDb());
|
183 |
-
$this->assertEquals(2,$clients[1]->getSelectedDb());
|
184 |
-
}
|
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);
|
196 |
-
$this->assertEquals($this->redisConfig[0]['host'],$address[0]);
|
197 |
-
$this->assertEquals($this->redisConfig[0]['port'],$address[1]);
|
198 |
-
}
|
199 |
-
|
200 |
-
public function testPing()
|
201 |
-
{
|
202 |
-
$pong = $this->sentinel->ping();
|
203 |
-
$this->assertEquals("PONG",$pong);
|
204 |
-
}
|
205 |
-
|
206 |
-
public function testGetHostAndPort()
|
207 |
-
{
|
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);
|
215 |
-
$client->expects($this->once())->method('getPort')->willReturn($port);
|
216 |
-
|
217 |
-
$this->assertEquals($host, $sentinel->getHost());
|
218 |
-
$this->assertEquals($port, $sentinel->getPort());
|
219 |
-
}
|
220 |
-
public function testNonExistingMethod()
|
221 |
-
{
|
222 |
-
$this->setExpectedExceptionShim('CredisException','Unknown sentinel subcommand \'bla\'');
|
223 |
-
$this->sentinel->bla();
|
224 |
-
}
|
225 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
dependencies/colinmollenhour/credis/tests/CredisStandaloneClusterTest.php
DELETED
@@ -1,30 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
require_once dirname(__FILE__).'/CredisClusterTest.php';
|
4 |
-
|
5 |
-
class CredisStandaloneClusterTest extends CredisClusterTest
|
6 |
-
{
|
7 |
-
protected $useStandalone = TRUE;
|
8 |
-
protected function tearDown()
|
9 |
-
{
|
10 |
-
if($this->cluster) {
|
11 |
-
foreach($this->cluster->clients() as $client){
|
12 |
-
if($client->isConnected()) {
|
13 |
-
$client->close();
|
14 |
-
}
|
15 |
-
}
|
16 |
-
$this->cluster = NULL;
|
17 |
-
}
|
18 |
-
}
|
19 |
-
public function testMasterSlave()
|
20 |
-
{
|
21 |
-
$this->tearDown();
|
22 |
-
$this->cluster = new Credis_Cluster(array($this->redisConfig[0],$this->redisConfig[6]), 2, $this->useStandalone);
|
23 |
-
$this->assertTrue($this->cluster->client('master')->set('key','value'));
|
24 |
-
$this->waitForSlaveReplication();
|
25 |
-
$this->assertEquals('value',$this->cluster->client('slave')->get('key'));
|
26 |
-
$this->assertEquals('value',$this->cluster->get('key'));
|
27 |
-
$this->setExpectedExceptionShim('CredisException','READONLY You can\'t write against a read only replica.');
|
28 |
-
$this->cluster->client('slave')->set('key2','value');
|
29 |
-
}
|
30 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
dependencies/colinmollenhour/credis/tests/CredisStandaloneSentinelTest.php
DELETED
@@ -1,8 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
require_once dirname(__FILE__).'/CredisSentinelTest.php';
|
4 |
-
|
5 |
-
class CredisStandaloneSentinelTest extends CredisSentinelTest
|
6 |
-
{
|
7 |
-
protected $useStandalone = TRUE;
|
8 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
dependencies/colinmollenhour/credis/tests/CredisStandaloneTest.php
DELETED
@@ -1,44 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
require_once dirname(__FILE__).'/CredisTest.php';
|
4 |
-
|
5 |
-
class CredisStandaloneTest extends CredisTest
|
6 |
-
{
|
7 |
-
protected $useStandalone = TRUE;
|
8 |
-
|
9 |
-
/**
|
10 |
-
* @group UnixSocket
|
11 |
-
*/
|
12 |
-
public function testInvalidPersistentConnectionOnUnixSocket()
|
13 |
-
{
|
14 |
-
$this->credis->close();
|
15 |
-
$this->credis = new Credis_Client('unix://'.realpath(__DIR__).'/redis.sock',0,null,'persistent');
|
16 |
-
$this->credis->forceStandalone();
|
17 |
-
//$this->setExpectedException('CredisException','Persistent connections to UNIX sockets are not supported in standalone mode.');
|
18 |
-
$this->credis->connect();
|
19 |
-
$this->assertTrue($this->credis->isConnected());
|
20 |
-
}
|
21 |
-
|
22 |
-
public function testPersistentConnectionsOnStandAloneTcpConnection()
|
23 |
-
{
|
24 |
-
$this->credis->close();
|
25 |
-
$this->credis = new Credis_Client('tcp://'.$this->redisConfig[0]['host'] . ':' . $this->redisConfig[0]['port'] . '/persistent');
|
26 |
-
$this->credis->forceStandalone();
|
27 |
-
$this->credis->set('key','value');
|
28 |
-
$this->assertEquals('value',$this->credis->get('key'));
|
29 |
-
}
|
30 |
-
|
31 |
-
public function testPersistentvsNonPersistent() {$this->assertTrue(true);}
|
32 |
-
|
33 |
-
public function testStandAloneArgumentsExtra()
|
34 |
-
{
|
35 |
-
$this->assertTrue($this->credis->hMSet('hash', array('field1' => 'value1', 'field2' => 'value2'), 'field3', 'value3'));
|
36 |
-
$this->assertEquals(array('field1' => 'value1', 'field2' => 'value2', 'field3' =>'value3'), $this->credis->hMGet('hash', array('field1','field2','field3')));
|
37 |
-
}
|
38 |
-
|
39 |
-
public function testStandAloneMultiPipelineThrowsException()
|
40 |
-
{
|
41 |
-
$this->setExpectedExceptionShim('CredisException','A pipeline is already in use and only one pipeline is supported.');
|
42 |
-
$this->credis->pipeline()->pipeline();
|
43 |
-
}
|
44 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
dependencies/colinmollenhour/credis/tests/CredisTest.php
DELETED
@@ -1,780 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
require_once dirname(__FILE__).'/../Client.php';
|
4 |
-
require_once dirname(__FILE__).'/CredisTestCommon.php';
|
5 |
-
|
6 |
-
class CredisTest extends CredisTestCommon
|
7 |
-
{
|
8 |
-
/** @var Credis_Client */
|
9 |
-
protected $credis;
|
10 |
-
|
11 |
-
protected function setUp()
|
12 |
-
{
|
13 |
-
parent::setUp();
|
14 |
-
$this->credis = new Credis_Client($this->redisConfig[0]['host'], $this->redisConfig[0]['port'], $this->redisConfig[0]['timeout']);
|
15 |
-
if($this->useStandalone) {
|
16 |
-
$this->credis->forceStandalone();
|
17 |
-
}
|
18 |
-
$this->credis->flushDb();
|
19 |
-
}
|
20 |
-
protected function tearDown()
|
21 |
-
{
|
22 |
-
if($this->credis) {
|
23 |
-
$this->credis->close();
|
24 |
-
$this->credis = NULL;
|
25 |
-
}
|
26 |
-
}
|
27 |
-
public function testFlush()
|
28 |
-
{
|
29 |
-
$this->credis->set('foo','FOO');
|
30 |
-
$this->assertTrue($this->credis->flushDb());
|
31 |
-
$this->assertFalse($this->credis->get('foo'));
|
32 |
-
}
|
33 |
-
|
34 |
-
public function testReadTimeout()
|
35 |
-
{
|
36 |
-
$this->credis->setReadTimeout(0.0001);
|
37 |
-
try {
|
38 |
-
$this->credis->save();
|
39 |
-
$this->fail('Expected exception (read should timeout since disk sync should take longer than 0.0001 seconds).');
|
40 |
-
} catch(CredisException $e) {
|
41 |
-
}
|
42 |
-
$this->credis->setReadTimeout(10);
|
43 |
-
$this->assertTrue(true);
|
44 |
-
}
|
45 |
-
|
46 |
-
public function testPHPRedisReadTimeout()
|
47 |
-
{
|
48 |
-
try {
|
49 |
-
$this->credis->setReadTimeout(-1);
|
50 |
-
} catch(CredisException $e) {
|
51 |
-
$this->fail('setReadTimeout should accept -1 as timeout value');
|
52 |
-
}
|
53 |
-
try {
|
54 |
-
$this->credis->setReadTimeout(-2);
|
55 |
-
$this->fail('setReadTimeout should not accept values less than -1');
|
56 |
-
} catch(CredisException $e) {
|
57 |
-
}
|
58 |
-
$this->assertTrue(true);
|
59 |
-
}
|
60 |
-
|
61 |
-
public function testScalars()
|
62 |
-
{
|
63 |
-
// Basic get/set
|
64 |
-
$this->credis->set('foo','FOO');
|
65 |
-
$this->assertEquals('FOO', $this->credis->get('foo'));
|
66 |
-
$this->assertFalse($this->credis->get('nil'));
|
67 |
-
|
68 |
-
// exists support
|
69 |
-
$this->assertEquals($this->credis->exists('foo'), 1);
|
70 |
-
$this->assertEquals($this->credis->exists('nil'), 0);
|
71 |
-
|
72 |
-
// Empty string
|
73 |
-
$this->credis->set('empty','');
|
74 |
-
$this->assertEquals('', $this->credis->get('empty'));
|
75 |
-
|
76 |
-
// UTF-8 characters
|
77 |
-
$utf8str = str_repeat("quarter: ¼, micro: µ, thorn: Þ, ", 500);
|
78 |
-
$this->credis->set('utf8',$utf8str);
|
79 |
-
$this->assertEquals($utf8str, $this->credis->get('utf8'));
|
80 |
-
|
81 |
-
// Array
|
82 |
-
$this->assertTrue($this->credis->mSet(array('bar' => 'BAR', 'apple' => 'red')));
|
83 |
-
$mGet = $this->credis->mGet(array('foo','bar','empty'));
|
84 |
-
$this->assertTrue(in_array('FOO', $mGet));
|
85 |
-
$this->assertTrue(in_array('BAR', $mGet));
|
86 |
-
$this->assertTrue(in_array('', $mGet));
|
87 |
-
|
88 |
-
// Non-array
|
89 |
-
$mGet = $this->credis->mGet('foo','bar');
|
90 |
-
$this->assertTrue(in_array('FOO', $mGet));
|
91 |
-
$this->assertTrue(in_array('BAR', $mGet));
|
92 |
-
|
93 |
-
// Delete strings, null response
|
94 |
-
$this->assertEquals(2, $this->credis->del('foo','bar'));
|
95 |
-
$this->assertFalse($this->credis->get('foo'));
|
96 |
-
$this->assertFalse($this->credis->get('bar'));
|
97 |
-
|
98 |
-
// Long string
|
99 |
-
$longString = str_repeat(md5('asd'), 4096); // 128k (redis.h REDIS_INLINE_MAX_SIZE = 64k)
|
100 |
-
$this->assertTrue($this->credis->set('long', $longString));
|
101 |
-
$this->assertEquals($longString, $this->credis->get('long'));
|
102 |
-
}
|
103 |
-
|
104 |
-
public function testSets()
|
105 |
-
{
|
106 |
-
// Multiple arguments
|
107 |
-
$this->assertEquals(2, $this->credis->sAdd('myset', 'Hello', 'World'));
|
108 |
-
|
109 |
-
// Array Arguments
|
110 |
-
$this->assertEquals(1, $this->credis->sAdd('myset', array('Hello','Cruel','World')));
|
111 |
-
|
112 |
-
// Non-empty set
|
113 |
-
$members = $this->credis->sMembers('myset');
|
114 |
-
$this->assertEquals(3, count($members));
|
115 |
-
$this->assertTrue(in_array('Hello', $members));
|
116 |
-
|
117 |
-
// Empty set
|
118 |
-
$this->assertEquals(array(), $this->credis->sMembers('noexist'));
|
119 |
-
}
|
120 |
-
|
121 |
-
public function testSortedSets()
|
122 |
-
{
|
123 |
-
$this->assertEquals(1, $this->credis->zAdd('myset', 1, 'Hello'));
|
124 |
-
$this->assertEquals(1, $this->credis->zAdd('myset', 2.123, 'World'));
|
125 |
-
$this->assertEquals(1, $this->credis->zAdd('myset', 10, 'And'));
|
126 |
-
$this->assertEquals(1, $this->credis->zAdd('myset', 11, 'Goodbye'));
|
127 |
-
|
128 |
-
$this->assertEquals(4, count($this->credis->zRange('myset', 0, 4)));
|
129 |
-
$this->assertEquals(2, count($this->credis->zRange('myset', 0, 1)));
|
130 |
-
|
131 |
-
$range = $this->credis->zRange('myset', 1, 2);
|
132 |
-
$this->assertEquals(2, count($range));
|
133 |
-
$this->assertEquals('World', $range[0]);
|
134 |
-
$this->assertEquals('And', $range[1]);
|
135 |
-
|
136 |
-
$range = $this->credis->zRange('myset', 1, 2, array('withscores' => true));
|
137 |
-
$this->assertEquals(2, count($range));
|
138 |
-
$this->assertTrue(array_key_exists('World', $range));
|
139 |
-
$this->assertEquals(2.123, $range['World']);
|
140 |
-
$this->assertTrue(array_key_exists('And', $range));
|
141 |
-
$this->assertEquals(10, $range['And']);
|
142 |
-
|
143 |
-
// withscores-option is off
|
144 |
-
$range = $this->credis->zRange('myset', 0, 4, array('withscores'));
|
145 |
-
$this->assertEquals(4, count($range));
|
146 |
-
$this->assertEquals(range(0, 3), array_keys($range)); // expecting numeric array without scores
|
147 |
-
|
148 |
-
$range = $this->credis->zRange('myset', 0, 4, array('withscores' => false));
|
149 |
-
$this->assertEquals(4, count($range));
|
150 |
-
$this->assertEquals(range(0, 3), array_keys($range));
|
151 |
-
|
152 |
-
$this->assertEquals(4, count($this->credis->zRevRange('myset', 0, 4)));
|
153 |
-
$this->assertEquals(2, count($this->credis->zRevRange('myset', 0, 1)));
|
154 |
-
|
155 |
-
$range = $this->credis->zRevRange('myset', 0, 1, array('withscores' => true));
|
156 |
-
$this->assertEquals(2, count($range));
|
157 |
-
$this->assertTrue(array_key_exists('And', $range));
|
158 |
-
$this->assertEquals(10, $range['And']);
|
159 |
-
$this->assertTrue(array_key_exists('Goodbye', $range));
|
160 |
-
$this->assertEquals(11, $range['Goodbye']);
|
161 |
-
|
162 |
-
// withscores-option is off
|
163 |
-
$range = $this->credis->zRevRange('myset', 0, 4, array('withscores'));
|
164 |
-
$this->assertEquals(4, count($range));
|
165 |
-
$this->assertEquals(range(0, 3), array_keys($range)); // expecting numeric array without scores
|
166 |
-
|
167 |
-
$range = $this->credis->zRevRange('myset', 0, 4, array('withscores' => false));
|
168 |
-
$this->assertEquals(4, count($range));
|
169 |
-
$this->assertEquals(range(0, 3), array_keys($range));
|
170 |
-
|
171 |
-
$this->assertEquals(4, count($this->credis->zRangeByScore('myset', '-inf', '+inf')));
|
172 |
-
$this->assertEquals(2, count($this->credis->zRangeByScore('myset', '1', '9')));
|
173 |
-
|
174 |
-
$range = $this->credis->zRangeByScore('myset', '-inf', '+inf', array('limit' => array(1, 2)));
|
175 |
-
$this->assertEquals(2, count($range));
|
176 |
-
$this->assertEquals('World', $range[0]);
|
177 |
-
$this->assertEquals('And', $range[1]);
|
178 |
-
|
179 |
-
$range = $this->credis->zRangeByScore('myset', '-inf', '+inf', array('withscores' => true, 'limit' => array(1, 2)));
|
180 |
-
$this->assertEquals(2, count($range));
|
181 |
-
$this->assertTrue(array_key_exists('World', $range));
|
182 |
-
$this->assertEquals(2.123, $range['World']);
|
183 |
-
$this->assertTrue(array_key_exists('And', $range));
|
184 |
-
$this->assertEquals(10, $range['And']);
|
185 |
-
|
186 |
-
$range = $this->credis->zRangeByScore('myset', 10, '+inf', array('withscores' => true));
|
187 |
-
$this->assertEquals(2, count($range));
|
188 |
-
$this->assertTrue(array_key_exists('And', $range));
|
189 |
-
$this->assertEquals(10, $range['And']);
|
190 |
-
$this->assertTrue(array_key_exists('Goodbye', $range));
|
191 |
-
$this->assertEquals(11, $range['Goodbye']);
|
192 |
-
|
193 |
-
// withscores-option is off
|
194 |
-
$range = $this->credis->zRangeByScore('myset', '-inf', '+inf', array('withscores'));
|
195 |
-
$this->assertEquals(4, count($range));
|
196 |
-
$this->assertEquals(range(0, 3), array_keys($range)); // expecting numeric array without scores
|
197 |
-
|
198 |
-
$range = $this->credis->zRangeByScore('myset', '-inf', '+inf', array('withscores' => false));
|
199 |
-
$this->assertEquals(4, count($range));
|
200 |
-
$this->assertEquals(range(0, 3), array_keys($range));
|
201 |
-
|
202 |
-
$this->assertEquals(4, count($this->credis->zRevRangeByScore('myset', '+inf', '-inf')));
|
203 |
-
$this->assertEquals(2, count($this->credis->zRevRangeByScore('myset', '9', '1')));
|
204 |
-
|
205 |
-
$range = $this->credis->zRevRangeByScore('myset', '+inf', '-inf', array('limit' => array(1, 2)));
|
206 |
-
$this->assertEquals(2, count($range));
|
207 |
-
$this->assertEquals('World', $range[1]);
|
208 |
-
$this->assertEquals('And', $range[0]);
|
209 |
-
|
210 |
-
$range = $this->credis->zRevRangeByScore('myset', '+inf', '-inf', array('withscores' => true, 'limit' => array(1, 2)));
|
211 |
-
$this->assertEquals(2, count($range));
|
212 |
-
$this->assertTrue(array_key_exists('World', $range));
|
213 |
-
$this->assertEquals(2.123, $range['World']);
|
214 |
-
$this->assertTrue(array_key_exists('And', $range));
|
215 |
-
$this->assertEquals(10, $range['And']);
|
216 |
-
|
217 |
-
$range = $this->credis->zRevRangeByScore('myset', '+inf',10, array('withscores' => true));
|
218 |
-
$this->assertEquals(2, count($range));
|
219 |
-
$this->assertTrue(array_key_exists('And', $range));
|
220 |
-
$this->assertEquals(10, $range['And']);
|
221 |
-
$this->assertTrue(array_key_exists('Goodbye', $range));
|
222 |
-
$this->assertEquals(11, $range['Goodbye']);
|
223 |
-
|
224 |
-
// withscores-option is off
|
225 |
-
$range = $this->credis->zRevRangeByScore('myset', '+inf', '-inf', array('withscores'));
|
226 |
-
$this->assertEquals(4, count($range));
|
227 |
-
$this->assertEquals(range(0, 3), array_keys($range)); // expecting numeric array without scores
|
228 |
-
|
229 |
-
$range = $this->credis->zRevRangeByScore('myset', '+inf', '-inf', array('withscores' => false));
|
230 |
-
$this->assertEquals(4, count($range));
|
231 |
-
$this->assertEquals(range(0, 3), array_keys($range));
|
232 |
-
|
233 |
-
|
234 |
-
// testing zunionstore (intersection of sorted sets)
|
235 |
-
$this->credis->zAdd('myset1', 10, 'key1');
|
236 |
-
$this->credis->zAdd('myset1', 10, 'key2');
|
237 |
-
$this->credis->zAdd('myset1', 10, 'key_not_in_myset2');
|
238 |
-
|
239 |
-
$this->credis->zAdd('myset2', 15, 'key1');
|
240 |
-
$this->credis->zAdd('myset2', 15, 'key2');
|
241 |
-
$this->credis->zAdd('myset2', 15, 'key_not_in_myset1');
|
242 |
-
|
243 |
-
$this->credis->zUnionStore('myset3', array('myset1', 'myset2'));
|
244 |
-
$range = $this->credis->zRangeByScore('myset3', '-inf', '+inf', array('withscores' => true));
|
245 |
-
$this->assertEquals(4, count($range));
|
246 |
-
$this->assertTrue(array_key_exists('key1', $range));
|
247 |
-
$this->assertEquals(25, $range['key1']);
|
248 |
-
$this->assertTrue(array_key_exists('key_not_in_myset1', $range));
|
249 |
-
$this->assertEquals(15, $range['key_not_in_myset1']);
|
250 |
-
|
251 |
-
// testing zunionstore AGGREGATE option
|
252 |
-
$this->credis->zUnionStore('myset4', array('myset1', 'myset2'), array('aggregate' => 'max'));
|
253 |
-
$range = $this->credis->zRangeByScore('myset4', '-inf', '+inf', array('withscores' => true));
|
254 |
-
$this->assertEquals(4, count($range));
|
255 |
-
$this->assertTrue(array_key_exists('key1', $range));
|
256 |
-
$this->assertEquals(15, $range['key1']);
|
257 |
-
$this->assertTrue(array_key_exists('key2', $range));
|
258 |
-
$this->assertEquals(15, $range['key2']);
|
259 |
-
|
260 |
-
// testing zunionstore WEIGHTS option
|
261 |
-
$this->credis->zUnionStore('myset5', array('myset1', 'myset2'), array('weights' => array(2, 4)));
|
262 |
-
$range = $this->credis->zRangeByScore('myset5', '-inf', '+inf', array('withscores' => true));
|
263 |
-
$this->assertEquals(4, count($range));
|
264 |
-
$this->assertTrue(array_key_exists('key1', $range));
|
265 |
-
$this->assertEquals(80, $range['key1']);
|
266 |
-
}
|
267 |
-
|
268 |
-
public function testHashes()
|
269 |
-
{
|
270 |
-
$this->assertEquals(1, $this->credis->hSet('hash','field1','foo'));
|
271 |
-
$this->assertEquals(0, $this->credis->hSet('hash','field1','foo'));
|
272 |
-
$this->assertEquals('foo', $this->credis->hGet('hash','field1'));
|
273 |
-
$this->assertEquals(NULL, $this->credis->hGet('hash','x'));
|
274 |
-
$this->assertTrue($this->credis->hMSet('hash', array('field2' => 'Hello', 'field3' => 'World')));
|
275 |
-
$this->assertEquals(array('field1' => 'foo', 'field2' => 'Hello', 'nilfield' => FALSE), $this->credis->hMGet('hash', array('field1','field2','nilfield')));
|
276 |
-
$this->assertEquals(array(), $this->credis->hGetAll('nohash'));
|
277 |
-
$this->assertEquals(array('field1' => 'foo', 'field2' => 'Hello', 'field3' => 'World'), $this->credis->hGetAll('hash'));
|
278 |
-
|
279 |
-
// test integer keys
|
280 |
-
$this->assertTrue($this->credis->hMSet('hashInt', array(0 => 'Hello', 1 => 'World')));
|
281 |
-
$this->assertEquals(array(0 => 'Hello', 1 => 'World'), $this->credis->hGetAll('hashInt'));
|
282 |
-
|
283 |
-
// Test long hash values
|
284 |
-
$longString = str_repeat(md5('asd'), 4096); // 128k (redis.h REDIS_INLINE_MAX_SIZE = 64k)
|
285 |
-
$this->assertEquals(1, $this->credis->hMSet('long_hash', array('count' => 1, 'data' => $longString)), 'Set long hash value');
|
286 |
-
$this->assertEquals($longString, $this->credis->hGet('long_hash', 'data'), 'Get long hash value');
|
287 |
-
|
288 |
-
// in piplining mode
|
289 |
-
$this->assertTrue($this->credis->hMSet('hash', array('field1' => 'foo', 'field2' => 'Hello')));
|
290 |
-
|
291 |
-
$this->credis->pipeline();
|
292 |
-
$this->assertTrue($this->credis === $this->credis->hMGet('hash', array('field1','field2','nilfield')));
|
293 |
-
$this->assertEquals(array(0 => array('field1' => 'foo', 'field2' => 'Hello', 'nilfield' => FALSE)), $this->credis->exec());
|
294 |
-
|
295 |
-
$this->credis->pipeline()->multi();
|
296 |
-
$this->assertTrue($this->credis === $this->credis->hMGet('hash', array('field1','field2','nilfield')));
|
297 |
-
$this->assertEquals(array(0 => array('field1' => 'foo', 'field2' => 'Hello', 'nilfield' => FALSE)), $this->credis->exec());
|
298 |
-
}
|
299 |
-
|
300 |
-
public function testFalsey()
|
301 |
-
{
|
302 |
-
$this->assertEquals(Credis_Client::TYPE_NONE, $this->credis->type('foo'));
|
303 |
-
}
|
304 |
-
|
305 |
-
public function testPipeline()
|
306 |
-
{
|
307 |
-
$config = $this->credis->config('GET', '*');
|
308 |
-
$this->assertEquals($config, $this->credis->pipeline()->config('GET', '*')->exec()[0]);
|
309 |
-
|
310 |
-
$this->credis->pipeline();
|
311 |
-
$this->pipelineTestInternal();
|
312 |
-
$this->assertEquals(array(), $this->credis->pipeline()->exec());
|
313 |
-
}
|
314 |
-
|
315 |
-
public function testPipelineMulti()
|
316 |
-
{
|
317 |
-
$config = $this->credis->config('GET', '*');
|
318 |
-
$this->assertEquals($config, $this->credis->pipeline()->multi()->config('GET', '*')->exec()[0]);
|
319 |
-
|
320 |
-
$this->credis->pipeline()->multi();
|
321 |
-
$this->pipelineTestInternal();
|
322 |
-
$this->assertEquals(array(), $this->credis->pipeline()->multi()->exec());
|
323 |
-
}
|
324 |
-
|
325 |
-
public function testWatchMultiUnwatch()
|
326 |
-
{
|
327 |
-
$this->assertTrue($this->credis->watch('foo', 'bar'));
|
328 |
-
|
329 |
-
$reply = $this->credis->pipeline()
|
330 |
-
->multi()
|
331 |
-
->set('foo', 1)
|
332 |
-
->set('bar', 1)
|
333 |
-
->exec();
|
334 |
-
$this->assertEquals(
|
335 |
-
array(
|
336 |
-
true,
|
337 |
-
true,
|
338 |
-
), $reply
|
339 |
-
);
|
340 |
-
$this->assertTrue($this->credis->unwatch());
|
341 |
-
}
|
342 |
-
|
343 |
-
protected function pipelineTestInternal()
|
344 |
-
{
|
345 |
-
$longString = str_repeat(md5('asd') . "\r\n", 500);
|
346 |
-
$reply = $this->credis
|
347 |
-
->set('a', 123)
|
348 |
-
->get('a')
|
349 |
-
->sAdd('b', 123)
|
350 |
-
->sMembers('b')
|
351 |
-
->set('empty', '')
|
352 |
-
->get('empty')
|
353 |
-
->set('big', $longString)
|
354 |
-
->get('big')
|
355 |
-
->hset('hash', 'field1', 1)
|
356 |
-
->hset('hash', 'field2', 2)
|
357 |
-
->hgetall('hash')
|
358 |
-
->hmget('hash', array('field1', 'field3'))
|
359 |
-
->zadd('sortedSet', 1, 'member1')
|
360 |
-
->zadd('sortedSet', 2, 'member2')
|
361 |
-
->zadd('sortedSet', 3, 'member3')
|
362 |
-
->zcard('sortedSet')
|
363 |
-
->zrangebyscore('sortedSet', 1, 2)
|
364 |
-
->zrangebyscore('sortedSet', 1, 2, array('withscores' => true))
|
365 |
-
->zrevrangebyscore('sortedSet', 2, 1)
|
366 |
-
->zrevrangebyscore('sortedSet', 2, 1, array('withscores' => true))
|
367 |
-
->zrange('sortedSet', 0, 1)
|
368 |
-
->zrange('sortedSet', 0, 1, array('withscores' => true))
|
369 |
-
->zrevrange('sortedSet', 0, 1)
|
370 |
-
->zrevrange('sortedSet', 0, 1, array('withscores' => true))
|
371 |
-
->exec();
|
372 |
-
$this->assertEquals(
|
373 |
-
array(
|
374 |
-
true, // set('a', 123)
|
375 |
-
'123', // get('a')
|
376 |
-
1, // sAdd('b', 123)
|
377 |
-
array(123), // sMembers('b')
|
378 |
-
true, // set('empty', '')
|
379 |
-
'', // get('empty')
|
380 |
-
true, // set('big', $longString)
|
381 |
-
$longString, // get('big')
|
382 |
-
1, // hset('hash', 'field1', 1)
|
383 |
-
1, // hset('hash', 'field2', 2)
|
384 |
-
array( // hgetall('hash')
|
385 |
-
'field1' => 1,
|
386 |
-
'field2' => 2,
|
387 |
-
),
|
388 |
-
array( // hmget('hash', array('field1', 'field3'))
|
389 |
-
'field1' => 1,
|
390 |
-
'field3' => false,
|
391 |
-
),
|
392 |
-
1, // zadd('sortedSet', 1, 'member1')
|
393 |
-
1, // zadd('sortedSet', 2, 'member2')
|
394 |
-
1, // zadd('sortedSet', 3, 'member3')
|
395 |
-
3, // zcard('sortedSet')
|
396 |
-
array( // zrangebyscore('sortedSet', 1, 2)
|
397 |
-
'member1',
|
398 |
-
'member2',
|
399 |
-
),
|
400 |
-
array( // zrangebyscore('sortedSet', 1, 2, array('withscores' => TRUE))
|
401 |
-
'member1' => 1.0,
|
402 |
-
'member2' => 2.0,
|
403 |
-
),
|
404 |
-
array( // zrevrangebyscore('sortedSet', 1, 2)
|
405 |
-
'member2',
|
406 |
-
'member1',
|
407 |
-
),
|
408 |
-
array( // zrevrangebyscore('sortedSet', 1, 2, array('withscores' => TRUE))
|
409 |
-
'member1' => 1.0,
|
410 |
-
'member2' => 2.0,
|
411 |
-
),
|
412 |
-
array( // zrangebyscore('sortedSet', 1, 2)
|
413 |
-
'member1',
|
414 |
-
'member2',
|
415 |
-
),
|
416 |
-
array( // zrangebyscore('sortedSet', 1, 2, array('withscores' => TRUE))
|
417 |
-
'member1' => 1.0,
|
418 |
-
'member2' => 2.0,
|
419 |
-
),
|
420 |
-
array( // zrevrangebyscore('sortedSet', 1, 2)
|
421 |
-
'member3',
|
422 |
-
'member2',
|
423 |
-
),
|
424 |
-
array( // zrevrangebyscore('sortedSet', 1, 2, array('withscores' => TRUE))
|
425 |
-
'member3' => 3.0,
|
426 |
-
'member2' => 2.0,
|
427 |
-
),
|
428 |
-
), $reply
|
429 |
-
);
|
430 |
-
}
|
431 |
-
|
432 |
-
public function testTransaction()
|
433 |
-
{
|
434 |
-
$reply = $this->credis->multi()
|
435 |
-
->incr('foo')
|
436 |
-
->incr('bar')
|
437 |
-
->exec();
|
438 |
-
$this->assertEquals(array(1,1), $reply);
|
439 |
-
|
440 |
-
$reply = $this->credis->pipeline()->multi()
|
441 |
-
->incr('foo')
|
442 |
-
->incr('bar')
|
443 |
-
->exec();
|
444 |
-
$this->assertEquals(array(2,2), $reply);
|
445 |
-
|
446 |
-
$reply = $this->credis->multi()->pipeline()
|
447 |
-
->incr('foo')
|
448 |
-
->incr('bar')
|
449 |
-
->exec();
|
450 |
-
$this->assertEquals(array(3,3), $reply);
|
451 |
-
|
452 |
-
$reply = $this->credis->multi()
|
453 |
-
->set('a', 3)
|
454 |
-
->lpop('a')
|
455 |
-
->exec();
|
456 |
-
$this->assertEquals(2, count($reply));
|
457 |
-
$this->assertEquals(TRUE, $reply[0]);
|
458 |
-
$this->assertFalse($reply[1]);
|
459 |
-
}
|
460 |
-
|
461 |
-
public function testServer()
|
462 |
-
{
|
463 |
-
$this->assertArrayHasKey('used_memory', $this->credis->info());
|
464 |
-
$this->assertArrayHasKey('maxmemory', $this->credis->config('GET', 'maxmemory'));
|
465 |
-
}
|
466 |
-
|
467 |
-
public function testScripts()
|
468 |
-
{
|
469 |
-
$this->assertNull($this->credis->evalSha('1111111111111111111111111111111111111111'));
|
470 |
-
$this->assertEquals(3, $this->credis->eval('return 3'));
|
471 |
-
$this->assertEquals('09d3822de862f46d784e6a36848b4f0736dda47a', $this->credis->script('load', 'return 3'));
|
472 |
-
$this->assertEquals(3, $this->credis->evalSha('09d3822de862f46d784e6a36848b4f0736dda47a'));
|
473 |
-
|
474 |
-
$this->credis->set('foo','FOO');
|
475 |
-
$this->assertEquals('FOOBAR', $this->credis->eval("return redis.call('get', KEYS[1])..ARGV[1]", 'foo', 'BAR'));
|
476 |
-
|
477 |
-
$this->assertEquals(array(1,2,'three'), $this->credis->eval("return {1,2,'three'}"));
|
478 |
-
try {
|
479 |
-
$this->credis->eval('this-is-not-lua');
|
480 |
-
$this->fail('Expected exception on invalid script.');
|
481 |
-
} catch(CredisException $e) {
|
482 |
-
}
|
483 |
-
}
|
484 |
-
|
485 |
-
public function testPubsub()
|
486 |
-
{
|
487 |
-
if (!$this->useStandalone && version_compare(PHP_VERSION, '7.0.0') >= 0) {
|
488 |
-
$ext = new ReflectionExtension('redis');
|
489 |
-
if (version_compare($ext->getVersion(), '3.1.4RC1') < 0) {
|
490 |
-
$this->fail('phpredis 3.1.4 is required for subscribe/pSubscribe not to segfault with php 7.x');
|
491 |
-
return;
|
492 |
-
}
|
493 |
-
}
|
494 |
-
$timeout = 2;
|
495 |
-
$time = microtime(true);
|
496 |
-
$this->credis->setReadTimeout($timeout);
|
497 |
-
try {
|
498 |
-
$testCase = $this;
|
499 |
-
$this->credis->pSubscribe(array('foobar','test*'), function ($credis, $pattern, $channel, $message) use ($testCase, &$time) {
|
500 |
-
$time = time(); // Reset timeout
|
501 |
-
// Test using: redis-cli publish foobar blah
|
502 |
-
$testCase->assertEquals('blah', $message);
|
503 |
-
});
|
504 |
-
$this->fail('pSubscribe should not return.');
|
505 |
-
} catch (CredisException $e) {
|
506 |
-
$this->assertEquals($timeout, intval(microtime(true) - $time));
|
507 |
-
if ($this->useStandalone) { // phpredis does not distinguish between timed out and disconnected
|
508 |
-
$this->assertEquals($e->getCode(), CredisException::CODE_TIMED_OUT);
|
509 |
-
} else {
|
510 |
-
$this->assertEquals($e->getCode(), CredisException::CODE_DISCONNECTED);
|
511 |
-
}
|
512 |
-
}
|
513 |
-
|
514 |
-
// Perform a new subscription. Client should have either unsubscribed or disconnected
|
515 |
-
$timeout = 2;
|
516 |
-
$time = microtime(true);
|
517 |
-
$this->credis->setReadTimeout($timeout);
|
518 |
-
try {
|
519 |
-
$testCase = $this;
|
520 |
-
$this->credis->subscribe('foobar', function ($credis, $channel, $message) use ($testCase, &$time) {
|
521 |
-
$time = time(); // Reset timeout
|
522 |
-
// Test using: redis-cli publish foobar blah
|
523 |
-
$testCase->assertEquals('blah', $message);
|
524 |
-
});
|
525 |
-
$this->fail('subscribe should not return.');
|
526 |
-
} catch (CredisException $e) {
|
527 |
-
$this->assertEquals($timeout, intval(microtime(true) - $time));
|
528 |
-
if ($this->useStandalone) { // phpredis does not distinguish between timed out and disconnected
|
529 |
-
$this->assertEquals($e->getCode(), CredisException::CODE_TIMED_OUT);
|
530 |
-
} else {
|
531 |
-
$this->assertEquals($e->getCode(), CredisException::CODE_DISCONNECTED);
|
532 |
-
}
|
533 |
-
}
|
534 |
-
}
|
535 |
-
public function testDb()
|
536 |
-
{
|
537 |
-
$this->tearDown();
|
538 |
-
$this->credis = new Credis_Client($this->redisConfig[0]['host'], $this->redisConfig[0]['port'], $this->redisConfig[0]['timeout'], false, 1);
|
539 |
-
if ($this->useStandalone) {
|
540 |
-
$this->credis->forceStandalone();
|
541 |
-
}
|
542 |
-
$this->assertTrue($this->credis->set('database',1));
|
543 |
-
$this->credis->close();
|
544 |
-
$this->credis = new Credis_Client($this->redisConfig[0]['host'], $this->redisConfig[0]['port'], $this->redisConfig[0]['timeout'], false, 0);
|
545 |
-
if ($this->useStandalone) {
|
546 |
-
$this->credis->forceStandalone();
|
547 |
-
}
|
548 |
-
$this->assertFalse($this->credis->get('database'));
|
549 |
-
$this->credis = new Credis_Client($this->redisConfig[0]['host'], $this->redisConfig[0]['port'], $this->redisConfig[0]['timeout'], false, 1);
|
550 |
-
if ($this->useStandalone) {
|
551 |
-
$this->credis->forceStandalone();
|
552 |
-
}
|
553 |
-
$this->assertEquals(1,$this->credis->get('database'));
|
554 |
-
}
|
555 |
-
|
556 |
-
/**
|
557 |
-
* @group Auth
|
558 |
-
*/
|
559 |
-
public function testPassword()
|
560 |
-
{
|
561 |
-
$this->tearDown();
|
562 |
-
$this->assertArrayHasKey('password',$this->redisConfig[4]);
|
563 |
-
$this->credis = new Credis_Client($this->redisConfig[4]['host'], $this->redisConfig[4]['port'], $this->redisConfig[4]['timeout'], false, 0, $this->redisConfig[4]['password']);
|
564 |
-
if ($this->useStandalone) {
|
565 |
-
$this->credis->forceStandalone();
|
566 |
-
}
|
567 |
-
$this->assertInstanceOf('Credis_Client',$this->credis->connect());
|
568 |
-
$this->assertTrue($this->credis->set('key','value'));
|
569 |
-
$this->credis->close();
|
570 |
-
$this->credis = new Credis_Client($this->redisConfig[4]['host'], $this->redisConfig[4]['port'], $this->redisConfig[4]['timeout'], false, 0, 'wrongpassword');
|
571 |
-
if ($this->useStandalone) {
|
572 |
-
$this->credis->forceStandalone();
|
573 |
-
}
|
574 |
-
try
|
575 |
-
{
|
576 |
-
$this->credis->connect();
|
577 |
-
$this->fail('connect should fail with wrong password');
|
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);
|
585 |
-
if ($this->useStandalone) {
|
586 |
-
$this->credis->forceStandalone();
|
587 |
-
}
|
588 |
-
try
|
589 |
-
{
|
590 |
-
$this->credis->set('key', 'value');
|
591 |
-
}
|
592 |
-
catch(CredisException $e)
|
593 |
-
{
|
594 |
-
$this->assertStringStartsWith('NOAUTH Authentication required', $e->getMessage());
|
595 |
-
}
|
596 |
-
try
|
597 |
-
{
|
598 |
-
$this->credis->auth('anotherwrongpassword');
|
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'));
|
606 |
-
}
|
607 |
-
|
608 |
-
public function testGettersAndSetters()
|
609 |
-
{
|
610 |
-
$this->assertEquals($this->credis->getHost(),$this->redisConfig[0]['host']);
|
611 |
-
$this->assertEquals($this->credis->getPort(),$this->redisConfig[0]['port']);
|
612 |
-
$this->assertEquals($this->credis->getSelectedDb(),0);
|
613 |
-
$this->assertTrue($this->credis->select(2));
|
614 |
-
$this->assertEquals($this->credis->getSelectedDb(),2);
|
615 |
-
$this->assertTrue($this->credis->isConnected());
|
616 |
-
$this->credis->close();
|
617 |
-
$this->assertFalse($this->credis->isConnected());
|
618 |
-
$this->credis = new Credis_Client($this->redisConfig[0]['host'], $this->redisConfig[0]['port'], null, 'persistenceId');
|
619 |
-
if ($this->useStandalone) {
|
620 |
-
$this->credis->forceStandalone();
|
621 |
-
}
|
622 |
-
$this->assertEquals('persistenceId',$this->credis->getPersistence());
|
623 |
-
$this->credis = new Credis_Client('localhost', 12345);
|
624 |
-
if ($this->useStandalone) {
|
625 |
-
$this->credis->forceStandalone();
|
626 |
-
}
|
627 |
-
$this->credis->setMaxConnectRetries(1);
|
628 |
-
$this->setExpectedExceptionShim('CredisException','Connection to Redis localhost:12345 failed after 2 failures.');
|
629 |
-
$this->credis->connect();
|
630 |
-
}
|
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 |
-
/**
|
663 |
-
* @group UnixSocket
|
664 |
-
*/
|
665 |
-
public function testConnectionStringsSocket()
|
666 |
-
{
|
667 |
-
$this->credis = new Credis_Client(realpath(__DIR__).'/redis.sock',0,null,'persistent');
|
668 |
-
if ($this->useStandalone) {
|
669 |
-
$this->credis->forceStandalone();
|
670 |
-
}
|
671 |
-
$this->credis->connect();
|
672 |
-
$this->credis->set('key','value');
|
673 |
-
$this->assertEquals('value',$this->credis->get('key'));
|
674 |
-
}
|
675 |
-
|
676 |
-
public function testInvalidTcpConnectionString()
|
677 |
-
{
|
678 |
-
$this->credis->close();
|
679 |
-
$this->setExpectedExceptionShim('CredisException','Invalid host format; expected tcp://host[:port][/persistence_identifier]');
|
680 |
-
$this->credis = new Credis_Client('tcp://'.$this->redisConfig[0]['host'] . ':abc');
|
681 |
-
if ($this->useStandalone) {
|
682 |
-
$this->credis->forceStandalone();
|
683 |
-
}
|
684 |
-
}
|
685 |
-
|
686 |
-
public function testInvalidTlsConnectionString()
|
687 |
-
{
|
688 |
-
$this->credis->close();
|
689 |
-
$this->setExpectedExceptionShim('CredisException','Invalid host format; expected tls://host[:port][/persistence_identifier]');
|
690 |
-
$this->credis = new Credis_Client('tls://'.$this->redisConfig[0]['host'] . ':abc');
|
691 |
-
if ($this->useStandalone) {
|
692 |
-
$this->credis->forceStandalone();
|
693 |
-
}
|
694 |
-
}
|
695 |
-
|
696 |
-
public function testInvalidUnixSocketConnectionString()
|
697 |
-
{
|
698 |
-
$this->credis->close();
|
699 |
-
$this->setExpectedExceptionShim('CredisException','Invalid unix socket format; expected unix:///path/to/redis.sock');
|
700 |
-
$this->credis = new Credis_Client('unix://path/to/redis.sock');
|
701 |
-
if ($this->useStandalone) {
|
702 |
-
$this->credis->forceStandalone();
|
703 |
-
}
|
704 |
-
}
|
705 |
-
|
706 |
-
public function testForceStandAloneAfterEstablishedConnection()
|
707 |
-
{
|
708 |
-
$this->credis->connect();
|
709 |
-
if ( ! $this->useStandalone) {
|
710 |
-
$this->setExpectedExceptionShim('CredisException','Cannot force Credis_Client to use standalone PHP driver after a connection has already been established.');
|
711 |
-
}
|
712 |
-
$this->credis->forceStandalone();
|
713 |
-
$this->assertTrue(true);
|
714 |
-
}
|
715 |
-
public function testHscan()
|
716 |
-
{
|
717 |
-
$this->credis->hmset('hash',array('name' => 'Jack','age' =>33));
|
718 |
-
$iterator = null;
|
719 |
-
$result = $this->credis->hscan($iterator,'hash','n*',10);
|
720 |
-
$this->assertEquals($iterator,0);
|
721 |
-
$this->assertEquals($result,['name'=>'Jack']);
|
722 |
-
}
|
723 |
-
public function testSscan()
|
724 |
-
{
|
725 |
-
$this->credis->sadd('set','name','Jack');
|
726 |
-
$this->credis->sadd('set','age','33');
|
727 |
-
$iterator = null;
|
728 |
-
$result = $this->credis->sscan($iterator,'set','n*',10);
|
729 |
-
$this->assertEquals($iterator,0);
|
730 |
-
$this->assertEquals($result,[0=>'name']);
|
731 |
-
}
|
732 |
-
public function testZscan()
|
733 |
-
{
|
734 |
-
$this->credis->zadd('sortedset',0,'name');
|
735 |
-
$this->credis->zadd('sortedset',1,'age');
|
736 |
-
$iterator = null;
|
737 |
-
$result = $this->credis->zscan($iterator,'sortedset','n*',10);
|
738 |
-
$this->assertEquals($iterator,0);
|
739 |
-
$this->assertEquals($result,['name'=>'0']);
|
740 |
-
}
|
741 |
-
public function testscan()
|
742 |
-
{
|
743 |
-
$seen = array();
|
744 |
-
for($i = 0; $i < 100; $i++)
|
745 |
-
{
|
746 |
-
$this->credis->set('name.' . $i, 'Jack');
|
747 |
-
$this->credis->set('age.' . $i, '33');
|
748 |
-
}
|
749 |
-
$iterator = null;
|
750 |
-
do
|
751 |
-
{
|
752 |
-
$result = $this->credis->scan($iterator, 'n*', 10);
|
753 |
-
if ($result === false)
|
754 |
-
{
|
755 |
-
$this->assertEquals($iterator, 0);
|
756 |
-
break;
|
757 |
-
}
|
758 |
-
else
|
759 |
-
{
|
760 |
-
foreach($result as $key)
|
761 |
-
{
|
762 |
-
$seen[$key] = true;
|
763 |
-
}
|
764 |
-
}
|
765 |
-
}
|
766 |
-
while($iterator);
|
767 |
-
$this->assertEquals(count($seen), 100);
|
768 |
-
}
|
769 |
-
|
770 |
-
public function testPing()
|
771 |
-
{
|
772 |
-
$pong = $this->credis->ping();
|
773 |
-
$this->assertEquals("PONG",$pong);
|
774 |
-
if (version_compare(phpversion('redis'), '5.0.0', '>='))
|
775 |
-
{
|
776 |
-
$pong = $this->credis->ping("test");
|
777 |
-
$this->assertEquals("test", $pong);
|
778 |
-
}
|
779 |
-
}
|
780 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
dependencies/colinmollenhour/credis/tests/CredisTestCommon.php
DELETED
@@ -1,170 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
// backward compatibility (https://stackoverflow.com/a/42828632/187780)
|
3 |
-
if (!class_exists('\PHPUnit\Framework\TestCase') && class_exists('\PHPUnit_Framework_TestCase')) {
|
4 |
-
class_alias('\PHPUnit_Framework_TestCase', '\PHPUnit\Framework\TestCase');
|
5 |
-
}
|
6 |
-
|
7 |
-
class CredisTestCommon extends \PHPUnit\Framework\TestCase
|
8 |
-
{
|
9 |
-
protected $useStandalone = false;
|
10 |
-
protected $redisConfig = null;
|
11 |
-
protected $slaveConfig = null;
|
12 |
-
|
13 |
-
protected function setUp()
|
14 |
-
{
|
15 |
-
if ($this->redisConfig === null)
|
16 |
-
{
|
17 |
-
$configFile = dirname(__FILE__) . '/redis_config.json';
|
18 |
-
if (!file_exists($configFile) || !($config = file_get_contents($configFile)))
|
19 |
-
{
|
20 |
-
$this->markTestSkipped('Could not load ' . $configFile);
|
21 |
-
|
22 |
-
return;
|
23 |
-
}
|
24 |
-
$this->redisConfig = json_decode($config);
|
25 |
-
$arrayConfig = array();
|
26 |
-
foreach ($this->redisConfig as $config)
|
27 |
-
{
|
28 |
-
$arrayConfig[] = (array)$config;
|
29 |
-
}
|
30 |
-
$this->redisConfig = $arrayConfig;
|
31 |
-
}
|
32 |
-
|
33 |
-
if(!$this->useStandalone && !extension_loaded('redis')) {
|
34 |
-
$this->fail('The Redis extension is not loaded.');
|
35 |
-
}
|
36 |
-
}
|
37 |
-
|
38 |
-
/**
|
39 |
-
* Verifies the slave has connected to the master and replication has caught up
|
40 |
-
*
|
41 |
-
* @return bool
|
42 |
-
*/
|
43 |
-
protected function waitForSlaveReplication()
|
44 |
-
{
|
45 |
-
if ($this->slaveConfig === null)
|
46 |
-
{
|
47 |
-
foreach ($this->redisConfig as $config)
|
48 |
-
{
|
49 |
-
if ($config['alias'] === 'slave')
|
50 |
-
{
|
51 |
-
$this->slaveConfig = $config;
|
52 |
-
break;
|
53 |
-
}
|
54 |
-
}
|
55 |
-
if ($this->slaveConfig === null)
|
56 |
-
{
|
57 |
-
$this->markTestSkipped('Could not load slave config');
|
58 |
-
|
59 |
-
return false;
|
60 |
-
}
|
61 |
-
}
|
62 |
-
$masterConfig = new Credis_Client($this->redisConfig[0]['host'], $this->redisConfig[0]['port']);
|
63 |
-
$masterConfig->forceStandalone();
|
64 |
-
|
65 |
-
$slaveConfig = new Credis_Client($this->slaveConfig['host'], $this->slaveConfig['port']);
|
66 |
-
$slaveConfig->forceStandalone();
|
67 |
-
|
68 |
-
$start = microtime(true);
|
69 |
-
$timeout = $start + 60;
|
70 |
-
while (microtime(true) < $timeout)
|
71 |
-
{
|
72 |
-
usleep(100);
|
73 |
-
$role = $slaveConfig->role();
|
74 |
-
if ($role[0] !== 'slave')
|
75 |
-
{
|
76 |
-
$this->markTestSkipped('slave config does not points to a slave');
|
77 |
-
return false;
|
78 |
-
}
|
79 |
-
if ($role[3] === 'connected')
|
80 |
-
{
|
81 |
-
$masterRole = $masterConfig->role();
|
82 |
-
if ($masterRole[0] !== 'master')
|
83 |
-
{
|
84 |
-
$this->markTestSkipped('master config does not points to a master');
|
85 |
-
return false;
|
86 |
-
}
|
87 |
-
if ($role[4] >= $masterRole[1])
|
88 |
-
{
|
89 |
-
return true;
|
90 |
-
}
|
91 |
-
}
|
92 |
-
}
|
93 |
-
// shouldn't get here
|
94 |
-
$this->fail("Timeout (".(microtime(true) - $start)." seconds) waiting for master-slave replication to finalize");
|
95 |
-
return false;
|
96 |
-
}
|
97 |
-
|
98 |
-
public static function setUpBeforeClass()
|
99 |
-
{
|
100 |
-
if(preg_match('/^WIN/',strtoupper(PHP_OS))){
|
101 |
-
echo "Unit tests will not work automatically on Windows. Please setup all Redis instances manually:".PHP_EOL;
|
102 |
-
echo "\tredis-server redis-master.conf".PHP_EOL;
|
103 |
-
echo "\tredis-server redis-slave.conf".PHP_EOL;
|
104 |
-
echo "\tredis-server redis-2.conf".PHP_EOL;
|
105 |
-
echo "\tredis-server redis-3.conf".PHP_EOL;
|
106 |
-
echo "\tredis-server redis-4.conf".PHP_EOL;
|
107 |
-
echo "\tredis-server redis-auth.conf".PHP_EOL;
|
108 |
-
echo "\tredis-server redis-socket.conf".PHP_EOL.PHP_EOL;
|
109 |
-
} else {
|
110 |
-
chdir(__DIR__);
|
111 |
-
$directoryIterator = new DirectoryIterator(__DIR__);
|
112 |
-
foreach($directoryIterator as $item){
|
113 |
-
if(!$item->isfile() || !preg_match('/^redis\-(.+)\.conf$/',$item->getFilename()) || $item->getFilename() == 'redis-sentinel.conf'){
|
114 |
-
continue;
|
115 |
-
}
|
116 |
-
exec('redis-server '.$item->getFilename());
|
117 |
-
}
|
118 |
-
copy('redis-master.conf','redis-master.conf.bak');
|
119 |
-
copy('redis-slave.conf','redis-slave.conf.bak');
|
120 |
-
// wait for redis instances to initialize
|
121 |
-
sleep(1);
|
122 |
-
}
|
123 |
-
}
|
124 |
-
|
125 |
-
public static function tearDownAfterClass()
|
126 |
-
{
|
127 |
-
if(preg_match('/^WIN/',strtoupper(PHP_OS))){
|
128 |
-
echo "Please kill all Redis instances manually:".PHP_EOL;
|
129 |
-
} else {
|
130 |
-
chdir(__DIR__);
|
131 |
-
$directoryIterator = new DirectoryIterator(__DIR__);
|
132 |
-
foreach($directoryIterator as $item){
|
133 |
-
if(!$item->isfile() || !preg_match('/^redis\-(.+)\.pid$/',$item->getFilename())){
|
134 |
-
continue;
|
135 |
-
}
|
136 |
-
$pid = trim(file_get_contents($item->getFilename()));
|
137 |
-
if(function_exists('posix_kill')){
|
138 |
-
posix_kill($pid,15);
|
139 |
-
} else {
|
140 |
-
exec('kill '.$pid);
|
141 |
-
}
|
142 |
-
}
|
143 |
-
sleep(1); // give teardown some time to finish
|
144 |
-
@unlink('dump.rdb');
|
145 |
-
@unlink('redis-master.conf');
|
146 |
-
@unlink('redis-slave.conf');
|
147 |
-
@copy('redis-master.conf.bak','redis-master.conf');
|
148 |
-
@copy('redis-slave.conf.bak','redis-slave.conf');
|
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
|
155 |
-
*/
|
156 |
-
public function setExpectedExceptionShim($class, $message = NULL, $code = NULL)
|
157 |
-
{
|
158 |
-
if (method_exists($this, 'setExpectedException')) {
|
159 |
-
$this->setExpectedException($class, $message, $code);
|
160 |
-
} else {
|
161 |
-
parent::expectException($class);
|
162 |
-
if ($message !== null) {
|
163 |
-
$this->expectExceptionMessage($message);
|
164 |
-
}
|
165 |
-
if ($code !== null) {
|
166 |
-
$this->expectExceptionCode($code);
|
167 |
-
}
|
168 |
-
}
|
169 |
-
}
|
170 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
dependencies/colinmollenhour/credis/tests/keys.test
DELETED
@@ -1,100 +0,0 @@
|
|
1 |
-
4a51973817aa0:4a51973817ab6
|
2 |
-
4a51973817b1b:4a51973817b29
|
3 |
-
4a51973817b43:4a51973817b50
|
4 |
-
4a51973817b61:4a51973817b6e
|
5 |
-
4a51973817b8a:4a51973817b96
|
6 |
-
4a51973817bad:4a51973817bba
|
7 |
-
4a51973817bd2:4a51973817bde
|
8 |
-
4a51973817bf6:4a51973817c01
|
9 |
-
4a51973817c19:4a51973817c24
|
10 |
-
4a51973817c3d:4a51973817c48
|
11 |
-
4a51973817c60:4a51973817c6b
|
12 |
-
4a51973817c83:4a51973817c8e
|
13 |
-
4a51973817ca7:4a51973817cb2
|
14 |
-
4a51973817cca:4a51973817cd5
|
15 |
-
4a51973817ced:4a51973817cf8
|
16 |
-
4a51973817d10:4a51973817d1c
|
17 |
-
4a51973817d33:4a51973817d3f
|
18 |
-
4a51973817d56:4a51973817d62
|
19 |
-
4a51973817d7a:4a51973817d86
|
20 |
-
4a51973817d9d:4a51973817da9
|
21 |
-
4a51973817dc1:4a51973817dcd
|
22 |
-
4a51973817de5:4a51973817df0
|
23 |
-
4a51973817e08:4a51973817e13
|
24 |
-
4a51973817e2b:4a51973817e37
|
25 |
-
4a51973817e4f:4a51973817e5a
|
26 |
-
4a51973817e72:4a51973817e7d
|
27 |
-
4a51973817e95:4a51973817ea1
|
28 |
-
4a51973817eb8:4a51973817ec4
|
29 |
-
4a51973817edb:4a51973817ee7
|
30 |
-
4a51973817eff:4a51973817f0b
|
31 |
-
4a51973817f22:4a51973817f2e
|
32 |
-
4a51973817f45:4a51973817f51
|
33 |
-
4a51973817f69:4a51973817f74
|
34 |
-
4a51973817f8c:4a51973817f98
|
35 |
-
4a51973817faf:4a51973817fbc
|
36 |
-
4a51973817fd4:4a51973817fdf
|
37 |
-
4a51973817ff7:4a51973818002
|
38 |
-
4a5197381801a:4a51973818026
|
39 |
-
4a5197381803d:4a51973818049
|
40 |
-
4a51973818060:4a5197381806c
|
41 |
-
4a51973818084:4a51973818090
|
42 |
-
4a519738180a7:4a519738180b3
|
43 |
-
4a519738180ca:4a519738180d6
|
44 |
-
4a519738180ee:4a519738180f9
|
45 |
-
4a51973818111:4a5197381811c
|
46 |
-
4a51973818134:4a5197381813f
|
47 |
-
4a51973818158:4a51973818163
|
48 |
-
4a5197381817b:4a51973818186
|
49 |
-
4a5197381819e:4a519738181a9
|
50 |
-
4a519738181c2:4a519738181cd
|
51 |
-
4a519738181e5:4a519738181f0
|
52 |
-
4a51973818208:4a51973818214
|
53 |
-
4a5197381822c:4a51973818237
|
54 |
-
4a5197381824f:4a5197381825a
|
55 |
-
4a51973818272:4a5197381827e
|
56 |
-
4a51973818296:4a519738182a1
|
57 |
-
4a519738182b9:4a519738182c4
|
58 |
-
4a519738182dc:4a519738182e8
|
59 |
-
4a519738182ff:4a5197381830b
|
60 |
-
4a51973818322:4a5197381832e
|
61 |
-
4a51973818346:4a51973818351
|
62 |
-
4a51973818369:4a51973818374
|
63 |
-
4a5197381838c:4a51973818397
|
64 |
-
4a519738183b0:4a519738183bc
|
65 |
-
4a519738183d3:4a519738183df
|
66 |
-
4a519738183f6:4a51973818403
|
67 |
-
4a5197381841b:4a51973818426
|
68 |
-
4a5197381843d:4a51973818449
|
69 |
-
4a51973818461:4a5197381846d
|
70 |
-
4a51973818484:4a51973818490
|
71 |
-
4a519738184a7:4a519738184b3
|
72 |
-
4a519738184cb:4a519738184d7
|
73 |
-
4a519738184ee:4a519738184fa
|
74 |
-
4a51973818511:4a5197381851d
|
75 |
-
4a51973818535:4a51973818540
|
76 |
-
4a51973818558:4a51973818563
|
77 |
-
4a5197381857b:4a51973818586
|
78 |
-
4a5197381859e:4a519738185aa
|
79 |
-
4a519738185c2:4a519738185ce
|
80 |
-
4a519738185e5:4a519738185f2
|
81 |
-
4a51973818609:4a51973818615
|
82 |
-
4a5197381862c:4a51973818637
|
83 |
-
4a51973818650:4a5197381865b
|
84 |
-
4a51973818673:4a5197381867e
|
85 |
-
4a51973818696:4a519738186a1
|
86 |
-
4a519738186b9:4a519738186c5
|
87 |
-
4a519738186dd:4a519738186e8
|
88 |
-
4a519738186ff:4a5197381870f
|
89 |
-
4a51973818721:4a51973818730
|
90 |
-
4a51973818747:4a51973818753
|
91 |
-
4a5197381876a:4a51973818776
|
92 |
-
4a5197381878e:4a5197381879a
|
93 |
-
4a519738187b1:4a519738187bd
|
94 |
-
4a519738187d5:4a519738187e1
|
95 |
-
4a519738187f9:4a51973818804
|
96 |
-
4a5197381881c:4a51973818827
|
97 |
-
4a51973818840:4a5197381884b
|
98 |
-
4a51973818863:4a5197381886e
|
99 |
-
4a51973818886:4a51973818892
|
100 |
-
4a519738188aa:4a519738188b5
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
dependencies/colinmollenhour/credis/tests/redis-2.conf
DELETED
@@ -1,5 +0,0 @@
|
|
1 |
-
daemonize yes
|
2 |
-
port 6380
|
3 |
-
dir ./
|
4 |
-
pidfile redis-2.pid
|
5 |
-
timeout 300
|
|
|
|
|
|
|
|
|
|
dependencies/colinmollenhour/credis/tests/redis-3.conf
DELETED
@@ -1,5 +0,0 @@
|
|
1 |
-
daemonize yes
|
2 |
-
port 6381
|
3 |
-
dir ./
|
4 |
-
pidfile redis-3.pid
|
5 |
-
timeout 300
|
|
|
|
|
|
|
|
|
|
dependencies/colinmollenhour/credis/tests/redis-4.conf
DELETED
@@ -1,5 +0,0 @@
|
|
1 |
-
daemonize yes
|
2 |
-
port 6382
|
3 |
-
dir ./
|
4 |
-
pidfile redis-4.pid
|
5 |
-
timeout 300
|
|
|
|
|
|
|
|
|
|
dependencies/colinmollenhour/credis/tests/redis-auth.conf
DELETED
@@ -1,6 +0,0 @@
|
|
1 |
-
daemonize yes
|
2 |
-
port 6383
|
3 |
-
dir ./
|
4 |
-
pidfile redis-auth.pid
|
5 |
-
timeout 300
|
6 |
-
requirepass "thepassword"
|
|
|
|
|
|
|
|
|
|
|
|
dependencies/colinmollenhour/credis/tests/redis-master.conf
DELETED
@@ -1,8 +0,0 @@
|
|
1 |
-
daemonize yes
|
2 |
-
port 6379
|
3 |
-
dir ./
|
4 |
-
pidfile redis-master.pid
|
5 |
-
timeout 300
|
6 |
-
save
|
7 |
-
repl-diskless-sync yes
|
8 |
-
repl-diskless-sync-delay 0
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
dependencies/colinmollenhour/credis/tests/redis-sentinel.conf
DELETED
@@ -1,6 +0,0 @@
|
|
1 |
-
daemonize yes
|
2 |
-
dir ./
|
3 |
-
pidfile redis-sentinel.pid
|
4 |
-
port 26379
|
5 |
-
sentinel monitor mymaster 127.0.0.1 6379 1
|
6 |
-
sentinel monitor masterdown 127.0.0.1 6399 1
|
|
|
|
|
|
|
|
|
|
|
|
dependencies/colinmollenhour/credis/tests/redis-slave.conf
DELETED
@@ -1,7 +0,0 @@
|
|
1 |
-
daemonize yes
|
2 |
-
port 6385
|
3 |
-
dir ./
|
4 |
-
pidfile redis-slave.pid
|
5 |
-
timeout 300
|
6 |
-
slaveof 127.0.0.1 6379
|
7 |
-
save
|
|
|
|
|
|
|
|
|
|
|
|
|
|
dependencies/colinmollenhour/credis/tests/redis-socket.conf
DELETED
@@ -1,6 +0,0 @@
|
|
1 |
-
daemonize yes
|
2 |
-
port 6384
|
3 |
-
dir ./
|
4 |
-
unixsocket redis.sock
|
5 |
-
unixsocketperm 755
|
6 |
-
pidfile redis-socket.pid
|
|
|
|
|
|
|
|
|
|
|
|
dependencies/colinmollenhour/credis/tests/redis_config.json
DELETED
@@ -1,9 +0,0 @@
|
|
1 |
-
[
|
2 |
-
{"host":"127.0.0.1","port":6379,"timeout":2.5,"alias":"master","master":true},
|
3 |
-
{"host":"127.0.0.1","port":6380,"timeout":2.5,"alias":"second"},
|
4 |
-
{"host":"127.0.0.1","port":6381,"timeout":2.5,"alias":"third"},
|
5 |
-
{"host":"127.0.0.1","port":6382,"timeout":2.5,"alias":"fourth"},
|
6 |
-
{"host":"127.0.0.1","port":6383,"timeout":2.5,"alias":"auth", "password": "thepassword"},
|
7 |
-
{"host":"127.0.0.1","port":6384,"timeout":2.5,"alias":"socket"},
|
8 |
-
{"host":"127.0.0.1","port":6385,"timeout":2.5,"alias":"slave"}
|
9 |
-
]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
dependencies/colinmollenhour/credis/tests/sentinel_config.json
DELETED
@@ -1 +0,0 @@
|
|
1 |
-
{"host":"127.0.0.1","port":26379,"clustername":"mymaster","downclustername":"masterdown"}
|
|
dependencies/predis/predis/CHANGELOG.md
CHANGED
@@ -1,13 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
v1.1.9 (2021-10-05)
|
2 |
================================================================================
|
3 |
|
4 |
-
- Fixed PHP 8.1 compatibility in `StreamConnection`
|
5 |
|
6 |
|
7 |
v1.1.8 (2021-09-29)
|
8 |
================================================================================
|
9 |
|
10 |
-
- Ensure compatibility with PHP 8.1.
|
11 |
|
12 |
|
13 |
v1.1.7 (2021-04-04)
|
1 |
+
v1.1.10 (2022-01-05)
|
2 |
+
================================================================================
|
3 |
+
|
4 |
+
- __FIX__: Avoid PHP 8.1 deprecation notices in `Session/Handler`
|
5 |
+
- __FIX__: Fixed "Cannot use object of type Predis\Response\Error as array"
|
6 |
+
error in `Connection/Aggregate/SentinelReplication`
|
7 |
+
|
8 |
+
|
9 |
v1.1.9 (2021-10-05)
|
10 |
================================================================================
|
11 |
|
12 |
+
- __FIX__: Fixed PHP 8.1 compatibility in `StreamConnection`
|
13 |
|
14 |
|
15 |
v1.1.8 (2021-09-29)
|
16 |
================================================================================
|
17 |
|
18 |
+
- __FIX__: Ensure compatibility with PHP 8.1.
|
19 |
|
20 |
|
21 |
v1.1.7 (2021-04-04)
|
dependencies/predis/predis/VERSION
CHANGED
@@ -1 +1 @@
|
|
1 |
-
1.1.
|
1 |
+
1.1.10
|
dependencies/predis/predis/composer.json
ADDED
@@ -0,0 +1,48 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"name": "predis/predis",
|
3 |
+
"type": "library",
|
4 |
+
"description": "Flexible and feature-complete Redis client for PHP and HHVM",
|
5 |
+
"keywords": ["nosql", "redis", "predis"],
|
6 |
+
"homepage": "http://github.com/predis/predis",
|
7 |
+
"license": "MIT",
|
8 |
+
"support": {
|
9 |
+
"issues": "https://github.com/predis/predis/issues"
|
10 |
+
},
|
11 |
+
"authors": [
|
12 |
+
{
|
13 |
+
"name": "Daniele Alessandri",
|
14 |
+
"email": "suppakilla@gmail.com",
|
15 |
+
"homepage": "http://clorophilla.net",
|
16 |
+
"role": "Creator & Maintainer"
|
17 |
+
},
|
18 |
+
{
|
19 |
+
"name": "Till Krüss",
|
20 |
+
"homepage": "https://till.im",
|
21 |
+
"role": "Maintainer"
|
22 |
+
}
|
23 |
+
],
|
24 |
+
"funding": [
|
25 |
+
{
|
26 |
+
"type": "github",
|
27 |
+
"url": "https://github.com/sponsors/tillkruss"
|
28 |
+
}
|
29 |
+
],
|
30 |
+
"require": {
|
31 |
+
"php": ">=5.3.9"
|
32 |
+
},
|
33 |
+
"require-dev": {
|
34 |
+
"phpunit/phpunit": "~4.8"
|
35 |
+
},
|
36 |
+
"suggest": {
|
37 |
+
"ext-phpiredis": "Allows faster serialization and deserialization of the Redis protocol",
|
38 |
+
"ext-curl": "Allows access to Webdis when paired with phpiredis"
|
39 |
+
},
|
40 |
+
"autoload": {
|
41 |
+
"psr-4": {
|
42 |
+
"Predis\\": "src/"
|
43 |
+
}
|
44 |
+
},
|
45 |
+
"scripts": {
|
46 |
+
"post-update-cmd": "@php -f tests/apply-patches.php"
|
47 |
+
}
|
48 |
+
}
|
dependencies/predis/predis/package.ini
CHANGED
@@ -10,7 +10,7 @@ name = "Predis"
|
|
10 |
desc = "Flexible and feature-complete Redis client for PHP and HHVM"
|
11 |
homepage = "http://github.com/nrk/predis"
|
12 |
license = "MIT"
|
13 |
-
version = "1.1.
|
14 |
stability = "stable"
|
15 |
channel = "pear.nrk.io"
|
16 |
|
10 |
desc = "Flexible and feature-complete Redis client for PHP and HHVM"
|
11 |
homepage = "http://github.com/nrk/predis"
|
12 |
license = "MIT"
|
13 |
+
version = "1.1.10"
|
14 |
stability = "stable"
|
15 |
channel = "pear.nrk.io"
|
16 |
|
dependencies/predis/predis/src/Client.php
CHANGED
@@ -40,7 +40,7 @@ use Predis\Transaction\MultiExec as MultiExecTransaction;
|
|
40 |
*/
|
41 |
class Client implements ClientInterface, \IteratorAggregate
|
42 |
{
|
43 |
-
const VERSION = '1.1.
|
44 |
|
45 |
protected $connection;
|
46 |
protected $options;
|
40 |
*/
|
41 |
class Client implements ClientInterface, \IteratorAggregate
|
42 |
{
|
43 |
+
const VERSION = '1.1.10';
|
44 |
|
45 |
protected $connection;
|
46 |
protected $options;
|
dependencies/predis/predis/src/Connection/Aggregate/SentinelReplication.php
CHANGED
@@ -20,6 +20,7 @@ use Predis\Connection\NodeConnectionInterface;
|
|
20 |
use Predis\Connection\Parameters;
|
21 |
use Predis\Replication\ReplicationStrategy;
|
22 |
use Predis\Replication\RoleException;
|
|
|
23 |
use Predis\Response\ErrorInterface as ErrorResponseInterface;
|
24 |
use Predis\Response\ServerException;
|
25 |
|
@@ -523,13 +524,17 @@ class SentinelReplication implements ReplicationInterface
|
|
523 |
* @param NodeConnectionInterface $connection Connection to a redis server.
|
524 |
* @param string $role Expected role of the server ("master", "slave" or "sentinel").
|
525 |
*
|
526 |
-
* @throws RoleException
|
527 |
*/
|
528 |
protected function assertConnectionRole(NodeConnectionInterface $connection, $role)
|
529 |
{
|
530 |
$role = strtolower($role);
|
531 |
$actualRole = $connection->executeCommand(RawCommand::create('ROLE'));
|
532 |
|
|
|
|
|
|
|
|
|
533 |
if ($role !== $actualRole[0]) {
|
534 |
throw new RoleException($connection, "Expected $role but got $actualRole[0] [$connection]");
|
535 |
}
|
20 |
use Predis\Connection\Parameters;
|
21 |
use Predis\Replication\ReplicationStrategy;
|
22 |
use Predis\Replication\RoleException;
|
23 |
+
use Predis\Response\Error;
|
24 |
use Predis\Response\ErrorInterface as ErrorResponseInterface;
|
25 |
use Predis\Response\ServerException;
|
26 |
|
524 |
* @param NodeConnectionInterface $connection Connection to a redis server.
|
525 |
* @param string $role Expected role of the server ("master", "slave" or "sentinel").
|
526 |
*
|
527 |
+
* @throws RoleException|ConnectionException
|
528 |
*/
|
529 |
protected function assertConnectionRole(NodeConnectionInterface $connection, $role)
|
530 |
{
|
531 |
$role = strtolower($role);
|
532 |
$actualRole = $connection->executeCommand(RawCommand::create('ROLE'));
|
533 |
|
534 |
+
if ($actualRole instanceof Error) {
|
535 |
+
throw new ConnectionException($connection, $actualRole->getMessage());
|
536 |
+
}
|
537 |
+
|
538 |
if ($role !== $actualRole[0]) {
|
539 |
throw new RoleException($connection, "Expected $role but got $actualRole[0] [$connection]");
|
540 |
}
|
dependencies/predis/predis/src/Session/Handler.php
CHANGED
@@ -65,6 +65,7 @@ class Handler implements \SessionHandlerInterface
|
|
65 |
/**
|
66 |
* {@inheritdoc}
|
67 |
*/
|
|
|
68 |
public function open($save_path, $session_id)
|
69 |
{
|
70 |
// NOOP
|
@@ -74,6 +75,7 @@ class Handler implements \SessionHandlerInterface
|
|
74 |
/**
|
75 |
* {@inheritdoc}
|
76 |
*/
|
|
|
77 |
public function close()
|
78 |
{
|
79 |
// NOOP
|
@@ -83,6 +85,7 @@ class Handler implements \SessionHandlerInterface
|
|
83 |
/**
|
84 |
* {@inheritdoc}
|
85 |
*/
|
|
|
86 |
public function gc($maxlifetime)
|
87 |
{
|
88 |
// NOOP
|
@@ -92,6 +95,7 @@ class Handler implements \SessionHandlerInterface
|
|
92 |
/**
|
93 |
* {@inheritdoc}
|
94 |
*/
|
|
|
95 |
public function read($session_id)
|
96 |
{
|
97 |
if ($data = $this->client->get($session_id)) {
|
@@ -103,6 +107,7 @@ class Handler implements \SessionHandlerInterface
|
|
103 |
/**
|
104 |
* {@inheritdoc}
|
105 |
*/
|
|
|
106 |
public function write($session_id, $session_data)
|
107 |
{
|
108 |
$this->client->setex($session_id, $this->ttl, $session_data);
|
@@ -113,6 +118,7 @@ class Handler implements \SessionHandlerInterface
|
|
113 |
/**
|
114 |
* {@inheritdoc}
|
115 |
*/
|
|
|
116 |
public function destroy($session_id)
|
117 |
{
|
118 |
$this->client->del($session_id);
|
65 |
/**
|
66 |
* {@inheritdoc}
|
67 |
*/
|
68 |
+
#[\ReturnTypeWillChange]
|
69 |
public function open($save_path, $session_id)
|
70 |
{
|
71 |
// NOOP
|
75 |
/**
|
76 |
* {@inheritdoc}
|
77 |
*/
|
78 |
+
#[\ReturnTypeWillChange]
|
79 |
public function close()
|
80 |
{
|
81 |
// NOOP
|
85 |
/**
|
86 |
* {@inheritdoc}
|
87 |
*/
|
88 |
+
#[\ReturnTypeWillChange]
|
89 |
public function gc($maxlifetime)
|
90 |
{
|
91 |
// NOOP
|
95 |
/**
|
96 |
* {@inheritdoc}
|
97 |
*/
|
98 |
+
#[\ReturnTypeWillChange]
|
99 |
public function read($session_id)
|
100 |
{
|
101 |
if ($data = $this->client->get($session_id)) {
|
107 |
/**
|
108 |
* {@inheritdoc}
|
109 |
*/
|
110 |
+
#[\ReturnTypeWillChange]
|
111 |
public function write($session_id, $session_data)
|
112 |
{
|
113 |
$this->client->setex($session_id, $this->ttl, $session_data);
|
118 |
/**
|
119 |
* {@inheritdoc}
|
120 |
*/
|
121 |
+
#[\ReturnTypeWillChange]
|
122 |
public function destroy($session_id)
|
123 |
{
|
124 |
$this->client->del($session_id);
|
includes/class-plugin.php
CHANGED
@@ -609,16 +609,20 @@ class Plugin {
|
|
609 |
}
|
610 |
|
611 |
if ( $this->object_cache_dropin_exists() ) {
|
612 |
-
$url = $this->action_link( 'update-dropin' );
|
613 |
-
|
614 |
if ( $this->validate_object_cache_dropin() ) {
|
615 |
if ( $this->object_cache_dropin_outdated() ) {
|
616 |
// translators: %s = Action link to update the drop-in.
|
617 |
-
$message = sprintf(
|
|
|
|
|
|
|
618 |
}
|
619 |
} else {
|
620 |
-
// translators: %s =
|
621 |
-
$message = sprintf(
|
|
|
|
|
|
|
622 |
}
|
623 |
|
624 |
if ( isset( $message ) ) {
|
609 |
}
|
610 |
|
611 |
if ( $this->object_cache_dropin_exists() ) {
|
|
|
|
|
612 |
if ( $this->validate_object_cache_dropin() ) {
|
613 |
if ( $this->object_cache_dropin_outdated() ) {
|
614 |
// translators: %s = Action link to update the drop-in.
|
615 |
+
$message = sprintf(
|
616 |
+
__( 'The Redis object cache drop-in is outdated. Please <a href="%s">update the drop-in</a>.', 'redis-cache' ),
|
617 |
+
$this->action_link( 'update-dropin' )
|
618 |
+
);
|
619 |
}
|
620 |
} else {
|
621 |
+
// translators: %s = Link to settings page.
|
622 |
+
$message = sprintf(
|
623 |
+
__( 'A foreign object cache drop-in was found. To use Redis for object caching, please <a href="%s">enable the drop-in</a>.', 'redis-cache' ),
|
624 |
+
esc_url( network_admin_url( $this->page ) )
|
625 |
+
);
|
626 |
}
|
627 |
|
628 |
if ( isset( $message ) ) {
|
includes/object-cache.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
* Plugin Name: Redis Object Cache Drop-In
|
4 |
* Plugin URI: http://wordpress.org/plugins/redis-cache/
|
5 |
* Description: A persistent object cache backend powered by Redis. Supports Predis, PhpRedis, Credis, HHVM, replication, clustering and WP-CLI.
|
6 |
-
* Version: 2.0.
|
7 |
* Author: Till Krüss
|
8 |
* Author URI: https://objectcache.pro
|
9 |
* License: GPLv3
|
@@ -36,6 +36,22 @@ function wp_cache_add( $key, $value, $group = '', $expiration = 0 ) {
|
|
36 |
return $wp_object_cache->add( $key, $value, $group, $expiration );
|
37 |
}
|
38 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
39 |
/**
|
40 |
* Closes the cache.
|
41 |
*
|
@@ -80,6 +96,20 @@ function wp_cache_delete( $key, $group = '', $time = 0 ) {
|
|
80 |
return $wp_object_cache->delete( $key, $group, $time );
|
81 |
}
|
82 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
83 |
/**
|
84 |
* Invalidate all items in the cache. If `WP_REDIS_SELECTIVE_FLUSH` is `true`,
|
85 |
* only keys prefixed with the `WP_REDIS_PREFIX` are flushed.
|
@@ -94,6 +124,17 @@ function wp_cache_flush( $delay = 0 ) {
|
|
94 |
return $wp_object_cache->flush( $delay );
|
95 |
}
|
96 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
97 |
/**
|
98 |
* Retrieve object from cache.
|
99 |
*
|
@@ -216,6 +257,22 @@ function wp_cache_set( $key, $value, $group = '', $expiration = 0 ) {
|
|
216 |
return $wp_object_cache->set( $key, $value, $group, $expiration );
|
217 |
}
|
218 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
219 |
/**
|
220 |
* Switch the internal blog id.
|
221 |
*
|
@@ -1060,6 +1117,30 @@ class WP_Object_Cache {
|
|
1060 |
return $this->add_or_replace( true, $key, $value, $group, $expiration );
|
1061 |
}
|
1062 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1063 |
/**
|
1064 |
* Replace a value in the cache.
|
1065 |
*
|
@@ -1242,6 +1323,85 @@ class WP_Object_Cache {
|
|
1242 |
return (bool) $result;
|
1243 |
}
|
1244 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1245 |
/**
|
1246 |
* Invalidate all items in the cache. If `WP_REDIS_SELECTIVE_FLUSH` is `true`,
|
1247 |
* only keys prefixed with the `WP_REDIS_PREFIX` are flushed.
|
@@ -1877,6 +2037,25 @@ LUA;
|
|
1877 |
return $result;
|
1878 |
}
|
1879 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1880 |
/**
|
1881 |
* Increment a Redis counter by the amount specified
|
1882 |
*
|
@@ -2045,7 +2224,7 @@ LUA;
|
|
2045 |
<?php echo (int) $this->cache_misses; ?>
|
2046 |
<br />
|
2047 |
<strong>Cache Size:</strong>
|
2048 |
-
<?php echo number_format( strlen( serialize( $this->cache ) ) / 1024, 2 ); ?>
|
2049 |
</p>
|
2050 |
<?php
|
2051 |
}
|
3 |
* Plugin Name: Redis Object Cache Drop-In
|
4 |
* Plugin URI: http://wordpress.org/plugins/redis-cache/
|
5 |
* Description: A persistent object cache backend powered by Redis. Supports Predis, PhpRedis, Credis, HHVM, replication, clustering and WP-CLI.
|
6 |
+
* Version: 2.0.25
|
7 |
* Author: Till Krüss
|
8 |
* Author URI: https://objectcache.pro
|
9 |
* License: GPLv3
|
36 |
return $wp_object_cache->add( $key, $value, $group, $expiration );
|
37 |
}
|
38 |
|
39 |
+
/**
|
40 |
+
* Adds multiple values to the cache in one call.
|
41 |
+
*
|
42 |
+
* @param array $data Array of keys and values to be set.
|
43 |
+
* @param string $group Optional. Where the cache contents are grouped. Default empty.
|
44 |
+
* @param int $expire Optional. When to expire the cache contents, in seconds.
|
45 |
+
* Default 0 (no expiration).
|
46 |
+
* @return bool[] Array of return values, grouped by key. Each value is either
|
47 |
+
* true on success, or false if cache key and group already exist.
|
48 |
+
*/
|
49 |
+
function wp_cache_add_multiple( array $data, $group = '', $expire = 0 ) {
|
50 |
+
global $wp_object_cache;
|
51 |
+
|
52 |
+
return $wp_object_cache->add_multiple( $data, $group, $expire );
|
53 |
+
}
|
54 |
+
|
55 |
/**
|
56 |
* Closes the cache.
|
57 |
*
|
96 |
return $wp_object_cache->delete( $key, $group, $time );
|
97 |
}
|
98 |
|
99 |
+
/**
|
100 |
+
* Deletes multiple values from the cache in one call.
|
101 |
+
*
|
102 |
+
* @param array $keys Array of keys under which the cache to deleted.
|
103 |
+
* @param string $group Optional. Where the cache contents are grouped. Default empty.
|
104 |
+
* @return bool[] Array of return values, grouped by key. Each value is either
|
105 |
+
* true on success, or false if the contents were not deleted.
|
106 |
+
*/
|
107 |
+
function wp_cache_delete_multiple( array $keys, $group = '' ) {
|
108 |
+
global $wp_object_cache;
|
109 |
+
|
110 |
+
return $wp_object_cache->delete_multiple( $keys, $group );
|
111 |
+
}
|
112 |
+
|
113 |
/**
|
114 |
* Invalidate all items in the cache. If `WP_REDIS_SELECTIVE_FLUSH` is `true`,
|
115 |
* only keys prefixed with the `WP_REDIS_PREFIX` are flushed.
|
124 |
return $wp_object_cache->flush( $delay );
|
125 |
}
|
126 |
|
127 |
+
/**
|
128 |
+
* Removes all cache items from the in-memory runtime cache.
|
129 |
+
*
|
130 |
+
* @return bool True on success, false on failure.
|
131 |
+
*/
|
132 |
+
function wp_cache_flush_runtime() {
|
133 |
+
global $wp_object_cache;
|
134 |
+
|
135 |
+
return $wp_object_cache->flush_runtime();
|
136 |
+
}
|
137 |
+
|
138 |
/**
|
139 |
* Retrieve object from cache.
|
140 |
*
|
257 |
return $wp_object_cache->set( $key, $value, $group, $expiration );
|
258 |
}
|
259 |
|
260 |
+
/**
|
261 |
+
* Sets multiple values to the cache in one call.
|
262 |
+
*
|
263 |
+
* @param array $data Array of keys and values to be set.
|
264 |
+
* @param string $group Optional. Where the cache contents are grouped. Default empty.
|
265 |
+
* @param int $expire Optional. When to expire the cache contents, in seconds.
|
266 |
+
* Default 0 (no expiration).
|
267 |
+
* @return bool[] Array of return values, grouped by key. Each value is either
|
268 |
+
* true on success, or false on failure.
|
269 |
+
*/
|
270 |
+
function wp_cache_set_multiple( array $data, $group = '', $expire = 0 ) {
|
271 |
+
global $wp_object_cache;
|
272 |
+
|
273 |
+
return $wp_object_cache->set_multiple( $data, $group, $expire );
|
274 |
+
}
|
275 |
+
|
276 |
/**
|
277 |
* Switch the internal blog id.
|
278 |
*
|
1117 |
return $this->add_or_replace( true, $key, $value, $group, $expiration );
|
1118 |
}
|
1119 |
|
1120 |
+
/**
|
1121 |
+
* Adds multiple values to the cache in one call.
|
1122 |
+
*
|
1123 |
+
* @param array $data Array of keys and values to be added.
|
1124 |
+
* @param string $group Optional. Where the cache contents are grouped.
|
1125 |
+
* @param int $expire Optional. When to expire the cache contents, in seconds.
|
1126 |
+
* Default 0 (no expiration).
|
1127 |
+
* @return bool[] Array of return values, grouped by key. Each value is either
|
1128 |
+
* true on success, or false if cache key and group already exist.
|
1129 |
+
*/
|
1130 |
+
public function add_multiple( array $data, $group = 'default', $expire = 0 ) {
|
1131 |
+
if ( function_exists( 'wp_suspend_cache_addition' ) && wp_suspend_cache_addition() ) {
|
1132 |
+
return array_combine( $data, array_fill( 0, count( $data ), false ) );
|
1133 |
+
}
|
1134 |
+
|
1135 |
+
$values = [];
|
1136 |
+
|
1137 |
+
foreach ( $data as $key => $value ) {
|
1138 |
+
$values[ $key ] = $this->add( $key, $value, $group, $expire );
|
1139 |
+
}
|
1140 |
+
|
1141 |
+
return $values;
|
1142 |
+
}
|
1143 |
+
|
1144 |
/**
|
1145 |
* Replace a value in the cache.
|
1146 |
*
|
1323 |
return (bool) $result;
|
1324 |
}
|
1325 |
|
1326 |
+
/**
|
1327 |
+
* Deletes multiple values from the cache in one call.
|
1328 |
+
*
|
1329 |
+
* @param array $keys Array of keys to be deleted.
|
1330 |
+
* @param string $group Optional. Where the cache contents are grouped.
|
1331 |
+
* @return bool[] Array of return values, grouped by key. Each value is either
|
1332 |
+
* true on success, or false if the contents were not deleted.
|
1333 |
+
*/
|
1334 |
+
public function delete_multiple( array $keys, $group = 'default' ) {
|
1335 |
+
if ( $this->redis_status() && method_exists( $this->redis, 'pipeline' ) ) {
|
1336 |
+
return $this->delete_multiple_at_once( $keys, $group );
|
1337 |
+
}
|
1338 |
+
|
1339 |
+
$values = [];
|
1340 |
+
|
1341 |
+
foreach ( $keys as $key ) {
|
1342 |
+
$values[ $key ] = $this->delete( $key, $group );
|
1343 |
+
}
|
1344 |
+
|
1345 |
+
return $values;
|
1346 |
+
}
|
1347 |
+
|
1348 |
+
/**
|
1349 |
+
* Deletes multiple values from the cache in one call.
|
1350 |
+
*
|
1351 |
+
* @param array $keys Array of keys to be deleted.
|
1352 |
+
* @param string $group Optional. Where the cache contents are grouped.
|
1353 |
+
* @return bool[] Array of return values, grouped by key. Each value is either
|
1354 |
+
* true on success, or false if the contents were not deleted.
|
1355 |
+
*/
|
1356 |
+
protected function delete_multiple_at_once( array $keys, $group = 'default' ) {
|
1357 |
+
if ( $this->is_ignored_group( $group ) ) {
|
1358 |
+
$results = [];
|
1359 |
+
|
1360 |
+
foreach ( $keys as $key ) {
|
1361 |
+
$derived_key = $this->build_key( $key, $group );
|
1362 |
+
|
1363 |
+
$results[ $key ] = isset( $this->cache[ $derived_key ] );
|
1364 |
+
|
1365 |
+
unset( $this->cache[ $derived_key ] );
|
1366 |
+
}
|
1367 |
+
|
1368 |
+
return $results;
|
1369 |
+
}
|
1370 |
+
|
1371 |
+
try {
|
1372 |
+
$tx = $this->redis->pipeline();
|
1373 |
+
|
1374 |
+
foreach ($keys as $key) {
|
1375 |
+
$derived_key = $this->build_key( (string) $key, $group );
|
1376 |
+
|
1377 |
+
$tx->del( $derived_key );
|
1378 |
+
|
1379 |
+
unset( $this->cache[ $derived_key ] );
|
1380 |
+
}
|
1381 |
+
|
1382 |
+
$results = array_map( function ( $response ) {
|
1383 |
+
return (bool) $this->parse_redis_response( $response );
|
1384 |
+
}, $tx->exec() );
|
1385 |
+
|
1386 |
+
return array_combine( $keys, $results );
|
1387 |
+
} catch ( Exception $exception ) {
|
1388 |
+
$this->handle_exception( $exception );
|
1389 |
+
|
1390 |
+
return array_combine( $keys, array_fill( 0, count( $keys ), false ) );
|
1391 |
+
}
|
1392 |
+
}
|
1393 |
+
|
1394 |
+
/**
|
1395 |
+
* Removes all cache items from the in-memory runtime cache.
|
1396 |
+
*
|
1397 |
+
* @return bool True on success, false on failure.
|
1398 |
+
*/
|
1399 |
+
public function flush_runtime() {
|
1400 |
+
$this->cache = [];
|
1401 |
+
|
1402 |
+
return true;
|
1403 |
+
}
|
1404 |
+
|
1405 |
/**
|
1406 |
* Invalidate all items in the cache. If `WP_REDIS_SELECTIVE_FLUSH` is `true`,
|
1407 |
* only keys prefixed with the `WP_REDIS_PREFIX` are flushed.
|
2037 |
return $result;
|
2038 |
}
|
2039 |
|
2040 |
+
/**
|
2041 |
+
* Sets multiple values to the cache in one call.
|
2042 |
+
*
|
2043 |
+
* @param array $data Array of key and value to be set.
|
2044 |
+
* @param string $group Optional. Where the cache contents are grouped.
|
2045 |
+
* @param int $expire Optional. When to expire the cache contents, in seconds.
|
2046 |
+
* Default 0 (no expiration).
|
2047 |
+
* @return bool[] Array of return values, grouped by key. Each value is always true.
|
2048 |
+
*/
|
2049 |
+
public function set_multiple( array $data, $group = 'default', $expiration = 0 ) {
|
2050 |
+
$values = [];
|
2051 |
+
|
2052 |
+
foreach ( $data as $key => $value ) {
|
2053 |
+
$values[ $key ] = $this->set( $key, $value, $group, $expiration );
|
2054 |
+
}
|
2055 |
+
|
2056 |
+
return $values;
|
2057 |
+
}
|
2058 |
+
|
2059 |
/**
|
2060 |
* Increment a Redis counter by the amount specified
|
2061 |
*
|
2224 |
<?php echo (int) $this->cache_misses; ?>
|
2225 |
<br />
|
2226 |
<strong>Cache Size:</strong>
|
2227 |
+
<?php echo number_format( strlen( serialize( $this->cache ) ) / 1024, 2 ); ?> KB
|
2228 |
</p>
|
2229 |
<?php
|
2230 |
}
|
languages/redis-cache.pot
CHANGED
@@ -1,17 +1,17 @@
|
|
1 |
-
# Copyright (C)
|
2 |
# This file is distributed under the GPLv3.
|
3 |
msgid ""
|
4 |
msgstr ""
|
5 |
-
"Project-Id-Version: Redis Object Cache 2.0.
|
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:
|
13 |
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
14 |
-
"X-Generator: WP-CLI 2.
|
15 |
"X-Domain: redis-cache\n"
|
16 |
|
17 |
#. Plugin Name of the plugin
|
@@ -26,7 +26,7 @@ msgid "https://wordpress.org/plugins/redis-cache/"
|
|
26 |
msgstr ""
|
27 |
|
28 |
#. Description of the plugin
|
29 |
-
msgid "A persistent object cache backend powered by Redis. Supports Predis, PhpRedis, Credis, HHVM, replication, clustering and WP-CLI."
|
30 |
msgstr ""
|
31 |
|
32 |
#. Author of the plugin
|
@@ -93,135 +93,134 @@ msgid "Not enough data collected, yet."
|
|
93 |
msgstr ""
|
94 |
|
95 |
#: includes/class-plugin.php:335
|
|
|
96 |
msgid "Enable object cache to collect data."
|
97 |
msgstr ""
|
98 |
|
99 |
-
#: includes/class-plugin.php:
|
100 |
#: includes/class-qm-collector.php:66
|
101 |
msgid "Disabled"
|
102 |
msgstr ""
|
103 |
|
104 |
-
#: includes/class-plugin.php:
|
105 |
msgid "Drop-in not installed"
|
106 |
msgstr ""
|
107 |
|
108 |
-
#: includes/class-plugin.php:
|
109 |
msgid "Drop-in is invalid"
|
110 |
msgstr ""
|
111 |
|
112 |
-
#: includes/class-plugin.php:
|
113 |
msgid "Connected"
|
114 |
msgstr ""
|
115 |
|
116 |
-
#: includes/class-plugin.php:
|
117 |
msgid "Not connected"
|
118 |
msgstr ""
|
119 |
|
120 |
-
#: includes/class-plugin.php:
|
121 |
#: includes/ui/tabs/overview.php:269
|
122 |
msgid "Unknown"
|
123 |
msgstr ""
|
124 |
|
125 |
-
|
126 |
-
#: includes/class-plugin.php:613
|
127 |
msgid "The Redis object cache drop-in is outdated. Please <a href=\"%s\">update the drop-in</a>."
|
128 |
msgstr ""
|
129 |
|
130 |
-
|
131 |
-
#: includes/class-plugin.php:617
|
132 |
msgid "A foreign object cache drop-in was found. To use Redis for object caching, please <a href=\"%s\">enable the drop-in</a>."
|
133 |
msgstr ""
|
134 |
|
135 |
-
#: includes/class-plugin.php:
|
136 |
msgid "Object cache flushed."
|
137 |
msgstr ""
|
138 |
|
139 |
-
#: includes/class-plugin.php:
|
140 |
msgid "Object cache could not be flushed."
|
141 |
msgstr ""
|
142 |
|
143 |
-
#: includes/class-plugin.php:
|
144 |
-
#: includes/cli/class-commands.php:
|
145 |
msgid "Object cache enabled."
|
146 |
msgstr ""
|
147 |
|
148 |
-
#: includes/class-plugin.php:
|
149 |
-
#: includes/cli/class-commands.php:
|
150 |
msgid "Object cache could not be enabled."
|
151 |
msgstr ""
|
152 |
|
153 |
-
#: includes/class-plugin.php:
|
154 |
-
#: includes/cli/class-commands.php:
|
155 |
msgid "Object cache disabled."
|
156 |
msgstr ""
|
157 |
|
158 |
-
#: includes/class-plugin.php:
|
159 |
-
#: includes/cli/class-commands.php:
|
160 |
msgid "Object cache could not be disabled."
|
161 |
msgstr ""
|
162 |
|
163 |
-
#: includes/class-plugin.php:
|
164 |
-
#: includes/cli/class-commands.php:
|
165 |
msgid "Updated object cache drop-in and enabled Redis object cache."
|
166 |
msgstr ""
|
167 |
|
168 |
-
#: includes/class-plugin.php:
|
169 |
-
#: includes/cli/class-commands.php:
|
170 |
msgid "Object cache drop-in could not be updated."
|
171 |
msgstr ""
|
172 |
|
173 |
-
#: includes/class-plugin.php:
|
174 |
msgid "Object Cache Pro!"
|
175 |
msgstr ""
|
176 |
|
177 |
#. translators: %s = Link to the plugin setting screen.
|
178 |
-
#: includes/class-plugin.php:
|
179 |
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>"
|
180 |
msgstr ""
|
181 |
|
182 |
-
#: includes/class-plugin.php:
|
183 |
msgid "Object Cache Pro + WooCommerce = ❤️"
|
184 |
msgstr ""
|
185 |
|
186 |
#. translators: %s = Link to the plugin's settings screen.
|
187 |
-
#: includes/class-plugin.php:
|
188 |
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>"
|
189 |
msgstr ""
|
190 |
|
191 |
#. translators: %1$d = number of objects. %2$s = human-readable size of cache. %3$s = name of the used client.
|
192 |
-
#: includes/class-plugin.php:
|
193 |
msgid "Retrieved %1$d objects (%2$s) from Redis using %3$s."
|
194 |
msgstr ""
|
195 |
|
196 |
-
#: includes/class-plugin.php:
|
197 |
msgid "Could not initialize filesystem."
|
198 |
msgstr ""
|
199 |
|
200 |
-
#: includes/class-plugin.php:
|
201 |
msgid "Object cache file doesn’t exist."
|
202 |
msgstr ""
|
203 |
|
204 |
-
#: includes/class-plugin.php:
|
205 |
msgid "Test file exists, but couldn’t be deleted."
|
206 |
msgstr ""
|
207 |
|
208 |
-
#: includes/class-plugin.php:
|
209 |
msgid "Content directory is not writable."
|
210 |
msgstr ""
|
211 |
|
212 |
-
#: includes/class-plugin.php:
|
213 |
msgid "Failed to copy test file."
|
214 |
msgstr ""
|
215 |
|
216 |
-
#: includes/class-plugin.php:
|
217 |
msgid "Copied test file doesn’t exist."
|
218 |
msgstr ""
|
219 |
|
220 |
-
#: includes/class-plugin.php:
|
221 |
msgid "Couldn’t verify test file contents."
|
222 |
msgstr ""
|
223 |
|
224 |
-
#: includes/class-plugin.php:
|
225 |
msgid "Copied test file couldn’t be deleted."
|
226 |
msgstr ""
|
227 |
|
@@ -242,16 +241,16 @@ msgstr ""
|
|
242 |
msgid "WordPress is using a foreign object cache drop-in and Redis Object Cache is not being used. Use WP CLI or go to \"Settings -> Redis\" to enable drop-in."
|
243 |
msgstr ""
|
244 |
|
245 |
-
#: includes/cli/class-commands.php:
|
246 |
msgid "Redis object cache already enabled."
|
247 |
msgstr ""
|
248 |
|
249 |
-
#: includes/cli/class-commands.php:
|
250 |
-
#: includes/cli/class-commands.php:
|
251 |
msgid "A foreign object cache drop-in was found. To use Redis for object caching, run: `wp redis update-dropin`."
|
252 |
msgstr ""
|
253 |
|
254 |
-
#: includes/cli/class-commands.php:
|
255 |
msgid "No object cache drop-in found."
|
256 |
msgstr ""
|
257 |
|
@@ -490,7 +489,6 @@ msgstr ""
|
|
490 |
msgid "Connection Timeout:"
|
491 |
msgstr ""
|
492 |
|
493 |
-
#. translators: %s = Redis connection/read timeout in seconds.
|
494 |
#. translators: %s = Redis connection/read timeout in seconds.
|
495 |
#: includes/ui/tabs/overview.php:223
|
496 |
#: includes/ui/tabs/overview.php:240
|
1 |
+
# Copyright (C) 2022 Till Krüss
|
2 |
# This file is distributed under the GPLv3.
|
3 |
msgid ""
|
4 |
msgstr ""
|
5 |
+
"Project-Id-Version: Redis Object Cache 2.0.24\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: 2022-04-16T21:43:24+00:00\n"
|
13 |
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
14 |
+
"X-Generator: WP-CLI 2.6.0\n"
|
15 |
"X-Domain: redis-cache\n"
|
16 |
|
17 |
#. Plugin Name of the plugin
|
26 |
msgstr ""
|
27 |
|
28 |
#. Description of the plugin
|
29 |
+
msgid "A persistent object cache backend powered by Redis. Supports Predis, PhpRedis, Relay, Credis, HHVM, replication, clustering and WP-CLI."
|
30 |
msgstr ""
|
31 |
|
32 |
#. Author of the plugin
|
93 |
msgstr ""
|
94 |
|
95 |
#: includes/class-plugin.php:335
|
96 |
+
#: includes/cli/class-commands.php:50
|
97 |
msgid "Enable object cache to collect data."
|
98 |
msgstr ""
|
99 |
|
100 |
+
#: includes/class-plugin.php:481
|
101 |
#: includes/class-qm-collector.php:66
|
102 |
msgid "Disabled"
|
103 |
msgstr ""
|
104 |
|
105 |
+
#: includes/class-plugin.php:485
|
106 |
msgid "Drop-in not installed"
|
107 |
msgstr ""
|
108 |
|
109 |
+
#: includes/class-plugin.php:489
|
110 |
msgid "Drop-in is invalid"
|
111 |
msgstr ""
|
112 |
|
113 |
+
#: includes/class-plugin.php:494
|
114 |
msgid "Connected"
|
115 |
msgstr ""
|
116 |
|
117 |
+
#: includes/class-plugin.php:495
|
118 |
msgid "Not connected"
|
119 |
msgstr ""
|
120 |
|
121 |
+
#: includes/class-plugin.php:498
|
122 |
#: includes/ui/tabs/overview.php:269
|
123 |
msgid "Unknown"
|
124 |
msgstr ""
|
125 |
|
126 |
+
#: includes/class-plugin.php:616
|
|
|
127 |
msgid "The Redis object cache drop-in is outdated. Please <a href=\"%s\">update the drop-in</a>."
|
128 |
msgstr ""
|
129 |
|
130 |
+
#: includes/class-plugin.php:623
|
|
|
131 |
msgid "A foreign object cache drop-in was found. To use Redis for object caching, please <a href=\"%s\">enable the drop-in</a>."
|
132 |
msgstr ""
|
133 |
|
134 |
+
#: includes/class-plugin.php:661
|
135 |
msgid "Object cache flushed."
|
136 |
msgstr ""
|
137 |
|
138 |
+
#: includes/class-plugin.php:667
|
139 |
msgid "Object cache could not be flushed."
|
140 |
msgstr ""
|
141 |
|
142 |
+
#: includes/class-plugin.php:697
|
143 |
+
#: includes/cli/class-commands.php:112
|
144 |
msgid "Object cache enabled."
|
145 |
msgstr ""
|
146 |
|
147 |
+
#: includes/class-plugin.php:703
|
148 |
+
#: includes/cli/class-commands.php:114
|
149 |
msgid "Object cache could not be enabled."
|
150 |
msgstr ""
|
151 |
|
152 |
+
#: includes/class-plugin.php:723
|
153 |
+
#: includes/cli/class-commands.php:153
|
154 |
msgid "Object cache disabled."
|
155 |
msgstr ""
|
156 |
|
157 |
+
#: includes/class-plugin.php:729
|
158 |
+
#: includes/cli/class-commands.php:155
|
159 |
msgid "Object cache could not be disabled."
|
160 |
msgstr ""
|
161 |
|
162 |
+
#: includes/class-plugin.php:754
|
163 |
+
#: includes/cli/class-commands.php:187
|
164 |
msgid "Updated object cache drop-in and enabled Redis object cache."
|
165 |
msgstr ""
|
166 |
|
167 |
+
#: includes/class-plugin.php:760
|
168 |
+
#: includes/cli/class-commands.php:189
|
169 |
msgid "Object cache drop-in could not be updated."
|
170 |
msgstr ""
|
171 |
|
172 |
+
#: includes/class-plugin.php:827
|
173 |
msgid "Object Cache Pro!"
|
174 |
msgstr ""
|
175 |
|
176 |
#. translators: %s = Link to the plugin setting screen.
|
177 |
+
#: includes/class-plugin.php:830
|
178 |
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>"
|
179 |
msgstr ""
|
180 |
|
181 |
+
#: includes/class-plugin.php:867
|
182 |
msgid "Object Cache Pro + WooCommerce = ❤️"
|
183 |
msgstr ""
|
184 |
|
185 |
#. translators: %s = Link to the plugin's settings screen.
|
186 |
+
#: includes/class-plugin.php:870
|
187 |
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>"
|
188 |
msgstr ""
|
189 |
|
190 |
#. translators: %1$d = number of objects. %2$s = human-readable size of cache. %3$s = name of the used client.
|
191 |
+
#: includes/class-plugin.php:936
|
192 |
msgid "Retrieved %1$d objects (%2$s) from Redis using %3$s."
|
193 |
msgstr ""
|
194 |
|
195 |
+
#: includes/class-plugin.php:993
|
196 |
msgid "Could not initialize filesystem."
|
197 |
msgstr ""
|
198 |
|
199 |
+
#: includes/class-plugin.php:1000
|
200 |
msgid "Object cache file doesn’t exist."
|
201 |
msgstr ""
|
202 |
|
203 |
+
#: includes/class-plugin.php:1005
|
204 |
msgid "Test file exists, but couldn’t be deleted."
|
205 |
msgstr ""
|
206 |
|
207 |
+
#: includes/class-plugin.php:1010
|
208 |
msgid "Content directory is not writable."
|
209 |
msgstr ""
|
210 |
|
211 |
+
#: includes/class-plugin.php:1014
|
212 |
msgid "Failed to copy test file."
|
213 |
msgstr ""
|
214 |
|
215 |
+
#: includes/class-plugin.php:1018
|
216 |
msgid "Copied test file doesn’t exist."
|
217 |
msgstr ""
|
218 |
|
219 |
+
#: includes/class-plugin.php:1024
|
220 |
msgid "Couldn’t verify test file contents."
|
221 |
msgstr ""
|
222 |
|
223 |
+
#: includes/class-plugin.php:1028
|
224 |
msgid "Copied test file couldn’t be deleted."
|
225 |
msgstr ""
|
226 |
|
241 |
msgid "WordPress is using a foreign object cache drop-in and Redis Object Cache is not being used. Use WP CLI or go to \"Settings -> Redis\" to enable drop-in."
|
242 |
msgstr ""
|
243 |
|
244 |
+
#: includes/cli/class-commands.php:94
|
245 |
msgid "Redis object cache already enabled."
|
246 |
msgstr ""
|
247 |
|
248 |
+
#: includes/cli/class-commands.php:96
|
249 |
+
#: includes/cli/class-commands.php:146
|
250 |
msgid "A foreign object cache drop-in was found. To use Redis for object caching, run: `wp redis update-dropin`."
|
251 |
msgstr ""
|
252 |
|
253 |
+
#: includes/cli/class-commands.php:140
|
254 |
msgid "No object cache drop-in found."
|
255 |
msgstr ""
|
256 |
|
489 |
msgid "Connection Timeout:"
|
490 |
msgstr ""
|
491 |
|
|
|
492 |
#. translators: %s = Redis connection/read timeout in seconds.
|
493 |
#: includes/ui/tabs/overview.php:223
|
494 |
#: includes/ui/tabs/overview.php:240
|
readme.txt
CHANGED
@@ -5,7 +5,7 @@ Tags: redis, predis, phpredis, credis, hhvm, pecl, relay, caching, cache, object
|
|
5 |
Requires at least: 3.3
|
6 |
Tested up to: 5.9
|
7 |
Requires PHP: 5.6
|
8 |
-
Stable tag: 2.0.
|
9 |
License: GPLv3
|
10 |
License URI: http://www.gnu.org/licenses/gpl-3.0.html
|
11 |
|
@@ -83,10 +83,27 @@ To see a list of all available WP-CLI commands, please see the [WP CLI commands
|
|
83 |
|
84 |
== Changelog ==
|
85 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
86 |
= 2.0.23 =
|
87 |
|
88 |
-
- Added support for Relay
|
89 |
- Minor UX fixes and improvements
|
|
|
90 |
- Updated ApexCharts to v3.31.0
|
91 |
|
92 |
= 2.0.22 =
|
@@ -531,6 +548,6 @@ Since Predis isn't maintained any longer, it's highly recommended to switch over
|
|
531 |
|
532 |
== Upgrade Notice ==
|
533 |
|
534 |
-
= 2.0.
|
535 |
|
536 |
-
|
5 |
Requires at least: 3.3
|
6 |
Tested up to: 5.9
|
7 |
Requires PHP: 5.6
|
8 |
+
Stable tag: 2.0.25
|
9 |
License: GPLv3
|
10 |
License URI: http://www.gnu.org/licenses/gpl-3.0.html
|
11 |
|
83 |
|
84 |
== Changelog ==
|
85 |
|
86 |
+
= 2.0.25 =
|
87 |
+
|
88 |
+
- Removed broken `wp_cache_add_multiple()` function
|
89 |
+
|
90 |
+
= 2.0.24 =
|
91 |
+
|
92 |
+
- Improve metrics label/tooltip formatting
|
93 |
+
- Fix metrics chart not rendering
|
94 |
+
- Updated Predis to v1.1.10
|
95 |
+
- Updated Credis to v1.13.0
|
96 |
+
- Support `composer/installers` v1 and v2
|
97 |
+
- Link to settings page when foreign drop-in was found
|
98 |
+
- Added `wp_cache_flush_runtime()` function
|
99 |
+
- Added `wp_cache_add_multiple()` function
|
100 |
+
- Added `wp_cache_delete_multiple()` function
|
101 |
+
|
102 |
= 2.0.23 =
|
103 |
|
104 |
+
- Added support for [Relay](https://relaycache.com)
|
105 |
- Minor UX fixes and improvements
|
106 |
+
- Fixed PHP 8.1 deprecation notice
|
107 |
- Updated ApexCharts to v3.31.0
|
108 |
|
109 |
= 2.0.22 =
|
548 |
|
549 |
== Upgrade Notice ==
|
550 |
|
551 |
+
= 2.0.25 =
|
552 |
|
553 |
+
Various fixes and improvements.
|
redis-cache.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
* Plugin Name: Redis Object Cache
|
4 |
* Plugin URI: https://wordpress.org/plugins/redis-cache/
|
5 |
* Description: A persistent object cache backend powered by Redis. Supports Predis, PhpRedis, Relay, Credis, HHVM, replication, clustering and WP-CLI.
|
6 |
-
* Version: 2.0.
|
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, Relay, Credis, HHVM, replication, clustering and WP-CLI.
|
6 |
+
* Version: 2.0.25
|
7 |
* Text Domain: redis-cache
|
8 |
* Domain Path: /languages
|
9 |
* Network: true
|