Version Description
- Updated bundled Predis library to v1.1.4
- Made
redis-cache
a global group for improved metrics on multisite - Switched to short array syntax
- Added
@since
tags to all functions - Use
parse_url()
instead ofwp_parse_url()
in drop-in - Fixed plugin instance variable name in
wp redis status
Download this release
Release Info
Developer | tillkruess |
Plugin | Redis Object Cache |
Version | 2.0.13 |
Comparing to | |
See all releases |
Code changes from version 2.0.12 to 2.0.13
- dependencies/predis/predis/.github/FUNDING.yml +0 -2
- dependencies/predis/predis/.php_cs.dist +0 -33
- dependencies/predis/predis/CHANGELOG.md +46 -0
- dependencies/predis/predis/CONTRIBUTING.md +1 -1
- dependencies/predis/predis/FAQ.md +1 -1
- dependencies/predis/predis/README.md +12 -13
- dependencies/predis/predis/VERSION +1 -1
- dependencies/predis/predis/bin/create-pear +2 -2
- dependencies/predis/predis/composer.json +21 -7
- dependencies/predis/predis/package.ini +1 -1
- dependencies/predis/predis/src/Client.php +4 -2
- dependencies/predis/predis/src/ClientContextInterface.php +3 -2
- dependencies/predis/predis/src/ClientInterface.php +148 -147
- dependencies/predis/predis/src/Cluster/Distributor/HashRing.php +1 -1
- dependencies/predis/predis/src/Connection/Factory.php +7 -3
- dependencies/predis/predis/src/Replication/ReplicationStrategy.php +0 -26
- dependencies/predis/predis/tests/README.md +82 -0
- dependencies/predis/predis/tests/phpunit_mock_objects.patch +38 -0
- dependencies/predis/predis/tests/phpunit_php7.patch +60 -0
- dependencies/predis/predis/tests/phpunit_php8.patch +39 -0
- includes/class-plugin.php +86 -35
- includes/cli/class-commands.php +1 -1
- includes/object-cache.php +138 -21
- includes/ui/class-tab.php +42 -2
- includes/ui/diagnostics.php +2 -2
- readme.txt +11 -2
- redis-cache.php +1 -1
dependencies/predis/predis/.github/FUNDING.yml
DELETED
@@ -1,2 +0,0 @@
|
|
1 |
-
github: tillkruss
|
2 |
-
custom: "https://www.paypal.me/tillkruss"
|
|
|
|
dependencies/predis/predis/.php_cs.dist
DELETED
@@ -1,33 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
$PREDIS_HEADER = <<<EOS
|
4 |
-
This file is part of the Predis package.
|
5 |
-
|
6 |
-
(c) Daniele Alessandri <suppakilla@gmail.com>
|
7 |
-
|
8 |
-
For the full copyright and license information, please view the LICENSE
|
9 |
-
file that was distributed with this source code.
|
10 |
-
EOS;
|
11 |
-
|
12 |
-
return PhpCsFixer\Config::create()
|
13 |
-
->setUsingCache(true)
|
14 |
-
->setRules(array(
|
15 |
-
'@Symfony' => true,
|
16 |
-
'header_comment' => array(
|
17 |
-
'header' => $PREDIS_HEADER,
|
18 |
-
),
|
19 |
-
'ordered_imports' => true,
|
20 |
-
'phpdoc_order' => true,
|
21 |
-
'binary_operator_spaces' => array(
|
22 |
-
'align_double_arrow' => false,
|
23 |
-
'align_equals' => false,
|
24 |
-
),
|
25 |
-
'array_syntax' => array('syntax' => 'long'),
|
26 |
-
))
|
27 |
-
->setFinder(
|
28 |
-
PhpCsFixer\Finder::create()
|
29 |
-
->in(__DIR__.'/bin')
|
30 |
-
->in(__DIR__.'/src')
|
31 |
-
->in(__DIR__.'/tests')
|
32 |
-
->in(__DIR__.'/examples')
|
33 |
-
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
dependencies/predis/predis/CHANGELOG.md
CHANGED
@@ -1,3 +1,49 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
v1.1.2 (2020-08-11)
|
2 |
================================================================================
|
3 |
|
1 |
+
v1.1.4 (2020-08-31)
|
2 |
+
================================================================================
|
3 |
+
|
4 |
+
- Improved @method annotations for methods responding to Redis commands defined
|
5 |
+
by `Predis\ClientInterface` and `Predis\ClientContextInterface`. (PR #456 and
|
6 |
+
PR #497, other fixes applied after further analysys).
|
7 |
+
|
8 |
+
- __FIX__: the client can now handle ACL authentication when connecting to Redis
|
9 |
+
6.x simply by passing both `username` and `password` to connection parameters.
|
10 |
+
See [the Redis docs](https://redis.io/topics/acl) for details on this topic.
|
11 |
+
|
12 |
+
- __FIX__: NULL or zero-length string values passed to `password` and `database`
|
13 |
+
in the connection parameters list do not trigger spurious `AUTH` and `SELECT`
|
14 |
+
commands anymore when connecting to Redis (ISSUE #436).
|
15 |
+
|
16 |
+
- __FIX__: initializing an iteration over a client instance when it is connected
|
17 |
+
to a standalone Redis server will not throw an exception anymore, instead it
|
18 |
+
will return an iterator that will run for just one loop returning a new client
|
19 |
+
instance using the underlying single-node connection (ISSUE #552, PR #556).
|
20 |
+
|
21 |
+
- __FIX__: `Predis\Cluster\Distributor\HashRingaddNodeToRing()` was calculating
|
22 |
+
the hash required for distribution by using `crc32()` directly instead of the
|
23 |
+
method `Predis\Cluster\Hash\HashGeneratorInterface::hash()` implemented by the
|
24 |
+
class itself. This bug fix does not have any impact on existing clusters that
|
25 |
+
use client-side sharding based on this distributor simply because it does not
|
26 |
+
take any external hash generators so distribution is not going to be affected.
|
27 |
+
|
28 |
+
- __FIX__: `SORT` now always trigger a switch to the master node in replication
|
29 |
+
configurations instead of just when the `STORE` modifier is specified, this is
|
30 |
+
because `SORT` is always considered to be a write operation and actually fails
|
31 |
+
with a `-READONLY` error response when executed against a replica node. (ISSUE
|
32 |
+
#554).
|
33 |
+
|
34 |
+
|
35 |
+
v1.1.3 (2020-08-18)
|
36 |
+
================================================================================
|
37 |
+
|
38 |
+
- Ensure compatibility with PHP 8.
|
39 |
+
|
40 |
+
- Moved repository from `github.com/nrk/predis` to `github.com/predis/predis`.
|
41 |
+
|
42 |
+
- __FIX__: Moved `cweagans/composer-patches` dependency to `require-dev`.
|
43 |
+
|
44 |
+
- __FIX__: Include PHPUnit `.patch` files in exports.
|
45 |
+
|
46 |
+
|
47 |
v1.1.2 (2020-08-11)
|
48 |
================================================================================
|
49 |
|
dependencies/predis/predis/CONTRIBUTING.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
## Filing bug reports ##
|
2 |
|
3 |
-
Bugs or feature requests can be posted on the [GitHub issues](http://github.com/
|
4 |
section of the project.
|
5 |
|
6 |
When reporting bugs, in addition to the obvious description of your issue you __must__ always provide
|
1 |
## Filing bug reports ##
|
2 |
|
3 |
+
Bugs or feature requests can be posted on the [GitHub issues](http://github.com/predis/predis/issues)
|
4 |
section of the project.
|
5 |
|
6 |
When reporting bugs, in addition to the obvious description of your issue you __must__ always provide
|
dependencies/predis/predis/FAQ.md
CHANGED
@@ -33,7 +33,7 @@ usually something that developers prefer to customize depending on their needs a
|
|
33 |
generalized when using Redis because of the many possible access patterns for your data. This does
|
34 |
not mean that it is impossible to have such a feature since you can leverage the extensibility of
|
35 |
this library to define your own serialization-aware commands. You can find more details about how to
|
36 |
-
do that [on this issue](http://github.com/
|
37 |
|
38 |
### How can I force Predis to connect to Redis before sending any command? ###
|
39 |
|
33 |
generalized when using Redis because of the many possible access patterns for your data. This does
|
34 |
not mean that it is impossible to have such a feature since you can leverage the extensibility of
|
35 |
this library to define your own serialization-aware commands. You can find more details about how to
|
36 |
+
do that [on this issue](http://github.com/predis/predis/issues/29#issuecomment-1202624).
|
37 |
|
38 |
### How can I force Predis to connect to Redis before sending any command? ###
|
39 |
|
dependencies/predis/predis/README.md
CHANGED
@@ -5,14 +5,12 @@
|
|
5 |
[![Latest development][ico-version-dev]][link-packagist]
|
6 |
[![Monthly installs][ico-downloads-monthly]][link-downloads]
|
7 |
[![Build status][ico-travis]][link-travis]
|
8 |
-
[![Gitter room][ico-gitter]][link-gitter]
|
9 |
|
10 |
Flexible and feature-complete [Redis](http://redis.io) client for PHP >= 5.3 and HHVM >= 2.3.0.
|
11 |
|
12 |
Predis does not require any additional C extension by default, but it can be optionally paired with
|
13 |
[phpiredis](https://github.com/nrk/phpiredis) to lower the overhead of the serialization and parsing
|
14 |
-
of the [Redis RESP Protocol](http://redis.io/topics/protocol).
|
15 |
-
implementation of the client you can refer to [Predis\Async](https://github.com/nrk/predis-async).
|
16 |
|
17 |
More details about this project can be found on the [frequently asked questions](FAQ.md).
|
18 |
|
@@ -40,7 +38,7 @@ More details about this project can be found on the [frequently asked questions]
|
|
40 |
This library can be found on [Packagist](http://packagist.org/packages/predis/predis) for an easier
|
41 |
management of projects dependencies using [Composer](http://packagist.org/about-composer) or on our
|
42 |
[own PEAR channel](http://pear.nrk.io) for a more traditional installation using PEAR. Ultimately,
|
43 |
-
compressed archives of each release are [available on GitHub](https://github.com/
|
44 |
|
45 |
|
46 |
### Loading the library ###
|
@@ -89,6 +87,9 @@ $client = new Predis\Client([
|
|
89 |
$client = new Predis\Client('tcp://10.0.0.1:6379');
|
90 |
```
|
91 |
|
|
|
|
|
|
|
92 |
It is also possible to connect to local instances of Redis using UNIX domain sockets, in this case
|
93 |
the parameters must use the `unix` scheme and specify a path for the socket file:
|
94 |
|
@@ -453,7 +454,7 @@ the development server profile will be used. You can refer to [the tests README]
|
|
453 |
for more detailed information about testing Predis.
|
454 |
|
455 |
Predis uses Travis CI for continuous integration and the history for past and current builds can be
|
456 |
-
found [on its project page](http://travis-ci.org/
|
457 |
|
458 |
|
459 |
## Other ##
|
@@ -461,9 +462,9 @@ found [on its project page](http://travis-ci.org/nrk/predis).
|
|
461 |
|
462 |
### Project related links ###
|
463 |
|
464 |
-
- [Source code](https://github.com/
|
465 |
-
- [Wiki](https://github.com/
|
466 |
-
- [Issue tracker](https://github.com/
|
467 |
- [PEAR channel](http://pear.nrk.io)
|
468 |
|
469 |
|
@@ -476,15 +477,13 @@ found [on its project page](http://travis-ci.org/nrk/predis).
|
|
476 |
|
477 |
The code for Predis is distributed under the terms of the MIT license (see [LICENSE](LICENSE)).
|
478 |
|
479 |
-
[ico-license]: https://img.shields.io/github/license/
|
480 |
[ico-version-stable]: https://img.shields.io/packagist/v/predis/predis.svg?style=flat-square
|
481 |
[ico-version-dev]: https://img.shields.io/packagist/vpre/predis/predis.svg?style=flat-square
|
482 |
[ico-downloads-monthly]: https://img.shields.io/packagist/dm/predis/predis.svg?style=flat-square
|
483 |
-
[ico-travis]: https://img.shields.io/travis/
|
484 |
[ico-hhvm]: https://img.shields.io/hhvm/predis/predis.svg?style=flat-square
|
485 |
-
[ico-gitter]: https://img.shields.io/gitter/room/nrk/predis.svg?style=flat-square
|
486 |
|
487 |
[link-packagist]: https://packagist.org/packages/predis/predis
|
488 |
-
[link-travis]: https://travis-ci.org/
|
489 |
[link-downloads]: https://packagist.org/packages/predis/predis/stats
|
490 |
-
[link-gitter]: https://gitter.im/nrk/predis
|
5 |
[![Latest development][ico-version-dev]][link-packagist]
|
6 |
[![Monthly installs][ico-downloads-monthly]][link-downloads]
|
7 |
[![Build status][ico-travis]][link-travis]
|
|
|
8 |
|
9 |
Flexible and feature-complete [Redis](http://redis.io) client for PHP >= 5.3 and HHVM >= 2.3.0.
|
10 |
|
11 |
Predis does not require any additional C extension by default, but it can be optionally paired with
|
12 |
[phpiredis](https://github.com/nrk/phpiredis) to lower the overhead of the serialization and parsing
|
13 |
+
of the [Redis RESP Protocol](http://redis.io/topics/protocol).
|
|
|
14 |
|
15 |
More details about this project can be found on the [frequently asked questions](FAQ.md).
|
16 |
|
38 |
This library can be found on [Packagist](http://packagist.org/packages/predis/predis) for an easier
|
39 |
management of projects dependencies using [Composer](http://packagist.org/about-composer) or on our
|
40 |
[own PEAR channel](http://pear.nrk.io) for a more traditional installation using PEAR. Ultimately,
|
41 |
+
compressed archives of each release are [available on GitHub](https://github.com/predis/predis/releases).
|
42 |
|
43 |
|
44 |
### Loading the library ###
|
87 |
$client = new Predis\Client('tcp://10.0.0.1:6379');
|
88 |
```
|
89 |
|
90 |
+
Password protected servers can be accessed by adding `password` to the parameters set. When ACLs are
|
91 |
+
enabled on Redis >= 6.0, both `username` and `password` are required for user authentication.
|
92 |
+
|
93 |
It is also possible to connect to local instances of Redis using UNIX domain sockets, in this case
|
94 |
the parameters must use the `unix` scheme and specify a path for the socket file:
|
95 |
|
454 |
for more detailed information about testing Predis.
|
455 |
|
456 |
Predis uses Travis CI for continuous integration and the history for past and current builds can be
|
457 |
+
found [on its project page](http://travis-ci.org/predis/predis).
|
458 |
|
459 |
|
460 |
## Other ##
|
462 |
|
463 |
### Project related links ###
|
464 |
|
465 |
+
- [Source code](https://github.com/predis/predis)
|
466 |
+
- [Wiki](https://github.com/predis/predis/wiki)
|
467 |
+
- [Issue tracker](https://github.com/predis/predis/issues)
|
468 |
- [PEAR channel](http://pear.nrk.io)
|
469 |
|
470 |
|
477 |
|
478 |
The code for Predis is distributed under the terms of the MIT license (see [LICENSE](LICENSE)).
|
479 |
|
480 |
+
[ico-license]: https://img.shields.io/github/license/predis/predis.svg?style=flat-square
|
481 |
[ico-version-stable]: https://img.shields.io/packagist/v/predis/predis.svg?style=flat-square
|
482 |
[ico-version-dev]: https://img.shields.io/packagist/vpre/predis/predis.svg?style=flat-square
|
483 |
[ico-downloads-monthly]: https://img.shields.io/packagist/dm/predis/predis.svg?style=flat-square
|
484 |
+
[ico-travis]: https://img.shields.io/travis/predis/predis.svg?style=flat-square
|
485 |
[ico-hhvm]: https://img.shields.io/hhvm/predis/predis.svg?style=flat-square
|
|
|
486 |
|
487 |
[link-packagist]: https://packagist.org/packages/predis/predis
|
488 |
+
[link-travis]: https://travis-ci.org/predis/predis
|
489 |
[link-downloads]: https://packagist.org/packages/predis/predis/stats
|
|
dependencies/predis/predis/VERSION
CHANGED
@@ -1 +1 @@
|
|
1 |
-
1.1.
|
1 |
+
1.1.4
|
dependencies/predis/predis/bin/create-pear
CHANGED
@@ -115,7 +115,7 @@ function addPackageFile($pkg, $fileinfo, $role, $baseDir = '')
|
|
115 |
function generatePackageXml($packageINI)
|
116 |
{
|
117 |
$XML = <<<XML
|
118 |
-
<?xml version="1.0"?>
|
119 |
<package packagerversion="1.4.10" version="2.0"
|
120 |
xmlns="http://pear.php.net/dtd/package-2.0"
|
121 |
xmlns:tasks="http://pear.php.net/dtd/tasks-1.0"
|
@@ -197,7 +197,7 @@ function rewritePackageInstallAs($pkg)
|
|
197 |
|
198 |
function savePackageXml($xml)
|
199 |
{
|
200 |
-
$dom = new DOMDocument("1.0");
|
201 |
$dom->preserveWhiteSpace = false;
|
202 |
$dom->formatOutput = true;
|
203 |
$dom->loadXML($xml->asXML());
|
115 |
function generatePackageXml($packageINI)
|
116 |
{
|
117 |
$XML = <<<XML
|
118 |
+
<?xml version="1.0" encoding="UTF-8"?>
|
119 |
<package packagerversion="1.4.10" version="2.0"
|
120 |
xmlns="http://pear.php.net/dtd/package-2.0"
|
121 |
xmlns:tasks="http://pear.php.net/dtd/tasks-1.0"
|
197 |
|
198 |
function savePackageXml($xml)
|
199 |
{
|
200 |
+
$dom = new DOMDocument("1.0", "UTF-8");
|
201 |
$dom->preserveWhiteSpace = false;
|
202 |
$dom->formatOutput = true;
|
203 |
$dom->loadXML($xml->asXML());
|
dependencies/predis/predis/composer.json
CHANGED
@@ -3,31 +3,45 @@
|
|
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/
|
7 |
"license": "MIT",
|
8 |
"support": {
|
9 |
-
"issues": "https://github.com/
|
10 |
},
|
11 |
"authors": [
|
12 |
{
|
13 |
"name": "Daniele Alessandri",
|
14 |
"email": "suppakilla@gmail.com",
|
15 |
-
"homepage": "http://clorophilla.net"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
16 |
}
|
17 |
],
|
18 |
"require": {
|
19 |
-
"php": ">=5.3.9"
|
20 |
-
"cweagans/composer-patches": "^1.6"
|
21 |
},
|
22 |
"require-dev": {
|
23 |
-
"phpunit/phpunit": "~4.8"
|
|
|
24 |
},
|
25 |
"suggest": {
|
26 |
"ext-phpiredis": "Allows faster serialization and deserialization of the Redis protocol",
|
27 |
"ext-curl": "Allows access to Webdis when paired with phpiredis"
|
28 |
},
|
29 |
"autoload": {
|
30 |
-
"psr-4": {
|
|
|
|
|
31 |
},
|
32 |
"extra": {
|
33 |
"composer-exit-on-patch-failure": true,
|
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 |
+
"cweagans/composer-patches": "^1.6"
|
36 |
},
|
37 |
"suggest": {
|
38 |
"ext-phpiredis": "Allows faster serialization and deserialization of the Redis protocol",
|
39 |
"ext-curl": "Allows access to Webdis when paired with phpiredis"
|
40 |
},
|
41 |
"autoload": {
|
42 |
+
"psr-4": {
|
43 |
+
"Predis\\": "src/"
|
44 |
+
}
|
45 |
},
|
46 |
"extra": {
|
47 |
"composer-exit-on-patch-failure": true,
|
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.4"
|
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;
|
@@ -535,7 +535,9 @@ class Client implements ClientInterface, \IteratorAggregate
|
|
535 |
$connection = $this->getConnection();
|
536 |
|
537 |
if (!$connection instanceof \Traversable) {
|
538 |
-
|
|
|
|
|
539 |
}
|
540 |
|
541 |
foreach ($connection as $node) {
|
40 |
*/
|
41 |
class Client implements ClientInterface, \IteratorAggregate
|
42 |
{
|
43 |
+
const VERSION = '1.1.4';
|
44 |
|
45 |
protected $connection;
|
46 |
protected $options;
|
535 |
$connection = $this->getConnection();
|
536 |
|
537 |
if (!$connection instanceof \Traversable) {
|
538 |
+
return new \ArrayIterator(array(
|
539 |
+
(string) $connection => new static($connection, $this->getOptions())
|
540 |
+
));
|
541 |
}
|
542 |
|
543 |
foreach ($connection as $node) {
|
dependencies/predis/predis/src/ClientContextInterface.php
CHANGED
@@ -39,6 +39,7 @@ use Predis\Command\CommandInterface;
|
|
39 |
* @method $this bitcount($key, $start = null, $end = null)
|
40 |
* @method $this bitop($operation, $destkey, $key)
|
41 |
* @method $this bitfield($key, $subcommand, ...$subcommandArg)
|
|
|
42 |
* @method $this decr($key)
|
43 |
* @method $this decrby($key, $decrement)
|
44 |
* @method $this get($key)
|
@@ -81,7 +82,7 @@ use Predis\Command\CommandInterface;
|
|
81 |
* @method $this llen($key)
|
82 |
* @method $this lpop($key)
|
83 |
* @method $this lpush($key, array $values)
|
84 |
-
* @method $this lpushx($key, $
|
85 |
* @method $this lrange($key, $start, $stop)
|
86 |
* @method $this lrem($key, $count, $value)
|
87 |
* @method $this lset($key, $index, $value)
|
@@ -89,7 +90,7 @@ use Predis\Command\CommandInterface;
|
|
89 |
* @method $this rpop($key)
|
90 |
* @method $this rpoplpush($source, $destination)
|
91 |
* @method $this rpush($key, array $values)
|
92 |
-
* @method $this rpushx($key, $
|
93 |
* @method $this sadd($key, array $members)
|
94 |
* @method $this scard($key)
|
95 |
* @method $this sdiff(array|string $keys)
|
39 |
* @method $this bitcount($key, $start = null, $end = null)
|
40 |
* @method $this bitop($operation, $destkey, $key)
|
41 |
* @method $this bitfield($key, $subcommand, ...$subcommandArg)
|
42 |
+
* @method $this bitpos($key, $bit, $start = null, $end = null)
|
43 |
* @method $this decr($key)
|
44 |
* @method $this decrby($key, $decrement)
|
45 |
* @method $this get($key)
|
82 |
* @method $this llen($key)
|
83 |
* @method $this lpop($key)
|
84 |
* @method $this lpush($key, array $values)
|
85 |
+
* @method $this lpushx($key, array $values)
|
86 |
* @method $this lrange($key, $start, $stop)
|
87 |
* @method $this lrem($key, $count, $value)
|
88 |
* @method $this lset($key, $index, $value)
|
90 |
* @method $this rpop($key)
|
91 |
* @method $this rpoplpush($source, $destination)
|
92 |
* @method $this rpush($key, array $values)
|
93 |
+
* @method $this rpushx($key, array $values)
|
94 |
* @method $this sadd($key, array $members)
|
95 |
* @method $this scard($key)
|
96 |
* @method $this sdiff(array|string $keys)
|
dependencies/predis/predis/src/ClientInterface.php
CHANGED
@@ -24,153 +24,154 @@ use Predis\Profile\ProfileInterface;
|
|
24 |
* and more friendly interface to ease programming which is described in the
|
25 |
* following list of methods:
|
26 |
*
|
27 |
-
* @method int
|
28 |
-
* @method string dump($key)
|
29 |
-
* @method int
|
30 |
-
* @method int
|
31 |
-
* @method int
|
32 |
-
* @method array
|
33 |
-
* @method int
|
34 |
-
* @method mixed
|
35 |
-
* @method int
|
36 |
-
* @method int
|
37 |
-
* @method int
|
38 |
-
* @method int
|
39 |
-
* @method string randomkey()
|
40 |
-
* @method mixed
|
41 |
-
* @method int
|
42 |
-
* @method array
|
43 |
-
* @method array
|
44 |
-
* @method int
|
45 |
-
* @method mixed
|
46 |
-
* @method int
|
47 |
-
* @method int
|
48 |
-
* @method int
|
49 |
-
* @method array bitfield($key, $subcommand, ...$subcommandArg)
|
50 |
-
* @method int
|
51 |
-
* @method int
|
52 |
-
* @method
|
53 |
-
* @method
|
54 |
-
* @method
|
55 |
-
* @method string
|
56 |
-
* @method
|
57 |
-
* @method int
|
58 |
-
* @method
|
59 |
-
* @method
|
60 |
-
* @method
|
61 |
-
* @method
|
62 |
-
* @method
|
63 |
-
* @method mixed
|
64 |
-
* @method
|
65 |
-
* @method int
|
66 |
-
* @method int
|
67 |
-
* @method int
|
68 |
-
* @method int
|
69 |
-
* @method int
|
70 |
-
* @method int
|
71 |
-
* @method
|
72 |
-
* @method
|
73 |
-
* @method
|
74 |
-
* @method
|
75 |
-
* @method
|
76 |
-
* @method
|
77 |
-
* @method
|
78 |
-
* @method
|
79 |
-
* @method
|
80 |
-
* @method
|
81 |
-
* @method int
|
82 |
-
* @method
|
83 |
-
* @method
|
84 |
-
* @method
|
85 |
-
* @method array
|
86 |
-
* @method array
|
87 |
-
* @method string
|
88 |
-
* @method
|
89 |
-
* @method int
|
90 |
-
* @method
|
91 |
-
* @method
|
92 |
-
* @method int
|
93 |
-
* @method
|
94 |
-
* @method
|
95 |
-
* @method
|
96 |
-
* @method mixed
|
97 |
-
* @method
|
98 |
-
* @method string
|
99 |
-
* @method
|
100 |
-
* @method int
|
101 |
-
* @method int
|
102 |
-
* @method int
|
103 |
-
* @method
|
104 |
-
* @method
|
105 |
-
* @method
|
106 |
-
* @method
|
107 |
-
* @method int
|
108 |
-
* @method
|
109 |
-
* @method
|
110 |
-
* @method
|
111 |
-
* @method string
|
112 |
-
* @method
|
113 |
-
* @method
|
114 |
-
* @method array
|
115 |
-
* @method
|
116 |
-
* @method int
|
117 |
-
* @method int
|
118 |
-
* @method
|
119 |
-
* @method string
|
120 |
-
* @method
|
121 |
-
* @method
|
122 |
-
* @method array
|
123 |
-
* @method
|
124 |
-
* @method int
|
125 |
-
* @method int
|
126 |
-
* @method int
|
127 |
-
* @method
|
128 |
-
* @method array
|
129 |
-
* @method
|
130 |
-
* @method int
|
131 |
-
* @method string
|
132 |
-
* @method
|
133 |
-
* @method array
|
134 |
-
* @method array
|
135 |
-
* @method
|
136 |
-
* @method int
|
137 |
-
* @method int
|
138 |
-
* @method
|
139 |
-
* @method
|
140 |
-
* @method
|
141 |
-
* @method
|
142 |
-
* @method
|
143 |
-
* @method
|
144 |
-
* @method
|
145 |
-
* @method mixed
|
146 |
-
* @method mixed
|
147 |
-
* @method mixed
|
148 |
-
* @method mixed
|
149 |
-
* @method mixed
|
150 |
-
* @method mixed
|
151 |
-
* @method
|
152 |
-
* @method
|
153 |
-
* @method mixed
|
154 |
-
* @method mixed
|
155 |
-
* @method mixed
|
156 |
-
* @method mixed
|
157 |
-
* @method mixed
|
158 |
-
* @method
|
159 |
-
* @method
|
160 |
-
* @method mixed
|
161 |
-
* @method
|
162 |
-
* @method
|
163 |
-
* @method
|
164 |
-
* @method mixed
|
165 |
-
* @method mixed
|
166 |
-
* @method
|
167 |
-
* @method array
|
168 |
-
* @method
|
169 |
-
* @method
|
170 |
-
* @method array
|
171 |
-
* @method
|
172 |
-
* @method
|
173 |
-
* @method array
|
|
|
174 |
*
|
175 |
* @author Daniele Alessandri <suppakilla@gmail.com>
|
176 |
*/
|
24 |
* and more friendly interface to ease programming which is described in the
|
25 |
* following list of methods:
|
26 |
*
|
27 |
+
* @method int del(array|string $keys)
|
28 |
+
* @method string|null dump($key)
|
29 |
+
* @method int exists($key)
|
30 |
+
* @method int expire($key, $seconds)
|
31 |
+
* @method int expireat($key, $timestamp)
|
32 |
+
* @method array keys($pattern)
|
33 |
+
* @method int move($key, $db)
|
34 |
+
* @method mixed object($subcommand, $key)
|
35 |
+
* @method int persist($key)
|
36 |
+
* @method int pexpire($key, $milliseconds)
|
37 |
+
* @method int pexpireat($key, $timestamp)
|
38 |
+
* @method int pttl($key)
|
39 |
+
* @method string|null randomkey()
|
40 |
+
* @method mixed rename($key, $target)
|
41 |
+
* @method int renamenx($key, $target)
|
42 |
+
* @method array scan($cursor, array $options = null)
|
43 |
+
* @method array sort($key, array $options = null)
|
44 |
+
* @method int ttl($key)
|
45 |
+
* @method mixed type($key)
|
46 |
+
* @method int append($key, $value)
|
47 |
+
* @method int bitcount($key, $start = null, $end = null)
|
48 |
+
* @method int bitop($operation, $destkey, $key)
|
49 |
+
* @method array|null bitfield($key, $subcommand, ...$subcommandArg)
|
50 |
+
* @method int bitpos($key, $bit, $start = null, $end = null)
|
51 |
+
* @method int decr($key)
|
52 |
+
* @method int decrby($key, $decrement)
|
53 |
+
* @method string|null get($key)
|
54 |
+
* @method int getbit($key, $offset)
|
55 |
+
* @method string getrange($key, $start, $end)
|
56 |
+
* @method string|null getset($key, $value)
|
57 |
+
* @method int incr($key)
|
58 |
+
* @method int incrby($key, $increment)
|
59 |
+
* @method string incrbyfloat($key, $increment)
|
60 |
+
* @method array mget(array $keys)
|
61 |
+
* @method mixed mset(array $dictionary)
|
62 |
+
* @method int msetnx(array $dictionary)
|
63 |
+
* @method mixed psetex($key, $milliseconds, $value)
|
64 |
+
* @method mixed set($key, $value, $expireResolution = null, $expireTTL = null, $flag = null)
|
65 |
+
* @method int setbit($key, $offset, $value)
|
66 |
+
* @method int setex($key, $seconds, $value)
|
67 |
+
* @method int setnx($key, $value)
|
68 |
+
* @method int setrange($key, $offset, $value)
|
69 |
+
* @method int strlen($key)
|
70 |
+
* @method int hdel($key, array $fields)
|
71 |
+
* @method int hexists($key, $field)
|
72 |
+
* @method string|null hget($key, $field)
|
73 |
+
* @method array hgetall($key)
|
74 |
+
* @method int hincrby($key, $field, $increment)
|
75 |
+
* @method string hincrbyfloat($key, $field, $increment)
|
76 |
+
* @method array hkeys($key)
|
77 |
+
* @method int hlen($key)
|
78 |
+
* @method array hmget($key, array $fields)
|
79 |
+
* @method mixed hmset($key, array $dictionary)
|
80 |
+
* @method array hscan($key, $cursor, array $options = null)
|
81 |
+
* @method int hset($key, $field, $value)
|
82 |
+
* @method int hsetnx($key, $field, $value)
|
83 |
+
* @method array hvals($key)
|
84 |
+
* @method int hstrlen($key, $field)
|
85 |
+
* @method array|null blpop(array|string $keys, $timeout)
|
86 |
+
* @method array|null brpop(array|string $keys, $timeout)
|
87 |
+
* @method string|null brpoplpush($source, $destination, $timeout)
|
88 |
+
* @method string|null lindex($key, $index)
|
89 |
+
* @method int linsert($key, $whence, $pivot, $value)
|
90 |
+
* @method int llen($key)
|
91 |
+
* @method string|null lpop($key)
|
92 |
+
* @method int lpush($key, array $values)
|
93 |
+
* @method int lpushx($key, array $values)
|
94 |
+
* @method array lrange($key, $start, $stop)
|
95 |
+
* @method int lrem($key, $count, $value)
|
96 |
+
* @method mixed lset($key, $index, $value)
|
97 |
+
* @method mixed ltrim($key, $start, $stop)
|
98 |
+
* @method string|null rpop($key)
|
99 |
+
* @method string|null rpoplpush($source, $destination)
|
100 |
+
* @method int rpush($key, array $values)
|
101 |
+
* @method int rpushx($key, array $values)
|
102 |
+
* @method int sadd($key, array $members)
|
103 |
+
* @method int scard($key)
|
104 |
+
* @method array sdiff(array|string $keys)
|
105 |
+
* @method int sdiffstore($destination, array|string $keys)
|
106 |
+
* @method array sinter(array|string $keys)
|
107 |
+
* @method int sinterstore($destination, array|string $keys)
|
108 |
+
* @method int sismember($key, $member)
|
109 |
+
* @method array smembers($key)
|
110 |
+
* @method int smove($source, $destination, $member)
|
111 |
+
* @method string|null spop($key, $count = null)
|
112 |
+
* @method string|null srandmember($key, $count = null)
|
113 |
+
* @method int srem($key, $member)
|
114 |
+
* @method array sscan($key, $cursor, array $options = null)
|
115 |
+
* @method array sunion(array|string $keys)
|
116 |
+
* @method int sunionstore($destination, array|string $keys)
|
117 |
+
* @method int zadd($key, array $membersAndScoresDictionary)
|
118 |
+
* @method int zcard($key)
|
119 |
+
* @method string zcount($key, $min, $max)
|
120 |
+
* @method string zincrby($key, $increment, $member)
|
121 |
+
* @method int zinterstore($destination, array|string $keys, array $options = null)
|
122 |
+
* @method array zrange($key, $start, $stop, array $options = null)
|
123 |
+
* @method array zrangebyscore($key, $min, $max, array $options = null)
|
124 |
+
* @method int|null zrank($key, $member)
|
125 |
+
* @method int zrem($key, $member)
|
126 |
+
* @method int zremrangebyrank($key, $start, $stop)
|
127 |
+
* @method int zremrangebyscore($key, $min, $max)
|
128 |
+
* @method array zrevrange($key, $start, $stop, array $options = null)
|
129 |
+
* @method array zrevrangebyscore($key, $max, $min, array $options = null)
|
130 |
+
* @method int|null zrevrank($key, $member)
|
131 |
+
* @method int zunionstore($destination, array|string $keys, array $options = null)
|
132 |
+
* @method string|null zscore($key, $member)
|
133 |
+
* @method array zscan($key, $cursor, array $options = null)
|
134 |
+
* @method array zrangebylex($key, $start, $stop, array $options = null)
|
135 |
+
* @method array zrevrangebylex($key, $start, $stop, array $options = null)
|
136 |
+
* @method int zremrangebylex($key, $min, $max)
|
137 |
+
* @method int zlexcount($key, $min, $max)
|
138 |
+
* @method int pfadd($key, array $elements)
|
139 |
+
* @method mixed pfmerge($destinationKey, array|string $sourceKeys)
|
140 |
+
* @method int pfcount(array|string $keys)
|
141 |
+
* @method mixed pubsub($subcommand, $argument)
|
142 |
+
* @method int publish($channel, $message)
|
143 |
+
* @method mixed discard()
|
144 |
+
* @method array|null exec()
|
145 |
+
* @method mixed multi()
|
146 |
+
* @method mixed unwatch()
|
147 |
+
* @method mixed watch($key)
|
148 |
+
* @method mixed eval($script, $numkeys, $keyOrArg1 = null, $keyOrArgN = null)
|
149 |
+
* @method mixed evalsha($script, $numkeys, $keyOrArg1 = null, $keyOrArgN = null)
|
150 |
+
* @method mixed script($subcommand, $argument = null)
|
151 |
+
* @method mixed auth($password)
|
152 |
+
* @method string echo($message)
|
153 |
+
* @method mixed ping($message = null)
|
154 |
+
* @method mixed select($database)
|
155 |
+
* @method mixed bgrewriteaof()
|
156 |
+
* @method mixed bgsave()
|
157 |
+
* @method mixed client($subcommand, $argument = null)
|
158 |
+
* @method mixed config($subcommand, $argument = null)
|
159 |
+
* @method int dbsize()
|
160 |
+
* @method mixed flushall()
|
161 |
+
* @method mixed flushdb()
|
162 |
+
* @method array info($section = null)
|
163 |
+
* @method int lastsave()
|
164 |
+
* @method mixed save()
|
165 |
+
* @method mixed slaveof($host, $port)
|
166 |
+
* @method mixed slowlog($subcommand, $argument = null)
|
167 |
+
* @method array time()
|
168 |
+
* @method array command()
|
169 |
+
* @method int geoadd($key, $longitude, $latitude, $member)
|
170 |
+
* @method array geohash($key, array $members)
|
171 |
+
* @method array geopos($key, array $members)
|
172 |
+
* @method string|null geodist($key, $member1, $member2, $unit = null)
|
173 |
+
* @method array georadius($key, $longitude, $latitude, $radius, $unit, array $options = null)
|
174 |
+
* @method array georadiusbymember($key, $member, $radius, $unit, array $options = null)
|
175 |
*
|
176 |
* @author Daniele Alessandri <suppakilla@gmail.com>
|
177 |
*/
|
dependencies/predis/predis/src/Cluster/Distributor/HashRing.php
CHANGED
@@ -161,7 +161,7 @@ class HashRing implements DistributorInterface, HashGeneratorInterface
|
|
161 |
$replicas = (int) round($weightRatio * $totalNodes * $replicas);
|
162 |
|
163 |
for ($i = 0; $i < $replicas; ++$i) {
|
164 |
-
$key =
|
165 |
$ring[$key] = $nodeObject;
|
166 |
}
|
167 |
}
|
161 |
$replicas = (int) round($weightRatio * $totalNodes * $replicas);
|
162 |
|
163 |
for ($i = 0; $i < $replicas; ++$i) {
|
164 |
+
$key = $this->hash("$nodeHash:$i");
|
165 |
$ring[$key] = $nodeObject;
|
166 |
}
|
167 |
}
|
dependencies/predis/predis/src/Connection/Factory.php
CHANGED
@@ -173,13 +173,17 @@ class Factory implements FactoryInterface
|
|
173 |
{
|
174 |
$parameters = $connection->getParameters();
|
175 |
|
176 |
-
if (isset($parameters->password)) {
|
|
|
|
|
|
|
|
|
177 |
$connection->addConnectCommand(
|
178 |
-
new RawCommand(
|
179 |
);
|
180 |
}
|
181 |
|
182 |
-
if (isset($parameters->database)) {
|
183 |
$connection->addConnectCommand(
|
184 |
new RawCommand(array('SELECT', $parameters->database))
|
185 |
);
|
173 |
{
|
174 |
$parameters = $connection->getParameters();
|
175 |
|
176 |
+
if (isset($parameters->password) && strlen($parameters->password)) {
|
177 |
+
$cmdAuthArgs = isset($parameters->username) && strlen($parameters->username)
|
178 |
+
? array('AUTH', $parameters->username, $parameters->password)
|
179 |
+
: array('AUTH', $parameters->password);
|
180 |
+
|
181 |
$connection->addConnectCommand(
|
182 |
+
new RawCommand($cmdAuthArgs)
|
183 |
);
|
184 |
}
|
185 |
|
186 |
+
if (isset($parameters->database) && strlen($parameters->database)) {
|
187 |
$connection->addConnectCommand(
|
188 |
new RawCommand(array('SELECT', $parameters->database))
|
189 |
);
|
dependencies/predis/predis/src/Replication/ReplicationStrategy.php
CHANGED
@@ -89,31 +89,6 @@ class ReplicationStrategy
|
|
89 |
return isset($this->disallowed[$command->getId()]);
|
90 |
}
|
91 |
|
92 |
-
/**
|
93 |
-
* Checks if a SORT command is a readable operation by parsing the arguments
|
94 |
-
* array of the specified commad instance.
|
95 |
-
*
|
96 |
-
* @param CommandInterface $command Command instance.
|
97 |
-
*
|
98 |
-
* @return bool
|
99 |
-
*/
|
100 |
-
protected function isSortReadOnly(CommandInterface $command)
|
101 |
-
{
|
102 |
-
$arguments = $command->getArguments();
|
103 |
-
$argc = count($arguments);
|
104 |
-
|
105 |
-
if ($argc > 1) {
|
106 |
-
for ($i = 1; $i < $argc; ++$i) {
|
107 |
-
$argument = strtoupper($arguments[$i]);
|
108 |
-
if ($argument === 'STORE') {
|
109 |
-
return false;
|
110 |
-
}
|
111 |
-
}
|
112 |
-
}
|
113 |
-
|
114 |
-
return true;
|
115 |
-
}
|
116 |
-
|
117 |
/**
|
118 |
* Checks if BITFIELD performs a read-only operation by looking for certain
|
119 |
* SET and INCRYBY modifiers in the arguments array of the command.
|
@@ -292,7 +267,6 @@ class ReplicationStrategy
|
|
292 |
'BITPOS' => true,
|
293 |
'TIME' => true,
|
294 |
'PFCOUNT' => true,
|
295 |
-
'SORT' => array($this, 'isSortReadOnly'),
|
296 |
'BITFIELD' => array($this, 'isBitfieldReadOnly'),
|
297 |
'GEOHASH' => true,
|
298 |
'GEOPOS' => true,
|
89 |
return isset($this->disallowed[$command->getId()]);
|
90 |
}
|
91 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
92 |
/**
|
93 |
* Checks if BITFIELD performs a read-only operation by looking for certain
|
94 |
* SET and INCRYBY modifiers in the arguments array of the command.
|
267 |
'BITPOS' => true,
|
268 |
'TIME' => true,
|
269 |
'PFCOUNT' => true,
|
|
|
270 |
'BITFIELD' => array($this, 'isBitfieldReadOnly'),
|
271 |
'GEOHASH' => true,
|
272 |
'GEOPOS' => true,
|
dependencies/predis/predis/tests/README.md
ADDED
@@ -0,0 +1,82 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# About testing Predis #
|
2 |
+
|
3 |
+
__ATTENTION__: Do not ever ever run this test suite against instances of Redis running in production
|
4 |
+
environments or containing data you are interested in! If you still want to test this library on a
|
5 |
+
production server without hitting the database, please read ahead about how to disable integration
|
6 |
+
tests.
|
7 |
+
|
8 |
+
Predis ships a comprehensive test suite that uses __PHPUnit__ to cover every aspect of the library.
|
9 |
+
The suite is organized into several unit groups with the PHPUnit `@group` annotation which makes it
|
10 |
+
possible to run only selected groups of tests. The main groups are:
|
11 |
+
|
12 |
+
- __disconnected__: generic tests verifying the correct behaviour of the library without requiring
|
13 |
+
an active connection to Redis.
|
14 |
+
- __connected__: integration tests that require an active connection to Redis
|
15 |
+
- __commands__: tests for the implementation of Redis commands.
|
16 |
+
- __slow__: tests that might slow down the execution of the test suite (either __connected__ or
|
17 |
+
__disconnected__).
|
18 |
+
|
19 |
+
A list of all the available groups in the suite can be obtained by running:
|
20 |
+
|
21 |
+
```bash
|
22 |
+
$ phpunit --list-groups
|
23 |
+
```
|
24 |
+
|
25 |
+
Groups of tests can be disabled or enabled via the XML configuration file or the standard command
|
26 |
+
line test runner. Please note that due to a bug in PHPUnit, older versions ignore the `--group`
|
27 |
+
option when the group is excluded in the XML configuration file. More details about this issue are
|
28 |
+
available on [PHPUnit's bug tracker](http://github.com/sebastianbergmann/phpunit/issues/320).
|
29 |
+
|
30 |
+
Certain groups of tests requiring native extensions, such as `ext-curl` or `ext-phpiredis`, are
|
31 |
+
disabled by default in the configuration file. To enable these groups of tests you should remove
|
32 |
+
them from the exclusion list in `phpunit.xml`.
|
33 |
+
|
34 |
+
### Combining groups for inclusion or exclusion with the command-line runner ###
|
35 |
+
|
36 |
+
```bash
|
37 |
+
$ phpunit --group disconnected --exclude-group commands,slow
|
38 |
+
```
|
39 |
+
|
40 |
+
### Integration tests ###
|
41 |
+
|
42 |
+
The suite performs integration tests against a running instance of Redis (>= 2.4.0) to verify the
|
43 |
+
correct behavior of the implementation of each command and certain abstractions implemented in the
|
44 |
+
library that depend on them. These tests are identified by the __connected__ group.
|
45 |
+
|
46 |
+
Integration tests for commands that are not defined in the specified server profile (see the value
|
47 |
+
of the `REDIS_SERVER_VERSION` constant in `phpunit.xml`) are marked as __skipped__ automatically.
|
48 |
+
|
49 |
+
By default, the test suite is configured to execute integration tests using the server profile for
|
50 |
+
Redis 3.2. You can run the suite against a Redis instance built from the `unstable` branch with the
|
51 |
+
development profile by changing the `REDIS_SERVER_VERSION` to `dev` in the `phpunit.xml` file.
|
52 |
+
|
53 |
+
If you do not have a Redis instance up and running or available for testing, you can completely
|
54 |
+
disable integration tests by excluding the __connected__ group:
|
55 |
+
|
56 |
+
```bash
|
57 |
+
$ phpunit --exclude-group connected
|
58 |
+
```
|
59 |
+
|
60 |
+
### Slow tests ###
|
61 |
+
|
62 |
+
Certain tests can slow down the execution of the suite. These tests can be disabled by excluding the
|
63 |
+
__slow__ group:
|
64 |
+
|
65 |
+
```bash
|
66 |
+
$ phpunit --exclude-group slow
|
67 |
+
```
|
68 |
+
|
69 |
+
### Testing Redis commands ###
|
70 |
+
|
71 |
+
We also provide an helper script in the `bin` directory that can be used to automatically generate a
|
72 |
+
file with the skeleton of a test case to test a Redis command by specifying the name of the class
|
73 |
+
in the `Predis\Command` namespace (only classes in this namespace are considered valid). For example
|
74 |
+
to generate a test case for `SET` (represented by the `Predis\Command\StringSet` class):
|
75 |
+
|
76 |
+
```bash
|
77 |
+
$ ./bin/create-command-test --class=StringSet
|
78 |
+
```
|
79 |
+
|
80 |
+
Each command has its own realm (e.g. commands operating on strings, lists, sets and such) which is
|
81 |
+
automatically inferred from the name of the specified class. The realm can be also provided manually
|
82 |
+
leveraging the `--realm` option.
|
dependencies/predis/predis/tests/phpunit_mock_objects.patch
ADDED
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
diff --git a/src/Framework/MockObject/Generator.php b/src/Framework/MockObject/Generator.php
|
2 |
+
index 3df3abb..fc76d5d 100644
|
3 |
+
--- a/src/Framework/MockObject/Generator.php
|
4 |
+
+++ b/src/Framework/MockObject/Generator.php
|
5 |
+
@@ -1031,16 +1031,29 @@ protected function getMethodParameters(ReflectionMethod $method, $forCall = fals
|
6 |
+
$typeDeclaration = '';
|
7 |
+
|
8 |
+
if (!$forCall) {
|
9 |
+
+ if (PHP_VERSION_ID >= 80000) {
|
10 |
+
+ $isArray = $parameter->getType() && $parameter->getType()->getName() === 'array';
|
11 |
+
+ $isCallable = $parameter->getType() && $parameter->getType()->getName() === 'callable';
|
12 |
+
+ } else {
|
13 |
+
+ $isArray = $parameter->isArray();
|
14 |
+
+ $isCallable = version_compare(PHP_VERSION, '5.4.0', '>=') ? $parameter->isCallable() : false;
|
15 |
+
+ }
|
16 |
+
+
|
17 |
+
if ($this->hasType($parameter)) {
|
18 |
+
- $typeDeclaration = (string) $parameter->getType() . ' ';
|
19 |
+
- } elseif ($parameter->isArray()) {
|
20 |
+
+ $type = $parameter->getType();
|
21 |
+
+ $typeDeclaration = (PHP_VERSION_ID >= 70100 ? $type->getName() : (string) $type) . ' ';
|
22 |
+
+ } elseif ($isArray) {
|
23 |
+
$typeDeclaration = 'array ';
|
24 |
+
} elseif ((defined('HHVM_VERSION') || version_compare(PHP_VERSION, '5.4.0', '>='))
|
25 |
+
- && $parameter->isCallable()) {
|
26 |
+
+ && $isCallable) {
|
27 |
+
$typeDeclaration = 'callable ';
|
28 |
+
} else {
|
29 |
+
try {
|
30 |
+
- $class = $parameter->getClass();
|
31 |
+
+ if (PHP_VERSION_ID >= 80000) {
|
32 |
+
+ $class = $parameter->getType();
|
33 |
+
+ } else {
|
34 |
+
+ $class = $parameter->getClass();
|
35 |
+
+ }
|
36 |
+
} catch (ReflectionException $e) {
|
37 |
+
throw new PHPUnit_Framework_MockObject_RuntimeException(
|
38 |
+
sprintf(
|
dependencies/predis/predis/tests/phpunit_php7.patch
ADDED
@@ -0,0 +1,60 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
diff --git a/src/Util/Getopt.php b/src/Util/Getopt.php
|
2 |
+
index ba21be3..96931a3 100644
|
3 |
+
--- a/src/Util/Getopt.php
|
4 |
+
+++ b/src/Util/Getopt.php
|
5 |
+
@@ -35,7 +35,15 @@ class PHPUnit_Util_Getopt
|
6 |
+
reset($args);
|
7 |
+
array_map('trim', $args);
|
8 |
+
|
9 |
+
- while (list($i, $arg) = each($args)) {
|
10 |
+
+ while (true) {
|
11 |
+
+ $arg = current($args);
|
12 |
+
+ $i = key($args);
|
13 |
+
+ next($args);
|
14 |
+
+
|
15 |
+
+ if ($arg === false) {
|
16 |
+
+ break;
|
17 |
+
+ }
|
18 |
+
+
|
19 |
+
if ($arg == '') {
|
20 |
+
continue;
|
21 |
+
}
|
22 |
+
@@ -94,11 +102,14 @@ class PHPUnit_Util_Getopt
|
23 |
+
if ($i + 1 < $argLen) {
|
24 |
+
$opts[] = array($opt, substr($arg, $i + 1));
|
25 |
+
break;
|
26 |
+
- } elseif (list(, $opt_arg) = each($args)) {
|
27 |
+
} else {
|
28 |
+
- throw new PHPUnit_Framework_Exception(
|
29 |
+
- "option requires an argument -- $opt"
|
30 |
+
- );
|
31 |
+
+ $opt_arg = current($args);
|
32 |
+
+ next($args);
|
33 |
+
+ if ($opt_arg === false) {
|
34 |
+
+ throw new PHPUnit_Framework_Exception(
|
35 |
+
+ "option requires an argument -- $opt"
|
36 |
+
+ );
|
37 |
+
+ }
|
38 |
+
}
|
39 |
+
}
|
40 |
+
}
|
41 |
+
@@ -139,11 +150,14 @@ class PHPUnit_Util_Getopt
|
42 |
+
|
43 |
+
if (substr($long_opt, -1) == '=') {
|
44 |
+
if (substr($long_opt, -2) != '==') {
|
45 |
+
- if (!strlen($opt_arg) &&
|
46 |
+
- !(list(, $opt_arg) = each($args))) {
|
47 |
+
- throw new PHPUnit_Framework_Exception(
|
48 |
+
- "option --$opt requires an argument"
|
49 |
+
- );
|
50 |
+
+ if (!strlen($opt_arg)) {
|
51 |
+
+ $opt_arg = current($args);
|
52 |
+
+ next($args);
|
53 |
+
+ if ($opt_arg === false) {
|
54 |
+
+ throw new PHPUnit_Framework_Exception(
|
55 |
+
+ "option --$opt requires an argument"
|
56 |
+
+ );
|
57 |
+
+ }
|
58 |
+
}
|
59 |
+
}
|
60 |
+
} elseif ($opt_arg) {
|
dependencies/predis/predis/tests/phpunit_php8.patch
ADDED
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
diff --git a/src/Framework/TestCase.php b/src/Framework/TestCase.php
|
2 |
+
index 638f42513..b4c7d3a5e 100644
|
3 |
+
--- a/src/Framework/TestCase.php
|
4 |
+
+++ b/src/Framework/TestCase.php
|
5 |
+
@@ -905,7 +905,7 @@ protected function runTest()
|
6 |
+
try {
|
7 |
+
$testResult = $method->invokeArgs(
|
8 |
+
$this,
|
9 |
+
- array_merge($this->data, $this->dependencyInput)
|
10 |
+
+ array_values(array_merge($this->data, $this->dependencyInput))
|
11 |
+
);
|
12 |
+
} catch (Throwable $_e) {
|
13 |
+
$e = $_e;
|
14 |
+
diff --git a/src/Util/Configuration.php b/src/Util/Configuration.php
|
15 |
+
index 5c1041608..b2f7a7bd0 100644
|
16 |
+
--- a/src/Util/Configuration.php
|
17 |
+
+++ b/src/Util/Configuration.php
|
18 |
+
@@ -162,7 +162,7 @@ protected function __construct($filename)
|
19 |
+
/**
|
20 |
+
* @since Method available since Release 3.4.0
|
21 |
+
*/
|
22 |
+
- final private function __clone()
|
23 |
+
+ private function __clone()
|
24 |
+
{
|
25 |
+
}
|
26 |
+
|
27 |
+
diff --git a/src/Util/PHP/Template/TestCaseMethod.tpl.dist b/src/Util/PHP/Template/TestCaseMethod.tpl.dist
|
28 |
+
index b48f354cd..d59cdeea7 100644
|
29 |
+
--- a/src/Util/PHP/Template/TestCaseMethod.tpl.dist
|
30 |
+
+++ b/src/Util/PHP/Template/TestCaseMethod.tpl.dist
|
31 |
+
@@ -78,7 +78,7 @@ if ('' !== $configurationFilePath) {
|
32 |
+
unset($configuration);
|
33 |
+
}
|
34 |
+
|
35 |
+
-function __phpunit_error_handler($errno, $errstr, $errfile, $errline, $errcontext)
|
36 |
+
+function __phpunit_error_handler($errno, $errstr, $errfile, $errline, $errcontext = null)
|
37 |
+
{
|
38 |
+
return true;
|
39 |
+
}
|
includes/class-plugin.php
CHANGED
@@ -36,12 +36,12 @@ class Plugin {
|
|
36 |
*
|
37 |
* @var string[] $actions
|
38 |
*/
|
39 |
-
private $actions =
|
40 |
'enable-cache',
|
41 |
'disable-cache',
|
42 |
'flush-cache',
|
43 |
'update-dropin',
|
44 |
-
|
45 |
|
46 |
/**
|
47 |
* Plugin instance property
|
@@ -93,34 +93,36 @@ class Plugin {
|
|
93 |
* @return void
|
94 |
*/
|
95 |
public function add_actions_and_filters() {
|
96 |
-
add_action( 'deactivate_plugin',
|
97 |
-
add_action( 'admin_init',
|
98 |
|
99 |
-
add_action( is_multisite() ? 'network_admin_menu' : 'admin_menu',
|
100 |
|
101 |
-
add_action( 'admin_notices',
|
102 |
-
add_action( 'network_admin_notices',
|
|
|
103 |
|
104 |
-
add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_admin_styles' ) );
|
105 |
-
add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_admin_scripts' ) );
|
106 |
-
add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_redis_metrics' ) );
|
107 |
|
108 |
-
add_action( '
|
|
|
|
|
109 |
|
110 |
-
add_action( '
|
111 |
-
add_action( 'wp_network_dashboard_setup', array( $this, 'setup_dashboard_widget' ) );
|
112 |
|
113 |
-
add_action( '
|
|
|
|
|
|
|
114 |
|
115 |
$links = sprintf( '%splugin_action_links_%s', is_multisite() ? 'network_admin_' : '', WP_REDIS_BASENAME );
|
116 |
-
add_filter( $links,
|
117 |
|
118 |
-
add_action( 'wp_head',
|
119 |
-
add_action( 'shutdown',
|
120 |
-
add_action( 'rediscache_discard_metrics',
|
121 |
|
122 |
-
add_filter( 'qm/collectors',
|
123 |
-
add_filter( 'qm/outputter/html',
|
124 |
}
|
125 |
|
126 |
/**
|
@@ -135,7 +137,7 @@ class Plugin {
|
|
135 |
__( 'Redis', 'redis-cache' ),
|
136 |
is_multisite() ? 'manage_network_options' : 'manage_options',
|
137 |
'redis-cache',
|
138 |
-
|
139 |
);
|
140 |
}
|
141 |
|
@@ -144,6 +146,29 @@ class Plugin {
|
|
144 |
*
|
145 |
* @return void
|
146 |
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
147 |
public function show_admin_page() {
|
148 |
// Request filesystem credentials?
|
149 |
if ( isset( $_GET['_wpnonce'], $_GET['action'] ) ) {
|
@@ -200,7 +225,7 @@ class Plugin {
|
|
200 |
wp_add_dashboard_widget(
|
201 |
'dashboard_rediscache',
|
202 |
__( 'Redis Object Cache', 'redis-cache' ),
|
203 |
-
|
204 |
);
|
205 |
}
|
206 |
|
@@ -238,11 +263,11 @@ class Plugin {
|
|
238 |
return;
|
239 |
}
|
240 |
|
241 |
-
$screens =
|
242 |
$this->screen,
|
243 |
'dashboard',
|
244 |
'dashboard-network',
|
245 |
-
|
246 |
|
247 |
if ( ! in_array( $screen->id, $screens, true ) ) {
|
248 |
return;
|
@@ -263,14 +288,14 @@ class Plugin {
|
|
263 |
return;
|
264 |
}
|
265 |
|
266 |
-
$screens =
|
267 |
$this->screen,
|
268 |
'dashboard',
|
269 |
'dashboard-network',
|
270 |
'edit-shop_order',
|
271 |
'edit-product',
|
272 |
'woocommerce_page_wc-admin',
|
273 |
-
|
274 |
|
275 |
if ( ! in_array( $screen->id, $screens, true ) ) {
|
276 |
return;
|
@@ -279,7 +304,7 @@ class Plugin {
|
|
279 |
wp_enqueue_script(
|
280 |
'redis-cache',
|
281 |
plugins_url( 'assets/js/admin.js', WP_REDIS_FILE ),
|
282 |
-
|
283 |
WP_REDIS_VERSION,
|
284 |
true
|
285 |
);
|
@@ -287,11 +312,11 @@ class Plugin {
|
|
287 |
wp_localize_script(
|
288 |
'redis-cache',
|
289 |
'rediscache',
|
290 |
-
|
291 |
'jQuery' => 'jQuery',
|
292 |
'disable_pro' => $screen->id !== $this->screen,
|
293 |
'disable_banners' => defined( 'WP_REDIS_DISABLE_BANNERS' ) && WP_REDIS_DISABLE_BANNERS,
|
294 |
-
'l10n' =>
|
295 |
'time' => __( 'Time', 'redis-cache' ),
|
296 |
'bytes' => __( 'Bytes', 'redis-cache' ),
|
297 |
'ratio' => __( 'Ratio', 'redis-cache' ),
|
@@ -299,8 +324,8 @@ class Plugin {
|
|
299 |
'no_data' => __( 'Not enough data collected, yet.', 'redis-cache' ),
|
300 |
'no_cache' => __( 'Enable object cache to collect data.', 'redis-cache' ),
|
301 |
'pro' => 'Object Cache Pro',
|
302 |
-
|
303 |
-
|
304 |
);
|
305 |
}
|
306 |
|
@@ -322,7 +347,7 @@ class Plugin {
|
|
322 |
return;
|
323 |
}
|
324 |
|
325 |
-
if ( ! in_array( $screen->id,
|
326 |
return;
|
327 |
}
|
328 |
|
@@ -571,6 +596,8 @@ class Plugin {
|
|
571 |
$message = sprintf( __( 'The Redis object cache drop-in is outdated. Please <a href="%s">update the drop-in</a>.', 'redis-cache' ), $url );
|
572 |
}
|
573 |
} else {
|
|
|
|
|
574 |
// translators: %s = Action link to update the drop-in.
|
575 |
$message = sprintf( __( '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' ), $url );
|
576 |
}
|
@@ -630,6 +657,12 @@ class Plugin {
|
|
630 |
FS_CHMOD_FILE
|
631 |
);
|
632 |
|
|
|
|
|
|
|
|
|
|
|
|
|
633 |
do_action( 'redis_object_cache_enable', $result );
|
634 |
|
635 |
$result
|
@@ -650,6 +683,12 @@ class Plugin {
|
|
650 |
if ( $action === 'disable-cache' ) {
|
651 |
$result = $wp_filesystem->delete( WP_CONTENT_DIR . '/object-cache.php' );
|
652 |
|
|
|
|
|
|
|
|
|
|
|
|
|
653 |
do_action( 'redis_object_cache_disable', $result );
|
654 |
|
655 |
$result
|
@@ -675,6 +714,12 @@ class Plugin {
|
|
675 |
FS_CHMOD_FILE
|
676 |
);
|
677 |
|
|
|
|
|
|
|
|
|
|
|
|
|
678 |
do_action( 'redis_object_cache_update_dropin', $result );
|
679 |
|
680 |
$result
|
@@ -739,7 +784,7 @@ class Plugin {
|
|
739 |
return;
|
740 |
}
|
741 |
|
742 |
-
if ( ! in_array( $screen->id,
|
743 |
return;
|
744 |
}
|
745 |
|
@@ -779,7 +824,7 @@ class Plugin {
|
|
779 |
return;
|
780 |
}
|
781 |
|
782 |
-
if ( ! in_array( $screen->id,
|
783 |
return;
|
784 |
}
|
785 |
|
@@ -810,7 +855,7 @@ class Plugin {
|
|
810 |
*/
|
811 |
public function register_shutdown_hooks() {
|
812 |
if ( ! defined( 'WP_REDIS_DISABLE_COMMENT' ) || ! WP_REDIS_DISABLE_COMMENT ) {
|
813 |
-
add_action( 'shutdown',
|
814 |
}
|
815 |
}
|
816 |
|
@@ -1065,6 +1110,12 @@ class Plugin {
|
|
1065 |
FS_CHMOD_FILE
|
1066 |
);
|
1067 |
|
|
|
|
|
|
|
|
|
|
|
|
|
1068 |
do_action( 'redis_object_cache_update_dropin', $result );
|
1069 |
}
|
1070 |
}
|
36 |
*
|
37 |
* @var string[] $actions
|
38 |
*/
|
39 |
+
private $actions = [
|
40 |
'enable-cache',
|
41 |
'disable-cache',
|
42 |
'flush-cache',
|
43 |
'update-dropin',
|
44 |
+
];
|
45 |
|
46 |
/**
|
47 |
* Plugin instance property
|
93 |
* @return void
|
94 |
*/
|
95 |
public function add_actions_and_filters() {
|
96 |
+
add_action( 'deactivate_plugin', [ $this, 'on_deactivation' ] );
|
97 |
+
add_action( 'admin_init', [ $this, 'maybe_update_dropin' ] );
|
98 |
|
99 |
+
add_action( is_multisite() ? 'network_admin_menu' : 'admin_menu', [ $this, 'add_admin_menu_page' ] );
|
100 |
|
101 |
+
add_action( 'admin_notices', [ $this, 'show_admin_notices' ] );
|
102 |
+
add_action( 'network_admin_notices', [ $this, 'show_admin_notices' ] );
|
103 |
+
add_action( 'admin_bar_menu', array( $this, 'add_admin_bar_menu' ), 1000 );
|
104 |
|
|
|
|
|
|
|
105 |
|
106 |
+
add_action( 'admin_enqueue_scripts', [ $this, 'enqueue_admin_styles' ] );
|
107 |
+
add_action( 'admin_enqueue_scripts', [ $this, 'enqueue_admin_scripts' ] );
|
108 |
+
add_action( 'admin_enqueue_scripts', [ $this, 'enqueue_redis_metrics' ] );
|
109 |
|
110 |
+
add_action( 'load-settings_page_redis-cache', [ $this, 'do_admin_actions' ] );
|
|
|
111 |
|
112 |
+
add_action( 'wp_dashboard_setup', [ $this, 'setup_dashboard_widget' ] );
|
113 |
+
add_action( 'wp_network_dashboard_setup', [ $this, 'setup_dashboard_widget' ] );
|
114 |
+
|
115 |
+
add_action( 'wp_ajax_roc_dismiss_notice', [ $this, 'dismiss_notice' ] );
|
116 |
|
117 |
$links = sprintf( '%splugin_action_links_%s', is_multisite() ? 'network_admin_' : '', WP_REDIS_BASENAME );
|
118 |
+
add_filter( $links, [ $this, 'add_plugin_actions_links' ] );
|
119 |
|
120 |
+
add_action( 'wp_head', [ $this, 'register_shutdown_hooks' ] );
|
121 |
+
add_action( 'shutdown', [ $this, 'record_metrics' ] );
|
122 |
+
add_action( 'rediscache_discard_metrics', [ $this, 'discard_metrics' ] );
|
123 |
|
124 |
+
add_filter( 'qm/collectors', [ $this, 'register_qm_collector' ], 25 );
|
125 |
+
add_filter( 'qm/outputter/html', [ $this, 'register_qm_output' ] );
|
126 |
}
|
127 |
|
128 |
/**
|
137 |
__( 'Redis', 'redis-cache' ),
|
138 |
is_multisite() ? 'manage_network_options' : 'manage_options',
|
139 |
'redis-cache',
|
140 |
+
[ $this, 'show_admin_page' ]
|
141 |
);
|
142 |
}
|
143 |
|
146 |
*
|
147 |
* @return void
|
148 |
*/
|
149 |
+
public function add_admin_bar_menu( $wp_admin_bar ) {
|
150 |
+
if ( ! current_user_can( is_multisite() ? 'manage_network_options' : 'manage_options' ) ) {
|
151 |
+
return;
|
152 |
+
}
|
153 |
+
|
154 |
+
if ( ! $this->get_redis_status() ) {
|
155 |
+
return;
|
156 |
+
}
|
157 |
+
|
158 |
+
if ( ! defined( 'WP_REDIS_DISABLE_ADMINBAR' ) || WP_REDIS_DISABLE_ADMINBAR ) {
|
159 |
+
return;
|
160 |
+
}
|
161 |
+
|
162 |
+
$wp_admin_bar->add_node( [
|
163 |
+
'id' => 'redis-cache-flush',
|
164 |
+
'title' => __( 'Flush Object Cache', 'redis-cache' ),
|
165 |
+
'href' => $this->action_link( 'flush-cache' ),
|
166 |
+
'meta' => [
|
167 |
+
'title' => __( 'Flush the Redis object cache', 'redis-cache' ),
|
168 |
+
],
|
169 |
+
] );
|
170 |
+
}
|
171 |
+
|
172 |
public function show_admin_page() {
|
173 |
// Request filesystem credentials?
|
174 |
if ( isset( $_GET['_wpnonce'], $_GET['action'] ) ) {
|
225 |
wp_add_dashboard_widget(
|
226 |
'dashboard_rediscache',
|
227 |
__( 'Redis Object Cache', 'redis-cache' ),
|
228 |
+
[ $this, 'show_dashboard_widget' ]
|
229 |
);
|
230 |
}
|
231 |
|
263 |
return;
|
264 |
}
|
265 |
|
266 |
+
$screens = [
|
267 |
$this->screen,
|
268 |
'dashboard',
|
269 |
'dashboard-network',
|
270 |
+
];
|
271 |
|
272 |
if ( ! in_array( $screen->id, $screens, true ) ) {
|
273 |
return;
|
288 |
return;
|
289 |
}
|
290 |
|
291 |
+
$screens = [
|
292 |
$this->screen,
|
293 |
'dashboard',
|
294 |
'dashboard-network',
|
295 |
'edit-shop_order',
|
296 |
'edit-product',
|
297 |
'woocommerce_page_wc-admin',
|
298 |
+
];
|
299 |
|
300 |
if ( ! in_array( $screen->id, $screens, true ) ) {
|
301 |
return;
|
304 |
wp_enqueue_script(
|
305 |
'redis-cache',
|
306 |
plugins_url( 'assets/js/admin.js', WP_REDIS_FILE ),
|
307 |
+
[ 'jquery', 'underscore' ],
|
308 |
WP_REDIS_VERSION,
|
309 |
true
|
310 |
);
|
312 |
wp_localize_script(
|
313 |
'redis-cache',
|
314 |
'rediscache',
|
315 |
+
[
|
316 |
'jQuery' => 'jQuery',
|
317 |
'disable_pro' => $screen->id !== $this->screen,
|
318 |
'disable_banners' => defined( 'WP_REDIS_DISABLE_BANNERS' ) && WP_REDIS_DISABLE_BANNERS,
|
319 |
+
'l10n' => [
|
320 |
'time' => __( 'Time', 'redis-cache' ),
|
321 |
'bytes' => __( 'Bytes', 'redis-cache' ),
|
322 |
'ratio' => __( 'Ratio', 'redis-cache' ),
|
324 |
'no_data' => __( 'Not enough data collected, yet.', 'redis-cache' ),
|
325 |
'no_cache' => __( 'Enable object cache to collect data.', 'redis-cache' ),
|
326 |
'pro' => 'Object Cache Pro',
|
327 |
+
],
|
328 |
+
]
|
329 |
);
|
330 |
}
|
331 |
|
347 |
return;
|
348 |
}
|
349 |
|
350 |
+
if ( ! in_array( $screen->id, [ $this->screen, 'dashboard', 'dashboard-network' ], true ) ) {
|
351 |
return;
|
352 |
}
|
353 |
|
596 |
$message = sprintf( __( 'The Redis object cache drop-in is outdated. Please <a href="%s">update the drop-in</a>.', 'redis-cache' ), $url );
|
597 |
}
|
598 |
} else {
|
599 |
+
// Ignore Pro version !!!
|
600 |
+
|
601 |
// translators: %s = Action link to update the drop-in.
|
602 |
$message = sprintf( __( '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' ), $url );
|
603 |
}
|
657 |
FS_CHMOD_FILE
|
658 |
);
|
659 |
|
660 |
+
/**
|
661 |
+
* Fires on cache enable event
|
662 |
+
*
|
663 |
+
* @since 1.3.5
|
664 |
+
* @param bool $result Whether the filesystem event (copy of the `object-cache.php` file) was successfull.
|
665 |
+
*/
|
666 |
do_action( 'redis_object_cache_enable', $result );
|
667 |
|
668 |
$result
|
683 |
if ( $action === 'disable-cache' ) {
|
684 |
$result = $wp_filesystem->delete( WP_CONTENT_DIR . '/object-cache.php' );
|
685 |
|
686 |
+
/**
|
687 |
+
* Fires on cache enable event
|
688 |
+
*
|
689 |
+
* @since 1.3.5
|
690 |
+
* @param bool $result Whether the filesystem event (deletion of the `object-cache.php` file) was successfull.
|
691 |
+
*/
|
692 |
do_action( 'redis_object_cache_disable', $result );
|
693 |
|
694 |
$result
|
714 |
FS_CHMOD_FILE
|
715 |
);
|
716 |
|
717 |
+
/**
|
718 |
+
* Fires on cache enable event
|
719 |
+
*
|
720 |
+
* @since 1.3.5
|
721 |
+
* @param bool $result Whether the filesystem event (copy of the `object-cache.php` file) was successfull.
|
722 |
+
*/
|
723 |
do_action( 'redis_object_cache_update_dropin', $result );
|
724 |
|
725 |
$result
|
784 |
return;
|
785 |
}
|
786 |
|
787 |
+
if ( ! in_array( $screen->id, [ 'dashboard', 'dashboard-network' ], true ) ) {
|
788 |
return;
|
789 |
}
|
790 |
|
824 |
return;
|
825 |
}
|
826 |
|
827 |
+
if ( ! in_array( $screen->id, [ 'edit-shop_order', 'edit-product', 'woocommerce_page_wc-admin' ], true ) ) {
|
828 |
return;
|
829 |
}
|
830 |
|
855 |
*/
|
856 |
public function register_shutdown_hooks() {
|
857 |
if ( ! defined( 'WP_REDIS_DISABLE_COMMENT' ) || ! WP_REDIS_DISABLE_COMMENT ) {
|
858 |
+
add_action( 'shutdown', [ $this, 'maybe_print_comment' ], 0 );
|
859 |
}
|
860 |
}
|
861 |
|
1110 |
FS_CHMOD_FILE
|
1111 |
);
|
1112 |
|
1113 |
+
/**
|
1114 |
+
* Fires on cache enable event
|
1115 |
+
*
|
1116 |
+
* @since 1.3.5
|
1117 |
+
* @param bool $result Whether the filesystem event (copy of the `object-cache.php` file) was successfull.
|
1118 |
+
*/
|
1119 |
do_action( 'redis_object_cache_update_dropin', $result );
|
1120 |
}
|
1121 |
}
|
includes/cli/class-commands.php
CHANGED
@@ -31,7 +31,7 @@ class Commands extends WP_CLI_Command {
|
|
31 |
* wp redis status
|
32 |
*/
|
33 |
public function status() {
|
34 |
-
$
|
35 |
|
36 |
require_once __DIR__ . '/../ui/diagnostics.php';
|
37 |
}
|
31 |
* wp redis status
|
32 |
*/
|
33 |
public function status() {
|
34 |
+
$roc = Plugin::instance();
|
35 |
|
36 |
require_once __DIR__ . '/../ui/diagnostics.php';
|
37 |
}
|
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
|
@@ -282,7 +282,7 @@ class WP_Object_Cache {
|
|
282 |
*
|
283 |
* @var array
|
284 |
*/
|
285 |
-
public $cache =
|
286 |
|
287 |
/**
|
288 |
* Holds the diagnostics values.
|
@@ -296,14 +296,14 @@ class WP_Object_Cache {
|
|
296 |
*
|
297 |
* @var array
|
298 |
*/
|
299 |
-
public $errors =
|
300 |
|
301 |
/**
|
302 |
* List of global groups.
|
303 |
*
|
304 |
* @var array
|
305 |
*/
|
306 |
-
public $global_groups =
|
307 |
'blog-details',
|
308 |
'blog-id-cache',
|
309 |
'blog-lookup',
|
@@ -321,25 +321,25 @@ class WP_Object_Cache {
|
|
321 |
'usermeta',
|
322 |
'user_meta',
|
323 |
'userslugs',
|
324 |
-
|
325 |
|
326 |
/**
|
327 |
* List of groups that will not be flushed.
|
328 |
*
|
329 |
* @var array
|
330 |
*/
|
331 |
-
public $unflushable_groups =
|
332 |
|
333 |
/**
|
334 |
* List of groups not saved to Redis.
|
335 |
*
|
336 |
* @var array
|
337 |
*/
|
338 |
-
public $ignored_groups =
|
339 |
'counts',
|
340 |
'plugins',
|
341 |
'themes',
|
342 |
-
|
343 |
|
344 |
/**
|
345 |
* Prefix used for global groups.
|
@@ -397,6 +397,8 @@ class WP_Object_Cache {
|
|
397 |
$this->global_groups = array_map( [ $this, 'sanitize_key_part' ], WP_REDIS_GLOBAL_GROUPS );
|
398 |
}
|
399 |
|
|
|
|
|
400 |
if ( defined( 'WP_REDIS_IGNORED_GROUPS' ) && is_array( WP_REDIS_IGNORED_GROUPS ) ) {
|
401 |
$this->ignored_groups = array_map( [ $this, 'sanitize_key_part' ], WP_REDIS_IGNORED_GROUPS );
|
402 |
}
|
@@ -471,7 +473,7 @@ class WP_Object_Cache {
|
|
471 |
* @return array
|
472 |
*/
|
473 |
protected function build_parameters() {
|
474 |
-
$parameters =
|
475 |
'scheme' => 'tcp',
|
476 |
'host' => '127.0.0.1',
|
477 |
'port' => 6379,
|
@@ -479,9 +481,9 @@ class WP_Object_Cache {
|
|
479 |
'timeout' => 1,
|
480 |
'read_timeout' => 1,
|
481 |
'retry_interval' => null,
|
482 |
-
|
483 |
|
484 |
-
$settings =
|
485 |
'scheme',
|
486 |
'host',
|
487 |
'port',
|
@@ -491,7 +493,7 @@ class WP_Object_Cache {
|
|
491 |
'timeout',
|
492 |
'read_timeout',
|
493 |
'retry_interval',
|
494 |
-
|
495 |
|
496 |
foreach ( $settings as $setting ) {
|
497 |
$constant = sprintf( 'WP_REDIS_%s', strtoupper( $setting ) );
|
@@ -623,7 +625,7 @@ class WP_Object_Cache {
|
|
623 |
}
|
624 |
|
625 |
$servers = false;
|
626 |
-
$options =
|
627 |
|
628 |
if ( defined( 'WP_REDIS_SHARDS' ) ) {
|
629 |
$servers = WP_REDIS_SHARDS;
|
@@ -647,7 +649,7 @@ class WP_Object_Cache {
|
|
647 |
$parameters['read_write_timeout'] = $parameters['read_timeout'];
|
648 |
}
|
649 |
|
650 |
-
foreach (
|
651 |
if ( defined( $constant ) ) {
|
652 |
if ( $parameters['database'] ) {
|
653 |
$options['parameters']['database'] = $parameters['database'];
|
@@ -741,7 +743,9 @@ class WP_Object_Cache {
|
|
741 |
$clients = $is_cluster ? WP_REDIS_CLUSTER : WP_REDIS_SERVERS;
|
742 |
|
743 |
foreach ( $clients as $index => &$connection_string ) {
|
744 |
-
|
|
|
|
|
745 |
parse_str( $url_components['query'], $add_params );
|
746 |
|
747 |
if ( ! $is_cluster && isset( $add_params['alias'] ) ) {
|
@@ -759,6 +763,19 @@ class WP_Object_Cache {
|
|
759 |
|
760 |
$this->redis = new Credis_Cluster( $clients );
|
761 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
762 |
$args['servers'] = $clients;
|
763 |
} else {
|
764 |
$args = [
|
@@ -949,7 +966,19 @@ class WP_Object_Cache {
|
|
949 |
// Save if group not excluded and redis is up.
|
950 |
if ( ! $this->is_ignored_group( $group ) && $this->redis_status() ) {
|
951 |
try {
|
952 |
-
$
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
953 |
$start_time = microtime( true );
|
954 |
|
955 |
if ( $add ) {
|
@@ -1044,6 +1073,14 @@ class WP_Object_Cache {
|
|
1044 |
$this->cache_time += $execute_time;
|
1045 |
|
1046 |
if ( function_exists( 'do_action' ) ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1047 |
do_action( 'redis_object_cache_delete', $key, $group, $execute_time );
|
1048 |
}
|
1049 |
|
@@ -1065,7 +1102,7 @@ class WP_Object_Cache {
|
|
1065 |
}
|
1066 |
|
1067 |
$results = [];
|
1068 |
-
$this->cache =
|
1069 |
|
1070 |
if ( $this->redis_status() ) {
|
1071 |
$salt = defined( 'WP_REDIS_PREFIX' ) ? trim( WP_REDIS_PREFIX ) : null;
|
@@ -1123,6 +1160,16 @@ class WP_Object_Cache {
|
|
1123 |
if ( function_exists( 'do_action' ) ) {
|
1124 |
$execute_time = microtime( true ) - $start_time;
|
1125 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1126 |
do_action( 'redis_object_cache_flush', $results, $delay, $selective, $salt, $execute_time );
|
1127 |
}
|
1128 |
}
|
@@ -1275,7 +1322,7 @@ LUA;
|
|
1275 |
*
|
1276 |
* @param string $key The key under which to store the value.
|
1277 |
* @param string $group The group value appended to the $key.
|
1278 |
-
* @param
|
1279 |
* cache. Default false.
|
1280 |
* @param bool $found Optional. Whether the key was found in the cache. Disambiguates a return of
|
1281 |
* false, a storable value. Passed by reference. Default null.
|
@@ -1325,11 +1372,32 @@ LUA;
|
|
1325 |
$this->add_to_internal_cache( $derived_key, $value );
|
1326 |
|
1327 |
if ( function_exists( 'do_action' ) ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1328 |
do_action( 'redis_object_cache_get', $key, $value, $group, $force, $found, $execute_time );
|
1329 |
}
|
1330 |
|
1331 |
if ( function_exists( 'apply_filters' ) && function_exists( 'has_filter' ) ) {
|
1332 |
if ( has_filter( 'redis_object_cache_get_value' ) ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1333 |
return apply_filters( 'redis_object_cache_get_value', $value, $key, $group, $force, $found );
|
1334 |
}
|
1335 |
}
|
@@ -1351,8 +1419,8 @@ LUA;
|
|
1351 |
return false;
|
1352 |
}
|
1353 |
|
1354 |
-
$cache =
|
1355 |
-
$derived_keys =
|
1356 |
|
1357 |
foreach ( $keys as $key ) {
|
1358 |
$derived_keys[ $key ] = $this->build_key( $key, $group );
|
@@ -1429,12 +1497,31 @@ LUA;
|
|
1429 |
}
|
1430 |
|
1431 |
if ( function_exists( 'do_action' ) ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1432 |
do_action( 'redis_object_cache_get_multiple', $keys, $cache, $group, $force, $execute_time );
|
1433 |
}
|
1434 |
|
1435 |
if ( function_exists( 'apply_filters' ) && function_exists( 'has_filter' ) ) {
|
1436 |
if ( has_filter( 'redis_object_cache_get_value' ) ) {
|
1437 |
foreach ( $cache as $key => $value ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1438 |
$cache[ $key ] = apply_filters( 'redis_object_cache_get_value', $value, $key, $group, $force );
|
1439 |
}
|
1440 |
}
|
@@ -1462,7 +1549,19 @@ LUA;
|
|
1462 |
|
1463 |
// Save if group not excluded from redis and redis is up.
|
1464 |
if ( ! $this->is_ignored_group( $group ) && $this->redis_status() ) {
|
1465 |
-
$
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1466 |
|
1467 |
try {
|
1468 |
if ( $expiration ) {
|
@@ -1488,6 +1587,16 @@ LUA;
|
|
1488 |
if ( function_exists( 'do_action' ) ) {
|
1489 |
$execute_time = microtime( true ) - $start_time;
|
1490 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1491 |
do_action( 'redis_object_cache_set', $key, $value, $group, $expiration, $execute_time );
|
1492 |
}
|
1493 |
|
@@ -1634,6 +1743,8 @@ LUA;
|
|
1634 |
);
|
1635 |
|
1636 |
return (object) [
|
|
|
|
|
1637 |
'hits' => $this->cache_hits,
|
1638 |
'misses' => $this->cache_misses,
|
1639 |
'ratio' => $total > 0 ? round( $this->cache_hits / ( $total / 100 ), 1 ) : 100,
|
@@ -2005,6 +2116,12 @@ LUA;
|
|
2005 |
error_log( $exception ); // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_error_log
|
2006 |
|
2007 |
if ( function_exists( 'do_action' ) ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
2008 |
do_action( 'redis_object_cache_error', $exception );
|
2009 |
}
|
2010 |
}
|
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.13
|
7 |
* Author: Till Krüss
|
8 |
* Author URI: https://objectcache.pro
|
9 |
* License: GPLv3
|
282 |
*
|
283 |
* @var array
|
284 |
*/
|
285 |
+
public $cache = [];
|
286 |
|
287 |
/**
|
288 |
* Holds the diagnostics values.
|
296 |
*
|
297 |
* @var array
|
298 |
*/
|
299 |
+
public $errors = [];
|
300 |
|
301 |
/**
|
302 |
* List of global groups.
|
303 |
*
|
304 |
* @var array
|
305 |
*/
|
306 |
+
public $global_groups = [
|
307 |
'blog-details',
|
308 |
'blog-id-cache',
|
309 |
'blog-lookup',
|
321 |
'usermeta',
|
322 |
'user_meta',
|
323 |
'userslugs',
|
324 |
+
];
|
325 |
|
326 |
/**
|
327 |
* List of groups that will not be flushed.
|
328 |
*
|
329 |
* @var array
|
330 |
*/
|
331 |
+
public $unflushable_groups = [];
|
332 |
|
333 |
/**
|
334 |
* List of groups not saved to Redis.
|
335 |
*
|
336 |
* @var array
|
337 |
*/
|
338 |
+
public $ignored_groups = [
|
339 |
'counts',
|
340 |
'plugins',
|
341 |
'themes',
|
342 |
+
];
|
343 |
|
344 |
/**
|
345 |
* Prefix used for global groups.
|
397 |
$this->global_groups = array_map( [ $this, 'sanitize_key_part' ], WP_REDIS_GLOBAL_GROUPS );
|
398 |
}
|
399 |
|
400 |
+
$this->global_groups[] = 'redis-cache';
|
401 |
+
|
402 |
if ( defined( 'WP_REDIS_IGNORED_GROUPS' ) && is_array( WP_REDIS_IGNORED_GROUPS ) ) {
|
403 |
$this->ignored_groups = array_map( [ $this, 'sanitize_key_part' ], WP_REDIS_IGNORED_GROUPS );
|
404 |
}
|
473 |
* @return array
|
474 |
*/
|
475 |
protected function build_parameters() {
|
476 |
+
$parameters = [
|
477 |
'scheme' => 'tcp',
|
478 |
'host' => '127.0.0.1',
|
479 |
'port' => 6379,
|
481 |
'timeout' => 1,
|
482 |
'read_timeout' => 1,
|
483 |
'retry_interval' => null,
|
484 |
+
];
|
485 |
|
486 |
+
$settings = [
|
487 |
'scheme',
|
488 |
'host',
|
489 |
'port',
|
493 |
'timeout',
|
494 |
'read_timeout',
|
495 |
'retry_interval',
|
496 |
+
];
|
497 |
|
498 |
foreach ( $settings as $setting ) {
|
499 |
$constant = sprintf( 'WP_REDIS_%s', strtoupper( $setting ) );
|
625 |
}
|
626 |
|
627 |
$servers = false;
|
628 |
+
$options = [];
|
629 |
|
630 |
if ( defined( 'WP_REDIS_SHARDS' ) ) {
|
631 |
$servers = WP_REDIS_SHARDS;
|
649 |
$parameters['read_write_timeout'] = $parameters['read_timeout'];
|
650 |
}
|
651 |
|
652 |
+
foreach ( [ 'WP_REDIS_SERVERS', 'WP_REDIS_SHARDS', 'WP_REDIS_CLUSTER' ] as $constant ) {
|
653 |
if ( defined( $constant ) ) {
|
654 |
if ( $parameters['database'] ) {
|
655 |
$options['parameters']['database'] = $parameters['database'];
|
743 |
$clients = $is_cluster ? WP_REDIS_CLUSTER : WP_REDIS_SERVERS;
|
744 |
|
745 |
foreach ( $clients as $index => &$connection_string ) {
|
746 |
+
// phpcs:ignore WordPress.WP.AlternativeFunctions.parse_url_parse_url
|
747 |
+
$url_components = parse_url( $connection_string );
|
748 |
+
|
749 |
parse_str( $url_components['query'], $add_params );
|
750 |
|
751 |
if ( ! $is_cluster && isset( $add_params['alias'] ) ) {
|
763 |
|
764 |
$this->redis = new Credis_Cluster( $clients );
|
765 |
|
766 |
+
foreach ( $clients as &$_client ) {
|
767 |
+
$connection_string = "{$_client['scheme']}://{$_client['host']}:{$_client['port']}";
|
768 |
+
unset( $_client['scheme'], $_client['host'], $_client['port'] );
|
769 |
+
|
770 |
+
$params = array_filter( $_client );
|
771 |
+
|
772 |
+
if ( $params ) {
|
773 |
+
$connection_string .= '?' . http_build_query( $params, null, '&' );
|
774 |
+
}
|
775 |
+
|
776 |
+
$_client = $connection_string;
|
777 |
+
}
|
778 |
+
|
779 |
$args['servers'] = $clients;
|
780 |
} else {
|
781 |
$args = [
|
966 |
// Save if group not excluded and redis is up.
|
967 |
if ( ! $this->is_ignored_group( $group ) && $this->redis_status() ) {
|
968 |
try {
|
969 |
+
$orig_exp = $expiration;
|
970 |
+
$expiration = $this->validate_expiration( $expiration );
|
971 |
+
|
972 |
+
/**
|
973 |
+
* Filters the cache expiration time
|
974 |
+
*
|
975 |
+
* @since 1.4.2
|
976 |
+
* @param int $expiration The time in seconds the entry expires. 0 for no expiry.
|
977 |
+
* @param string $key The cache key.
|
978 |
+
* @param string $group The cache group.
|
979 |
+
* @param mixed $orig_exp The original expiration value before validation.
|
980 |
+
*/
|
981 |
+
$expiration = apply_filters( 'redis_cache_expiration', $expiration, $key, $group, $orig_exp );
|
982 |
$start_time = microtime( true );
|
983 |
|
984 |
if ( $add ) {
|
1073 |
$this->cache_time += $execute_time;
|
1074 |
|
1075 |
if ( function_exists( 'do_action' ) ) {
|
1076 |
+
/**
|
1077 |
+
* Fires on every cache key deletion
|
1078 |
+
*
|
1079 |
+
* @since 1.3.3
|
1080 |
+
* @param string $key The cache key.
|
1081 |
+
* @param string $group The group value appended to the $key.
|
1082 |
+
* @param float $execute_time Execution time for the request in seconds.
|
1083 |
+
*/
|
1084 |
do_action( 'redis_object_cache_delete', $key, $group, $execute_time );
|
1085 |
}
|
1086 |
|
1102 |
}
|
1103 |
|
1104 |
$results = [];
|
1105 |
+
$this->cache = [];
|
1106 |
|
1107 |
if ( $this->redis_status() ) {
|
1108 |
$salt = defined( 'WP_REDIS_PREFIX' ) ? trim( WP_REDIS_PREFIX ) : null;
|
1160 |
if ( function_exists( 'do_action' ) ) {
|
1161 |
$execute_time = microtime( true ) - $start_time;
|
1162 |
|
1163 |
+
/**
|
1164 |
+
* Fires on every cache flush
|
1165 |
+
*
|
1166 |
+
* @since 1.3.5
|
1167 |
+
* @param null|array $results Array of flush results.
|
1168 |
+
* @param int $delay Given number of seconds to waited before invalidating the items.
|
1169 |
+
* @param bool $seletive Whether a selective flush took place.
|
1170 |
+
* @param string $salt The defined key prefix.
|
1171 |
+
* @param float $execute_time Execution time for the request in seconds.
|
1172 |
+
*/
|
1173 |
do_action( 'redis_object_cache_flush', $results, $delay, $selective, $salt, $execute_time );
|
1174 |
}
|
1175 |
}
|
1322 |
*
|
1323 |
* @param string $key The key under which to store the value.
|
1324 |
* @param string $group The group value appended to the $key.
|
1325 |
+
* @param bool $force Optional. Whether to force a refetch rather than relying on the local
|
1326 |
* cache. Default false.
|
1327 |
* @param bool $found Optional. Whether the key was found in the cache. Disambiguates a return of
|
1328 |
* false, a storable value. Passed by reference. Default null.
|
1372 |
$this->add_to_internal_cache( $derived_key, $value );
|
1373 |
|
1374 |
if ( function_exists( 'do_action' ) ) {
|
1375 |
+
/**
|
1376 |
+
* Fires on every cache get request
|
1377 |
+
*
|
1378 |
+
* @since 1.2.2
|
1379 |
+
* @param mixed $value Value of the cache entry.
|
1380 |
+
* @param string $key The cache key.
|
1381 |
+
* @param string $group The group value appended to the $key.
|
1382 |
+
* @param bool $force Whether a forced refetch has taken place rather than relying on the local cache.
|
1383 |
+
* @param bool $found Whether the key was found in the cache.
|
1384 |
+
* @param float $execute_time Execution time for the request in seconds.
|
1385 |
+
*/
|
1386 |
do_action( 'redis_object_cache_get', $key, $value, $group, $force, $found, $execute_time );
|
1387 |
}
|
1388 |
|
1389 |
if ( function_exists( 'apply_filters' ) && function_exists( 'has_filter' ) ) {
|
1390 |
if ( has_filter( 'redis_object_cache_get_value' ) ) {
|
1391 |
+
/**
|
1392 |
+
* Filters the return value
|
1393 |
+
*
|
1394 |
+
* @since 1.4.2
|
1395 |
+
* @param mixed $value Value of the cache entry.
|
1396 |
+
* @param string $key The cache key.
|
1397 |
+
* @param string $group The group value appended to the $key.
|
1398 |
+
* @param bool $force Whether a forced refetch has taken place rather than relying on the local cache.
|
1399 |
+
* @param bool $found Whether the key was found in the cache.
|
1400 |
+
*/
|
1401 |
return apply_filters( 'redis_object_cache_get_value', $value, $key, $group, $force, $found );
|
1402 |
}
|
1403 |
}
|
1419 |
return false;
|
1420 |
}
|
1421 |
|
1422 |
+
$cache = [];
|
1423 |
+
$derived_keys = [];
|
1424 |
|
1425 |
foreach ( $keys as $key ) {
|
1426 |
$derived_keys[ $key ] = $this->build_key( $key, $group );
|
1497 |
}
|
1498 |
|
1499 |
if ( function_exists( 'do_action' ) ) {
|
1500 |
+
/**
|
1501 |
+
* Fires on every cache get multiple request
|
1502 |
+
*
|
1503 |
+
* @since 2.0.6
|
1504 |
+
* @param mixed $value Value of the cache entry.
|
1505 |
+
* @param string $key The cache key.
|
1506 |
+
* @param string $group The group value appended to the $key.
|
1507 |
+
* @param bool $force Whether a forced refetch has taken place rather than relying on the local cache.
|
1508 |
+
* @param float $execute_time Execution time for the request in seconds.
|
1509 |
+
*/
|
1510 |
do_action( 'redis_object_cache_get_multiple', $keys, $cache, $group, $force, $execute_time );
|
1511 |
}
|
1512 |
|
1513 |
if ( function_exists( 'apply_filters' ) && function_exists( 'has_filter' ) ) {
|
1514 |
if ( has_filter( 'redis_object_cache_get_value' ) ) {
|
1515 |
foreach ( $cache as $key => $value ) {
|
1516 |
+
/**
|
1517 |
+
* Filters the return value
|
1518 |
+
*
|
1519 |
+
* @since 1.4.2
|
1520 |
+
* @param mixed $value Value of the cache entry.
|
1521 |
+
* @param string $key The cache key.
|
1522 |
+
* @param string $group The group value appended to the $key.
|
1523 |
+
* @param bool $force Whether a forced refetch has taken place rather than relying on the local cache.
|
1524 |
+
*/
|
1525 |
$cache[ $key ] = apply_filters( 'redis_object_cache_get_value', $value, $key, $group, $force );
|
1526 |
}
|
1527 |
}
|
1549 |
|
1550 |
// Save if group not excluded from redis and redis is up.
|
1551 |
if ( ! $this->is_ignored_group( $group ) && $this->redis_status() ) {
|
1552 |
+
$orig_exp = $expiration;
|
1553 |
+
$expiration = $this->validate_expiration( $expiration );
|
1554 |
+
|
1555 |
+
/**
|
1556 |
+
* Filters the cache expiration time
|
1557 |
+
*
|
1558 |
+
* @since 1.4.2
|
1559 |
+
* @param int $expiration The time in seconds the entry expires. 0 for no expiry.
|
1560 |
+
* @param string $key The cache key.
|
1561 |
+
* @param string $group The cache group.
|
1562 |
+
* @param mixed $orig_exp The original expiration value before validation.
|
1563 |
+
*/
|
1564 |
+
$expiration = apply_filters( 'redis_cache_expiration', $expiration, $key, $group, $orig_exp );
|
1565 |
|
1566 |
try {
|
1567 |
if ( $expiration ) {
|
1587 |
if ( function_exists( 'do_action' ) ) {
|
1588 |
$execute_time = microtime( true ) - $start_time;
|
1589 |
|
1590 |
+
/**
|
1591 |
+
* Fires on every cache set
|
1592 |
+
*
|
1593 |
+
* @since 1.2.2
|
1594 |
+
* @param string $key The cache key.
|
1595 |
+
* @param mixed $value Value of the cache entry.
|
1596 |
+
* @param string $group The group value appended to the $key.
|
1597 |
+
* @param int $expiration The time in seconds the entry expires. 0 for no expiry.
|
1598 |
+
* @param float $execute_time Execution time for the request in seconds.
|
1599 |
+
*/
|
1600 |
do_action( 'redis_object_cache_set', $key, $value, $group, $expiration, $execute_time );
|
1601 |
}
|
1602 |
|
1743 |
);
|
1744 |
|
1745 |
return (object) [
|
1746 |
+
// Connected, Disabled, Unknown, Not connected
|
1747 |
+
'status' => '...',
|
1748 |
'hits' => $this->cache_hits,
|
1749 |
'misses' => $this->cache_misses,
|
1750 |
'ratio' => $total > 0 ? round( $this->cache_hits / ( $total / 100 ), 1 ) : 100,
|
2116 |
error_log( $exception ); // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_error_log
|
2117 |
|
2118 |
if ( function_exists( 'do_action' ) ) {
|
2119 |
+
/**
|
2120 |
+
* Fires on every cache error
|
2121 |
+
*
|
2122 |
+
* @since 1.5.0
|
2123 |
+
* @param \Exception $exception The exception triggered.
|
2124 |
+
*/
|
2125 |
do_action( 'redis_object_cache_error', $exception );
|
2126 |
}
|
2127 |
}
|
includes/ui/class-tab.php
CHANGED
@@ -74,6 +74,7 @@ class Tab {
|
|
74 |
'file' => WP_REDIS_PLUGIN_PATH . "/includes/ui/tabs/{$slug}.php",
|
75 |
]
|
76 |
);
|
|
|
77 |
foreach ( $args ?: [] as $property => $value ) {
|
78 |
if ( property_exists( $this, $property ) ) {
|
79 |
$this->{$property} = $value;
|
@@ -138,6 +139,7 @@ class Tab {
|
|
138 |
if ( ! isset( $this->custom[ $key ] ) ) {
|
139 |
return null;
|
140 |
}
|
|
|
141 |
return $this->custom[ $key ];
|
142 |
}
|
143 |
|
@@ -161,6 +163,7 @@ class Tab {
|
|
161 |
*/
|
162 |
public function display() {
|
163 |
$roc = Plugin::instance();
|
|
|
164 |
include $this->file;
|
165 |
}
|
166 |
|
@@ -170,7 +173,16 @@ class Tab {
|
|
170 |
* @return string
|
171 |
*/
|
172 |
public function nav_id() {
|
173 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
174 |
}
|
175 |
|
176 |
/**
|
@@ -182,12 +194,22 @@ class Tab {
|
|
182 |
$classes = [
|
183 |
'nav-tab',
|
184 |
];
|
|
|
185 |
if ( $this->default ) {
|
186 |
$classes[] = 'nav-tab-active';
|
187 |
}
|
|
|
188 |
if ( $this->disabled ) {
|
189 |
$classes[] = 'nav-tab-disabled';
|
190 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
191 |
return implode( ' ', apply_filters( 'roc_tab_nav_classes', $classes, $this ) );
|
192 |
}
|
193 |
|
@@ -197,7 +219,16 @@ class Tab {
|
|
197 |
* @return string
|
198 |
*/
|
199 |
public function id() {
|
200 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
201 |
}
|
202 |
|
203 |
/**
|
@@ -210,9 +241,18 @@ class Tab {
|
|
210 |
'tab-pane',
|
211 |
"tab-pane-{$this->slug}",
|
212 |
];
|
|
|
213 |
if ( $this->default ) {
|
214 |
$classes[] = 'active';
|
215 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
216 |
return implode( ' ', apply_filters( 'roc_tab_classes', $classes, $this ) );
|
217 |
}
|
218 |
|
74 |
'file' => WP_REDIS_PLUGIN_PATH . "/includes/ui/tabs/{$slug}.php",
|
75 |
]
|
76 |
);
|
77 |
+
|
78 |
foreach ( $args ?: [] as $property => $value ) {
|
79 |
if ( property_exists( $this, $property ) ) {
|
80 |
$this->{$property} = $value;
|
139 |
if ( ! isset( $this->custom[ $key ] ) ) {
|
140 |
return null;
|
141 |
}
|
142 |
+
|
143 |
return $this->custom[ $key ];
|
144 |
}
|
145 |
|
163 |
*/
|
164 |
public function display() {
|
165 |
$roc = Plugin::instance();
|
166 |
+
|
167 |
include $this->file;
|
168 |
}
|
169 |
|
173 |
* @return string
|
174 |
*/
|
175 |
public function nav_id() {
|
176 |
+
$nav_id = "{$this->slug}-tab";
|
177 |
+
|
178 |
+
/**
|
179 |
+
* Filters the tab's nav id
|
180 |
+
*
|
181 |
+
* @since 2.0.12
|
182 |
+
* @param string $nav_id The id attribute of the current tab's nav element.
|
183 |
+
* @param Tab $this The current tab.
|
184 |
+
*/
|
185 |
+
return apply_filters( 'roc_tab_nav_id', $nav_id, $this );
|
186 |
}
|
187 |
|
188 |
/**
|
194 |
$classes = [
|
195 |
'nav-tab',
|
196 |
];
|
197 |
+
|
198 |
if ( $this->default ) {
|
199 |
$classes[] = 'nav-tab-active';
|
200 |
}
|
201 |
+
|
202 |
if ( $this->disabled ) {
|
203 |
$classes[] = 'nav-tab-disabled';
|
204 |
}
|
205 |
+
|
206 |
+
/**
|
207 |
+
* Filters the current tab's nav element css classes
|
208 |
+
*
|
209 |
+
* @since 2.0.12
|
210 |
+
* @param array $classes Array of css classes.
|
211 |
+
* @param Tab $this The current tab.
|
212 |
+
*/
|
213 |
return implode( ' ', apply_filters( 'roc_tab_nav_classes', $classes, $this ) );
|
214 |
}
|
215 |
|
219 |
* @return string
|
220 |
*/
|
221 |
public function id() {
|
222 |
+
$tab_id = "{$this->slug}-pane";
|
223 |
+
|
224 |
+
/**
|
225 |
+
* Filters the tab's id
|
226 |
+
*
|
227 |
+
* @since 2.0.12
|
228 |
+
* @param string $tab_id The id attribute of the current tab element.
|
229 |
+
* @param Tab $this The current tab.
|
230 |
+
*/
|
231 |
+
return apply_filters( 'roc_tab_id', $tab_id, $this );
|
232 |
}
|
233 |
|
234 |
/**
|
241 |
'tab-pane',
|
242 |
"tab-pane-{$this->slug}",
|
243 |
];
|
244 |
+
|
245 |
if ( $this->default ) {
|
246 |
$classes[] = 'active';
|
247 |
}
|
248 |
+
|
249 |
+
/**
|
250 |
+
* Filters the current tab's css classes
|
251 |
+
*
|
252 |
+
* @since 2.0.12
|
253 |
+
* @param array $classes Array of css classes.
|
254 |
+
* @param Tab $this The current tab.
|
255 |
+
*/
|
256 |
return implode( ' ', apply_filters( 'roc_tab_classes', $classes, $this ) );
|
257 |
}
|
258 |
|
includes/ui/diagnostics.php
CHANGED
@@ -61,7 +61,7 @@ if ( $dropin ) {
|
|
61 |
$info['Blog Prefix'] = wp_json_encode( $wp_object_cache->blog_prefix );
|
62 |
}
|
63 |
|
64 |
-
$constants =
|
65 |
'WP_REDIS_DISABLED',
|
66 |
'WP_REDIS_CLIENT',
|
67 |
'WP_REDIS_SCHEME',
|
@@ -83,7 +83,7 @@ $constants = array(
|
|
83 |
'WP_REDIS_GLOBAL_GROUPS',
|
84 |
'WP_REDIS_IGNORED_GROUPS',
|
85 |
'WP_REDIS_UNFLUSHABLE_GROUPS',
|
86 |
-
|
87 |
|
88 |
foreach ( $constants as $constant ) {
|
89 |
if ( defined( $constant ) ) {
|
61 |
$info['Blog Prefix'] = wp_json_encode( $wp_object_cache->blog_prefix );
|
62 |
}
|
63 |
|
64 |
+
$constants = [
|
65 |
'WP_REDIS_DISABLED',
|
66 |
'WP_REDIS_CLIENT',
|
67 |
'WP_REDIS_SCHEME',
|
83 |
'WP_REDIS_GLOBAL_GROUPS',
|
84 |
'WP_REDIS_IGNORED_GROUPS',
|
85 |
'WP_REDIS_UNFLUSHABLE_GROUPS',
|
86 |
+
];
|
87 |
|
88 |
foreach ( $constants as $constant ) {
|
89 |
if ( defined( $constant ) ) {
|
readme.txt
CHANGED
@@ -5,7 +5,7 @@ Tags: redis, predis, phpredis, credis, hhvm, pecl, caching, cache, object cache,
|
|
5 |
Requires at least: 3.3
|
6 |
Tested up to: 5.5
|
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,6 +83,15 @@ To see a list of all available WP-CLI commands, please see the [WP CLI commands
|
|
83 |
|
84 |
== Changelog ==
|
85 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
86 |
= 2.0.12 =
|
87 |
|
88 |
- Fixed bytes metrics calculation
|
@@ -450,6 +459,6 @@ Since Predis isn't maintained any longer, it's highly recommended to switch over
|
|
450 |
|
451 |
== Upgrade Notice ==
|
452 |
|
453 |
-
= 2.0.
|
454 |
|
455 |
Version 2.0 is a significant rewrite of the plugin. Please read the v2.0.0 release notes.
|
5 |
Requires at least: 3.3
|
6 |
Tested up to: 5.5
|
7 |
Requires PHP: 5.6
|
8 |
+
Stable tag: 2.0.13
|
9 |
License: GPLv3
|
10 |
License URI: http://www.gnu.org/licenses/gpl-3.0.html
|
11 |
|
83 |
|
84 |
== Changelog ==
|
85 |
|
86 |
+
= 2.0.13 =
|
87 |
+
|
88 |
+
- Updated bundled Predis library to v1.1.4
|
89 |
+
- Made `redis-cache` a global group for improved metrics on multisite
|
90 |
+
- Switched to short array syntax
|
91 |
+
- Added `@since` tags to all functions
|
92 |
+
- Use `parse_url()` instead of `wp_parse_url()` in drop-in
|
93 |
+
- Fixed plugin instance variable name in `wp redis status`
|
94 |
+
|
95 |
= 2.0.12 =
|
96 |
|
97 |
- Fixed bytes metrics calculation
|
459 |
|
460 |
== Upgrade Notice ==
|
461 |
|
462 |
+
= 2.0.13 =
|
463 |
|
464 |
Version 2.0 is a significant rewrite of the plugin. Please read the v2.0.0 release notes.
|
redis-cache.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
* Plugin Name: Redis Object Cache
|
4 |
* Plugin URI: https://wordpress.org/plugins/redis-cache/
|
5 |
* Description: A persistent object cache backend powered by Redis. Supports Predis, PhpRedis, Credis, HHVM, replication, clustering and WP-CLI.
|
6 |
-
* Version: 2.0.
|
7 |
* Text Domain: redis-cache
|
8 |
* Domain Path: /languages
|
9 |
* Network: true
|
3 |
* Plugin Name: Redis Object Cache
|
4 |
* Plugin URI: https://wordpress.org/plugins/redis-cache/
|
5 |
* Description: A persistent object cache backend powered by Redis. Supports Predis, PhpRedis, Credis, HHVM, replication, clustering and WP-CLI.
|
6 |
+
* Version: 2.0.13
|
7 |
* Text Domain: redis-cache
|
8 |
* Domain Path: /languages
|
9 |
* Network: true
|