diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 81bb8a45f..69ff597d2 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -1,60 +1,48 @@
on:
- - pull_request
- - push
+ pull_request:
+ paths-ignore:
+ - 'docs/**'
+ - 'README.md'
+ - 'CHANGELOG.md'
+ - '.gitignore'
+ - '.gitattributes'
+
+ push:
+ paths-ignore:
+ - 'docs/**'
+ - 'README.md'
+ - 'CHANGELOG.md'
+ - '.gitignore'
+ - '.gitattributes'
name: build
jobs:
tests:
- name: PHP ${{ matrix.php }}-redis-4
+ name: PHP ${{ matrix.php }}-redis-${{ matrix.redis }}
runs-on: ${{ matrix.os }}
strategy:
+ fail-fast: false
+
matrix:
os:
- ubuntu-latest
php:
- - "5.4"
- - "5.5"
- - "5.6"
- - "7.0"
- - "7.1"
- - "7.2"
- "7.3"
- "7.4"
+ - "8.0"
+ - "8.1"
+ - "8.2"
+ - "8.3"
+ - "8.4"
steps:
- name: Checkout
uses: actions/checkout@v2
- - name: Start Redis v4
- uses: superchargejs/redis-github-action@1.1.0
- with:
- redis-version: 4
-
- - name: Install PHP with extensions
- uses: shivammathur/setup-php@v2
- with:
- php-version: ${{ matrix.php }}
- extensions: curl, intl, redis
- ini-values: date.timezone='UTC'
- tools: composer:v2, pecl
-
- - name: Get Composer cache directory
- id: composer-cache
- run: echo "::set-output name=dir::$(composer config cache-files-dir)"
-
- - name: Cache Composer dependencies
- uses: actions/cache@v2.1.4
- with:
- path: ${{ steps.composer-cache.outputs.dir }}
- key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
- restore-keys: ${{ runner.os }}-composer-
-
- - name: Install dependencies with Composer
- run: composer update --prefer-dist --no-interaction --no-progress --optimize-autoloader
-
- - name: Run Redis tests with PhpUnit
- run: vendor/bin/phpunit --coverage-clover=coverage.clover
+ - name: PHP tests for PHP ${{ matrix.php }}
+ run: |
+ make test-sentinel v=${{ matrix.php }}
diff --git a/.github/workflows/ci-redis.yml b/.github/workflows/ci-redis.yml
deleted file mode 100644
index 7517670c8..000000000
--- a/.github/workflows/ci-redis.yml
+++ /dev/null
@@ -1,69 +0,0 @@
-on:
- - pull_request
- - push
-
-name: ci-redis
-
-jobs:
- tests:
- name: PHP ${{ matrix.php }}-redis-${{ matrix.redis }}
-
- runs-on: ${{ matrix.os }}
-
- strategy:
- matrix:
- os:
- - ubuntu-latest
-
- php:
- - "7.4"
-
- redis:
- - "5"
- - "6"
-
- steps:
- - name: Checkout
- uses: actions/checkout@v2
-
- - name: Start Redis v${{ matrix.redis }}
- uses: superchargejs/redis-github-action@1.1.0
- with:
- redis-version: ${{ matrix.redis }}
-
- - name: Install PHP with extensions
- uses: shivammathur/setup-php@v2
- with:
- php-version: ${{ matrix.php }}
- extensions: curl, intl, redis
- ini-values: date.timezone='UTC'
- coverage: xdebug
- tools: composer:v2, pecl
-
- - name: Get Composer cache directory
- id: composer-cache
- run: echo "::set-output name=dir::$(composer config cache-files-dir)"
-
- - name: Cache Composer dependencies
- uses: actions/cache@v2.1.4
- with:
- path: ${{ steps.composer-cache.outputs.dir }}
- key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
- restore-keys: ${{ runner.os }}-composer-
-
- - name: Install dependencies with Composer
- run: composer update --prefer-dist --no-interaction --no-progress --optimize-autoloader
-
- - name: Run Redis 5 tests with PhpUnit
- if: matrix.redis == '5'
- run: vendor/bin/phpunit
-
- - name: Run Redis 6 tests with PhpUnit and coverage
- if: matrix.redis == '6'
- run: vendor/bin/phpunit --coverage-clover=coverage.clover
-
- - name: Code coverage
- if: matrix.redis == '6'
- run: |
- wget https://scrutinizer-ci.com/ocular.phar
- php ocular.phar code-coverage:upload --format=php-clover coverage.clover
diff --git a/CHANGELOG.md b/CHANGELOG.md
index e7e13ee02..60703df09 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -4,7 +4,9 @@ Yii Framework 2 redis extension Change Log
2.0.21 under development
------------------------
-- no changes in this release.
+- New #276: Added support for predis (antonshevelev)
+- New #276: Changed default value of yii\redis\Cache::$forceClusterMode to false (antonshevelev)
+- New #276: Implemented yii\redis\ConnectionInterface in yii\redis\Connection (antonshevelev)
2.0.20 June 05, 2025
diff --git a/Makefile b/Makefile
index b6dd0e982..7ae831b87 100644
--- a/Makefile
+++ b/Makefile
@@ -35,3 +35,15 @@ clean:
docker rm $(shell cat tests/dockerids/redis)
rm tests/dockerids/redis
+test-sentinel:
+ make build
+ PHP_VERSION=$(filter-out $@,$(MAKECMDGOALS)) docker compose -f tests/docker/docker-compose.yml build --pull yii2-redis-php
+ PHP_VERSION=$(filter-out $@,$(MAKECMDGOALS)) docker compose -f tests/docker/docker-compose.yml up -d
+ PHP_VERSION=$(filter-out $@,$(MAKECMDGOALS)) docker compose -f tests/docker/docker-compose.yml exec yii2-redis-php sh -c "composer update && vendor/bin/phpunit --coverage-clover=coverage.clover"
+
+build: ## Build an image from a docker-compose file. Params: {{ v=8.1 }}. Default latest PHP 8.1
+ PHP_VERSION=$(filter-out $@,$(v)) docker compose -f tests/docker/docker-compose.yml up -d --build
+
+down: ## Stop and remove containers, networks
+ docker compose -f tests/docker/docker-compose.yml down
+
diff --git a/README.md b/README.md
index a56d84f59..c4725d47c 100644
--- a/README.md
+++ b/README.md
@@ -22,7 +22,7 @@ Documentation is at [docs/guide/README.md](docs/guide/README.md).
Requirements
------------
-At least redis version 2.6.12 is required for all components to work properly.
+At least redis version is required for all components to work properly.
Installation
------------
@@ -100,3 +100,8 @@ return [
]
];
```
+
+Additional topics
+-----------------
+
+* [predis support](/docs/guide/predis.md)
diff --git a/composer.json b/composer.json
index 045be6205..5b10edfd8 100644
--- a/composer.json
+++ b/composer.json
@@ -1,6 +1,13 @@
{
"name": "yiisoft/yii2-redis",
"description": "Redis Cache, Session and ActiveRecord for the Yii framework",
+ "keywords": [
+ "yii2",
+ "redis",
+ "active-record",
+ "cache",
+ "session"
+ ],
"keywords": ["yii2", "redis", "active-record", "cache", "session"],
"type": "yii2-extension",
"license": "BSD-3-Clause",
@@ -18,11 +25,13 @@
}
],
"require": {
+ "php": "^7.3 || ^8.0",
"yiisoft/yii2": "~2.0.39",
- "ext-openssl": "*"
+ "ext-openssl": "*",
+ "predis/predis": "^v2.3.0|^3.0"
},
"require-dev": {
- "phpunit/phpunit": "<7",
+ "phpunit/phpunit": "9.*",
"yiisoft/yii2-dev": "~2.0.39"
},
"autoload": {
diff --git a/docs/guide-ja/README.md b/docs/guide-ja/README.md
index e842949f0..c124acdec 100644
--- a/docs/guide-ja/README.md
+++ b/docs/guide-ja/README.md
@@ -9,6 +9,7 @@ Yii 2 Redis キャッシュ、セッションおよびアクティブレコー
--------
* [インストール](installation.md)
+* [Predisサポート](predis.md)
使用方法
--------
diff --git a/docs/guide-ja/predis.md b/docs/guide-ja/predis.md
new file mode 100644
index 000000000..fefae5f0f
--- /dev/null
+++ b/docs/guide-ja/predis.md
@@ -0,0 +1,70 @@
+Yii 2 Redis キャッシュ、セッションおよびアクティブレコード Predis
+===============================================
+## アプリケーションを構成する
+
+このエクステンションを使用するためには、アプリケーション構成情報で [[yii\redis\predis\PredisConnection]] クラスを構成する必要があります。
+
+> Warning: yii\redis\predis\PredisConnection クラスは redis-cluster 接続をサポートしますが、*cache*、*session*、*ActiveRecord*、*mutex* コンポーネント インタフェースのサポートは提供しません。
+
+### standalone
+```php
+return [
+ //....
+ 'components' => [
+ 'redis' => [
+ 'class' => 'yii\redis\predis\PredisConnection',
+ 'parameters' => 'tcp://redis:6379',
+ 'options' => [
+ 'parameters' => [
+ 'password' => 'secret', // Or NULL
+ 'database' => 0,
+ 'persistent' => true,
+ 'async_connect' => true,
+ 'read_write_timeout' => 0.1,
+ ],
+ ],
+ ],
+ ]
+];
+```
+### sentinel
+```php
+return [
+ //....
+ 'components' => [
+ 'redis' => [
+ 'class' => 'yii\redis\predis\PredisConnection',
+ 'parameters' => [
+ 'tcp://redis-node-1:26379',
+ 'tcp://redis-node-2:26379',
+ 'tcp://redis-node-3:26379',
+ ],
+ 'options' => [
+ 'parameters' => [
+ 'password' => 'secret', // Or NULL
+ 'database' => 0,
+ 'persistent' => true,
+ 'async_connect' => true,
+ 'read_write_timeout' => 0.1,
+ ],
+ ],
+ ],
+ ]
+];
+```
+
+> 接続構成とオプションの詳細については、predis のドキュメントを参照してください。
+
+これで、`redis` アプリケーション・コンポーネントによって、redis ストレージに対する基本的なアクセスが提供されるようになります。
+
+```php
+Yii::$app->redis->set('mykey', 'some value');
+echo Yii::$app->redis->get('mykey');
+```
+
+追加のトピック
+-----------------
+
+* [predisでキャッシュコンポーネントを使用する](topics-predis-cache.md)
+* [Predisでセッションコンポーネントを使用する](topics-predis-session.md)
+
diff --git a/docs/guide-ja/topics-cache.md b/docs/guide-ja/topics-cache.md
index 713e4a70f..8384e62db 100644
--- a/docs/guide-ja/topics-cache.md
+++ b/docs/guide-ja/topics-cache.md
@@ -37,7 +37,7 @@ return [
```
このキャッシュは [[yii\caching\CacheInterface]] の全てのメソッドを提供します。インタフェイスに含まれていない redis 固有のメソッドにアクセスしたい場合は、
-[[yii\redis\Connection]] のインスタンスである [[yii\redis\Cache::$redis]] を通じてアクセスすることが出来ます。
+[[yii\redis\ConnectionInterface]] のインスタンスである [[yii\redis\Cache::$redis]] を通じてアクセスすることが出来ます。
```php
Yii::$app->cache->redis->hset('mykey', 'somefield', 'somevalue');
diff --git a/docs/guide-ja/topics-predis-cache.md b/docs/guide-ja/topics-predis-cache.md
new file mode 100644
index 000000000..54124bd03
--- /dev/null
+++ b/docs/guide-ja/topics-predis-cache.md
@@ -0,0 +1,53 @@
+キャッシュ・コンポーネントを使用する Predis
+=========================
+
+`Cache` コンポーネントを使用するためには、[predis](predis.md) の節で説明した接続の構成に加えて、
+`cache` コンポーネントを [[yii\redis\Cache]] として構成する必要があります。
+
+```php
+return [
+ //....
+ 'components' => [
+ // ...
+ 'redis' => [
+ 'class' => 'yii\redis\predis\PredisConnection',
+ 'parameters' => 'tcp://redis:6379',
+ // ...
+ ],
+ 'cache' => [
+ 'class' => 'yii\redis\Cache',
+ ],
+ ]
+];
+```
+
+redis をキャッシュとしてのみ使用する場合、すなわち、redis のアクティブレコードやセッションを使用しない場合は、接続のパラメータをキャッシュ・コンポーネントの中で構成しても構いません
+(この場合、接続のアプリケーション・コンポーネントを構成する必要はありません)。
+
+```php
+return [
+ //....
+ 'components' => [
+ // ...
+ 'cache' => [
+ 'class' => 'yii\redis\Cache',
+ 'redis' => [
+ 'class' => 'yii\redis\predis\PredisConnection',
+ 'parameters' => 'tcp://redis:6379',
+ // ...
+ ],
+ ],
+ ]
+];
+```
+
+このキャッシュは [[yii\caching\CacheInterface]] の全てのメソッドを提供します。インタフェイスに含まれていない redis 固有のメソッドにアクセスしたい場合は、
+[[yii\redis\ConnectionInterface]] のインスタンスである [[yii\redis\Cache::$redis]] を通じてアクセスすることが出来ます。
+
+```php
+Yii::$app->cache->redis->hset('mykey', 'somefield', 'somevalue');
+Yii::$app->cache->redis->hget('mykey', 'somefield');
+...
+```
+
+利用可能なメソッドの一覧は [[yii\redis\predis\PredisConnection]] を参照して下さい。
diff --git a/docs/guide-ja/topics-predis-session.md b/docs/guide-ja/topics-predis-session.md
new file mode 100644
index 000000000..0f35fb02b
--- /dev/null
+++ b/docs/guide-ja/topics-predis-session.md
@@ -0,0 +1,42 @@
+セッション・コンポーネントを使用する Predis
+===========================
+
+`Session` コンポーネントを使用するためには、[predis](predis.md) の節で説明した接続の構成に加えて、
+`session` コンポーネントを [[yii\redis\Session]] として構成する必要があります。
+
+```php
+return [
+ //....
+ 'components' => [
+ // ...
+ 'redis' => [
+ 'class' => 'yii\redis\predis\PredisConnection',
+ 'parameters' => 'tcp://redis:6379',
+ // ...
+ ],
+ 'session' => [
+ 'class' => 'yii\redis\Session',
+ ],
+ ]
+];
+```
+
+redis をセッションとしてのみ使用する場合、すなわち、redis のアクティブレコードやキャッシュは使わない場合は、接続のパラメータをセッション・コンポーネントの中で構成しても構いません
+(この場合、接続のアプリケーション・コンポーネントを構成する必要はありません)。
+
+```php
+return [
+ //....
+ 'components' => [
+ // ...
+ 'session' => [
+ 'class' => 'yii\redis\Session',
+ 'redis' => [
+ 'class' => 'yii\redis\predis\PredisConnection',
+ 'parameters' => 'tcp://redis:6379',
+ // ...
+ ],
+ ],
+ ]
+];
+```
diff --git a/docs/guide-pt-BR/README.md b/docs/guide-pt-BR/README.md
index 5efdd8e40..9a23b7775 100644
--- a/docs/guide-pt-BR/README.md
+++ b/docs/guide-pt-BR/README.md
@@ -7,6 +7,7 @@ Iniciando
---------------
* [Instalação](installation.md)
+* [Suporte predis](predis.md)
Uso
-----
diff --git a/docs/guide-pt-BR/predis.md b/docs/guide-pt-BR/predis.md
new file mode 100644
index 000000000..ecab38cf2
--- /dev/null
+++ b/docs/guide-pt-BR/predis.md
@@ -0,0 +1,70 @@
+Predis para Redis Cache, Sessão e ActiveRecord para Yii 2
+===============================================
+## Configurando a aplicação
+
+Para usar essa extensão, você precisa parametrizar a classe [[yii\redis\predis\PredisConnection]] na configuração da aplicação:
+
+> Warning: A classe yii\redis\predis\PredisConnection suporta conexão redis-cluster, mas não fornece suporte para as interfaces de componentes *cache*, *session*, *ActiveRecord*, *mutex*.
+
+### standalone
+```php
+return [
+ //....
+ 'components' => [
+ 'redis' => [
+ 'class' => 'yii\redis\predis\PredisConnection',
+ 'parameters' => 'tcp://redis:6379',
+ 'options' => [
+ 'parameters' => [
+ 'password' => 'secret', // Or NULL
+ 'database' => 0,
+ 'persistent' => true,
+ 'async_connect' => true,
+ 'read_write_timeout' => 0.1,
+ ],
+ ],
+ ],
+ ]
+];
+```
+### sentinel
+```php
+return [
+ //....
+ 'components' => [
+ 'redis' => [
+ 'class' => 'yii\redis\predis\PredisConnection',
+ 'parameters' => [
+ 'tcp://redis-node-1:26379',
+ 'tcp://redis-node-2:26379',
+ 'tcp://redis-node-3:26379',
+ ],
+ 'options' => [
+ 'parameters' => [
+ 'password' => 'secret', // Or NULL
+ 'database' => 0,
+ 'persistent' => true,
+ 'async_connect' => true,
+ 'read_write_timeout' => 0.1,
+ ],
+ ],
+ ],
+ ]
+];
+```
+
+> Mais informações sobre configuração e opções de conexão podem ser encontradas na documentação do predis.
+
+Isto fornece o acesso básico ao armazenamento de redis através do componente de aplicação `redis`:
+
+```php
+Yii::$app->redis->set('mykey', 'some value');
+echo Yii::$app->redis->get('mykey');
+```
+
+Additional topics
+-----------------
+
+* [Usando o componente Cache com predis](topics-predis-cache.md)
+* [Usando o componente Session com predis](topics-predis-session.md)
+
diff --git a/docs/guide-pt-BR/topics-cache.md b/docs/guide-pt-BR/topics-cache.md
index 25b9503d2..b33e4cb77 100644
--- a/docs/guide-pt-BR/topics-cache.md
+++ b/docs/guide-pt-BR/topics-cache.md
@@ -35,7 +35,7 @@ return [
];
```
-O cache fornece todos os métodos do [[yii\caching\CacheInterface]]. Se você quiser acessar os métodos específicos do redis que não são incluído na interface, você pode usá-los via [[yii\redis\Cache::$redis]], que é uma instância de [[yii\redis\Connection]]:
+O cache fornece todos os métodos do [[yii\caching\CacheInterface]]. Se você quiser acessar os métodos específicos do redis que não são incluído na interface, você pode usá-los via [[yii\redis\Cache::$redis]], que é uma instância de [[yii\redis\ConnectionInterface]]:
```php
Yii::$app->cache->redis->hset('mykey', 'somefield', 'somevalue');
diff --git a/docs/guide-pt-BR/topics-predis-cache.md b/docs/guide-pt-BR/topics-predis-cache.md
new file mode 100644
index 000000000..7dc34f46a
--- /dev/null
+++ b/docs/guide-pt-BR/topics-predis-cache.md
@@ -0,0 +1,51 @@
+Usando o componente Cache com predis
+=========================
+
+Para usar o componente `Cache`, além de configurar a conexão conforme descrito na seção [predis](predis.md),
+você também tem que configurar o componente `cache` para ser [[yii\redis\Cache]]:
+
+```php
+return [
+ //....
+ 'components' => [
+ // ...
+ 'redis' => [
+ 'class' => 'yii\redis\predis\PredisConnection',
+ 'parameters' => 'tcp://redis:6379',
+ // ...
+ ],
+ 'cache' => [
+ 'class' => 'yii\redis\Cache',
+ ],
+ ]
+];
+```
+
+Se você usa apenas o cache de redis (ou seja, não está usando seu ActiveRecord ou Session), você também pode configurar os parâmetros da conexão dentro do componente de cache (nenhum componente de aplicativo de conexão precisa ser configurado neste caso):
+
+```php
+return [
+ //....
+ 'components' => [
+ // ...
+ 'cache' => [
+ 'class' => 'yii\redis\Cache',
+ 'redis' => [
+ 'class' => 'yii\redis\predis\PredisConnection',
+ 'parameters' => 'tcp://redis:6379',
+ // ...
+ ],
+ ],
+ ]
+];
+```
+
+O cache fornece todos os métodos do [[yii\caching\CacheInterface]]. Se você quiser acessar os métodos específicos do redis que não são incluído na interface, você pode usá-los via [[yii\redis\Cache::$redis]], que é uma instância de [[yii\redis\ConnectionInterface]]:
+
+```php
+Yii::$app->cache->redis->hset('mykey', 'somefield', 'somevalue');
+Yii::$app->cache->redis->hget('mykey', 'somefield');
+...
+```
+
+Veja [[yii\redis\predis\PredisConnection]] para a lista completa de métodos disponíveis.
diff --git a/docs/guide-pt-BR/topics-predis-session.md b/docs/guide-pt-BR/topics-predis-session.md
new file mode 100644
index 000000000..5d44fe7ab
--- /dev/null
+++ b/docs/guide-pt-BR/topics-predis-session.md
@@ -0,0 +1,42 @@
+Usando o componente Session com predis
+===========================
+
+Para usar o componente `Session`, além de configurar a conexão conforme descrito na seção [predis](predis.md),
+você também tem que configurar o componente `session` para ser [[yii\redis\Session]]:
+
+```php
+return [
+ //....
+ 'components' => [
+ // ...
+ 'redis' => [
+ 'class' => 'yii\redis\predis\PredisConnection',
+ 'parameters' => 'tcp://redis:6379',
+ // ...
+ ],
+ 'session' => [
+ 'class' => 'yii\redis\Session',
+ ],
+ ]
+];
+```
+
+Se você usar somente a sessão de redis (ou seja, não usar seu ActiveRecord ou Cache), você também pode configurar os parâmetros da conexão dentro do
+componente de sessão (nenhum componente de aplicativo de conexão precisa ser configurado neste caso):
+
+```php
+return [
+ //....
+ 'components' => [
+ // ...
+ 'session' => [
+ 'class' => 'yii\redis\Session',
+ 'redis' => [
+ 'class' => 'yii\redis\predis\PredisConnection',
+ 'parameters' => 'tcp://redis:6379',
+ // ...
+ ],
+ ],
+ ]
+];
+```
diff --git a/docs/guide-ru/README.md b/docs/guide-ru/README.md
index 2302d3f68..f8336377f 100644
--- a/docs/guide-ru/README.md
+++ b/docs/guide-ru/README.md
@@ -9,6 +9,7 @@ Redis Cache, Session и ActiveRecord для Yii 2
---------------
* [Установка](installation.md)
+* [Поддержка predis](predis.md)
Использование
-----
diff --git a/docs/guide-ru/predis.md b/docs/guide-ru/predis.md
new file mode 100644
index 000000000..24f2e33f6
--- /dev/null
+++ b/docs/guide-ru/predis.md
@@ -0,0 +1,70 @@
+Predis для Redis Cache, Session и ActiveRecord
+===============================================
+## Конфигурирование приложения
+
+Чтобы использовать это расширение, вам необходимо настроить класс [[yii\redis\predis\PredisConnection]] в конфигурации вашего приложения:
+
+> Warning: Класс `yii\redis\predis\PredisConnection` поддерживает подключение redis-cluster, но не даёт поддержки интерфейсов компонентов *cache*, *session*, *ActiveRecord*, *mutex*
+
+### standalone
+```php
+return [
+ //....
+ 'components' => [
+ 'redis' => [
+ 'class' => 'yii\redis\predis\PredisConnection',
+ 'parameters' => 'tcp://redis:6379',
+ 'options' => [
+ 'parameters' => [
+ 'password' => 'secret', // Or NULL
+ 'database' => 0,
+ 'persistent' => true,
+ 'async_connect' => true,
+ 'read_write_timeout' => 0.1,
+ ],
+ ],
+ ],
+ ]
+];
+```
+### sentinel
+```php
+return [
+ //....
+ 'components' => [
+ 'redis' => [
+ 'class' => 'yii\redis\predis\PredisConnection',
+ 'parameters' => [
+ 'tcp://redis-node-1:26379',
+ 'tcp://redis-node-2:26379',
+ 'tcp://redis-node-3:26379',
+ ],
+ 'options' => [
+ 'parameters' => [
+ 'password' => 'secret', // Or NULL
+ 'database' => 0,
+ 'persistent' => true,
+ 'async_connect' => true,
+ 'read_write_timeout' => 0.1,
+ ],
+ ],
+ ],
+ ]
+];
+```
+
+> Больше информации можно о конфигурации подключения и опциях можно получить в документации predis.
+
+Это обеспечивает базовый доступ к redis-хранилищу через компонент приложения `redis`:
+
+```php
+Yii::$app->redis->set('mykey', 'some value');
+echo Yii::$app->redis->get('mykey');
+```
+
+Дополнительно
+-----------------
+
+* [Использование компонента Cache с predis](topics-predis-cache.md)
+* [Использование компонента Session с predis](topics-predis-session.md)
+
diff --git a/docs/guide-ru/topics-cache.md b/docs/guide-ru/topics-cache.md
index 74dacb0ea..547d8613f 100644
--- a/docs/guide-ru/topics-cache.md
+++ b/docs/guide-ru/topics-cache.md
@@ -35,7 +35,7 @@ return [
```
Кэш предоставляет все методы [[yii\caching\CacheInterface]]. Если вы хотите получить доступ к определенным redis методам, которые не присутствуют
-в интерфейсе, вы можете использовать их через [[yii\redis\Cache::$redis]], который является экземпляром [[yii\redis\Connection]]:
+в интерфейсе, вы можете использовать их через [[yii\redis\Cache::$redis]], который является экземпляром [[yii\redis\ConnectionInterface]]:
```php
Yii::$app->cache->redis->hset('mykey', 'somefield', 'somevalue');
@@ -43,4 +43,4 @@ Yii::$app->cache->redis->hget('mykey', 'somefield');
...
```
-Смотри [[yii\redis\Connection]] для получения полного списка доступных методов.
\ No newline at end of file
+Смотри [[yii\redis\Connection]] для получения полного списка доступных методов.
diff --git a/docs/guide-ru/topics-predis-cache.md b/docs/guide-ru/topics-predis-cache.md
new file mode 100644
index 000000000..5b2477719
--- /dev/null
+++ b/docs/guide-ru/topics-predis-cache.md
@@ -0,0 +1,51 @@
+Использование компонента Cache вместе с predis
+=========================
+
+Чтобы использовать компонент `Cache`, в дополнение к настройке соединения, как описано в разделе [predis](predis.md), вам также нужно настроить компонент `cache` как [[yii\redis\Cache]]:
+
+```php
+return [
+ //....
+ 'components' => [
+ // ...
+ 'redis' => [
+ 'class' => 'yii\redis\predis\PredisConnection',
+ 'parameters' => 'tcp://redis:6379',
+ // ...
+ ],
+ 'cache' => [
+ 'class' => 'yii\redis\Cache',
+ ],
+ ]
+];
+```
+
+Если вы используете только кеш redis (т.е. не используете его ActiveRecord или Session), вы также можете настроить параметры соединения в пределах кеш-компонента (в этом случае необходимо настроить конфигурационный компонент подключения):
+
+```php
+return [
+ //....
+ 'components' => [
+ // ...
+ 'cache' => [
+ 'class' => 'yii\redis\Cache',
+ 'redis' => [
+ 'class' => 'yii\redis\predis\PredisConnection',
+ 'parameters' => 'tcp://redis:6379',
+ // ...
+ ],
+ ],
+ ]
+];
+```
+
+Кэш предоставляет все методы [[yii\caching\CacheInterface]]. Если вы хотите получить доступ к определенным redis методам, которые не присутствуют
+в интерфейсе, вы можете использовать их через [[yii\redis\Cache::$redis]], который является экземпляром [[yii\redis\ConnectionInterface]]:
+
+```php
+Yii::$app->cache->redis->hset('mykey', 'somefield', 'somevalue');
+Yii::$app->cache->redis->hget('mykey', 'somefield');
+...
+```
+
+Смотри [[yii\redis\predis\PredisConnection]] для получения полного списка доступных методов.
diff --git a/docs/guide-ru/topics-predis-session.md b/docs/guide-ru/topics-predis-session.md
new file mode 100644
index 000000000..f02d2e5db
--- /dev/null
+++ b/docs/guide-ru/topics-predis-session.md
@@ -0,0 +1,40 @@
+Использование компонента Session вместе с predis
+===========================
+
+Чтобы использовать компонент `Session`, в дополнение к настройке соединения, как описано в разделе [predis](predis.md), вам также нужно настроить компонент `session` как [[yii\redis\Session]]:
+
+```php
+return [
+ //....
+ 'components' => [
+ // ...
+ 'redis' => [
+ 'class' => 'yii\redis\predis\PredisConnection',
+ 'parameters' => 'tcp://redis:6379',
+ // ...
+ ],
+ 'session' => [
+ 'class' => 'yii\redis\Session',
+ ],
+ ]
+];
+```
+
+Если вы используете только redis сессии (т.е. не используете его ActiveRecord или Cache), вы также можете настроить параметры соединения в компоненте сеанса (в этом случае не нужно настраивать компонент приложения подключения):
+
+```php
+return [
+ //....
+ 'components' => [
+ // ...
+ 'session' => [
+ 'class' => 'yii\redis\Session',
+ 'redis' => [
+ 'class' => 'yii\redis\predis\PredisConnection',
+ 'parameters' => 'tcp://redis:6379',
+ // ...
+ ],
+ ],
+ ]
+];
+```
diff --git a/docs/guide-uz/README.md b/docs/guide-uz/README.md
index a2592bacc..048731aea 100644
--- a/docs/guide-uz/README.md
+++ b/docs/guide-uz/README.md
@@ -7,6 +7,7 @@ Ishni boshlash
---------------
* [O'rnatish](installation.md)
+* [predis qo'llab-quvvatlash](predis.md)
Foydalanish
-----
diff --git a/docs/guide-uz/predis.md b/docs/guide-uz/predis.md
new file mode 100644
index 000000000..060b50d22
--- /dev/null
+++ b/docs/guide-uz/predis.md
@@ -0,0 +1,70 @@
+Redis keshi, sessiya va ActiveRecord uchun Predis
+===============================================
+## Sozlash
+
+Kengaytmadan foydalanish uchun Yii2 sozlamalaridan `[[yii\redis\predis\PredisConnection]]` sinfini quyidagicha sozlashingiz kerak
+
+> Warning: Yii\redis\predis\PredisConnection klassi redis-klaster ulanishini qo‘llab-quvvatlaydi, lekin *kesh*, *sessiya*, *ActiveRecord*, *mutex* komponent interfeyslarini qo‘llab-quvvatlamaydi.
+
+### standalone
+```php
+return [
+ //....
+ 'components' => [
+ 'redis' => [
+ 'class' => 'yii\redis\predis\PredisConnection',
+ 'parameters' => 'tcp://redis:6379',
+ 'options' => [
+ 'parameters' => [
+ 'password' => 'secret', // Or NULL
+ 'database' => 0,
+ 'persistent' => true,
+ 'async_connect' => true,
+ 'read_write_timeout' => 0.1,
+ ],
+ ],
+ ],
+ ]
+];
+```
+### sentinel
+```php
+return [
+ //....
+ 'components' => [
+ 'redis' => [
+ 'class' => 'yii\redis\predis\PredisConnection',
+ 'parameters' => [
+ 'tcp://redis-node-1:26379',
+ 'tcp://redis-node-2:26379',
+ 'tcp://redis-node-3:26379',
+ ],
+ 'options' => [
+ 'parameters' => [
+ 'password' => 'secret', // Or NULL
+ 'database' => 0,
+ 'persistent' => true,
+ 'async_connect' => true,
+ 'read_write_timeout' => 0.1,
+ ],
+ ],
+ ],
+ ]
+];
+```
+
+> Ulanish konfiguratsiyasi va opsiyalari haqida batafsil ma’lumotni predis hujjatlarida topishingiz mumkin.
+
+Quyidagi kodlar orqali redis'ga ma'lumot kiritish va o'qishning eng oddiy holatini ko'rish mumkin
+
+```php
+Yii::$app->redis->set('mykey', 'some value');
+echo Yii::$app->redis->get('mykey');
+```
+
+Qo'shimcha
+-----------------
+
+* [Kesh komponentidan predis bilan foydalanish](topics-predis-cache.md)
+* [Session komponentidan predis bilan foydalanish](topics-predis-session.md)
+
diff --git a/docs/guide-uz/topics-cache.md b/docs/guide-uz/topics-cache.md
index f2b87c396..4e59738aa 100644
--- a/docs/guide-uz/topics-cache.md
+++ b/docs/guide-uz/topics-cache.md
@@ -39,7 +39,7 @@ return [
Kesh `[[yii\caching\CacheInterface]]` interfeysidagi barcha metodlardan foydalanish imkonini beradi.
Interfeysga kiritilmagan Redis maxsus metodlaridan foydalanmoqchi bo'lsangiz, [[yii\redis\Cache::$redis]] orqali foydalanishingiz mumkin,
-bu [[yii\redis\Connection]] holatidagi namuna:
+bu [[yii\redis\ConnectionInterface]] holatidagi namuna:
```php
Yii::$app->cache->redis->hset('mykey', 'somefield', 'somevalue');
diff --git a/docs/guide-uz/topics-predis-cache.md b/docs/guide-uz/topics-predis-cache.md
new file mode 100644
index 000000000..58128a2ce
--- /dev/null
+++ b/docs/guide-uz/topics-predis-cache.md
@@ -0,0 +1,55 @@
+Kesh komponentidan predis bilan foydalanish
+=========================
+
+Redis'dan keshda foydalanish uchun [predis](predis.md) bo'limida tavsiflanganidek sozlashdan tashqari,
+[[yii\redis\Cache]] sinfi ham sozlashingiz kerak:
+
+```php
+return [
+ //....
+ 'components' => [
+ // ...
+ 'redis' => [
+ 'class' => 'yii\redis\predis\PredisConnection',
+ 'parameters' => 'tcp://redis:6379',
+ // ...
+ ],
+ 'cache' => [
+ 'class' => 'yii\redis\Cache',
+ ],
+ ]
+];
+```
+
+Agar siz faqat redis keshidan foydalansangiz (ya'ni, ActiveRecord yoki Sessiya uchun foydalanmasangiz),
+kesh komponentini o'zida ulanish sozlamalarini ham kiritishingiz mumkin
+(bu holda [predis](predis.md) bo'limidagi sozlashni bajarish shart emas):
+
+```php
+return [
+ //....
+ 'components' => [
+ // ...
+ 'cache' => [
+ 'class' => 'yii\redis\Cache',
+ 'redis' => [
+ 'class' => 'yii\redis\predis\PredisConnection',
+ 'parameters' => 'tcp://redis:6379',
+ // ...
+ ],
+ ],
+ ]
+];
+```
+
+Kesh `[[yii\caching\CacheInterface]]` interfeysidagi barcha metodlardan foydalanish imkonini beradi.
+Interfeysga kiritilmagan Redis maxsus metodlaridan foydalanmoqchi bo'lsangiz, [[yii\redis\Cache::$redis]] orqali foydalanishingiz mumkin,
+bu [[yii\redis\ConnectionInterface]] holatidagi namuna:
+
+```php
+Yii::$app->cache->redis->hset('mykey', 'somefield', 'somevalue');
+Yii::$app->cache->redis->hget('mykey', 'somefield');
+...
+```
+
+Boshqa metodlarni ko'rish uchun `[[yii\redis\predis\PredisConnection]]` sinfiga qarang.
diff --git a/docs/guide-uz/topics-predis-session.md b/docs/guide-uz/topics-predis-session.md
new file mode 100644
index 000000000..695d14db0
--- /dev/null
+++ b/docs/guide-uz/topics-predis-session.md
@@ -0,0 +1,43 @@
+Session komponentidan predis bilan foydalanish
+===========================
+
+Redis'dan sessiyada foydalanish uchun [predis](predis.md) bo'limida tavsiflanganidek sozlashdan tashqari,
+[[yii\redis\Session]] sinfi ham sozlashingiz kerak:
+
+```php
+return [
+ //....
+ 'components' => [
+ // ...
+ 'redis' => [
+ 'class' => 'yii\redis\predis\PredisConnection',
+ 'parameters' => 'tcp://redis:6379',
+ // ...
+ ],
+ 'session' => [
+ 'class' => 'yii\redis\Session',
+ ],
+ ]
+];
+```
+
+Agar siz faqat redis sessiyaidan foydalansangiz (ya'ni, ActiveRecord yoki Kesh uchun foydalanmasangiz),
+sessiya komponentini o'zida ulanish sozlamalarini ham kiritishingiz mumkin
+(bu holda [predis](predis.md) bo'limidagi sozlashni bajarish shart emas):
+
+```php
+return [
+ //....
+ 'components' => [
+ // ...
+ 'session' => [
+ 'class' => 'yii\redis\Session',
+ 'redis' => [
+ 'class' => 'yii\redis\predis\PredisConnection',
+ 'parameters' => 'tcp://redis:6379',
+ // ...
+ ],
+ ],
+ ]
+];
+```
diff --git a/docs/guide-zh-CN/README.md b/docs/guide-zh-CN/README.md
index be87d1f74..cad6f9f83 100644
--- a/docs/guide-zh-CN/README.md
+++ b/docs/guide-zh-CN/README.md
@@ -10,6 +10,7 @@ Yii 2 Redis 缓存,会话和活动记录
---------------
* [安装](installation.md)
+* [支持“predis”](predis.md)
用法
-----
diff --git a/docs/guide-zh-CN/predis.md b/docs/guide-zh-CN/predis.md
new file mode 100644
index 000000000..12c1f29ae
--- /dev/null
+++ b/docs/guide-zh-CN/predis.md
@@ -0,0 +1,70 @@
+Redis Cache、Session 和 ActiveRecord 的“Predis”
+===============================================
+## 配置应用程序
+
+使用此扩展时,需要在你的应用程序配置中配置 [[yii\redis\predis\PredisConnection]] 类:
+
+> Warning: yii\redis\predis\PredisConnection 类支持 redis-cluster 连接,但是不提供对 *cache*、*session*、*ActiveRecord*、*mutex* 组件接口的支持。
+
+### standalone
+```php
+return [
+ //....
+ 'components' => [
+ 'redis' => [
+ 'class' => 'yii\redis\predis\PredisConnection',
+ 'parameters' => 'tcp://redis:6379',
+ 'options' => [
+ 'parameters' => [
+ 'password' => 'secret', // Or NULL
+ 'database' => 0,
+ 'persistent' => true,
+ 'async_connect' => true,
+ 'read_write_timeout' => 0.1,
+ ],
+ ],
+ ],
+ ]
+];
+```
+### sentinel
+```php
+return [
+ //....
+ 'components' => [
+ 'redis' => [
+ 'class' => 'yii\redis\predis\PredisConnection',
+ 'parameters' => [
+ 'tcp://redis-node-1:26379',
+ 'tcp://redis-node-2:26379',
+ 'tcp://redis-node-3:26379',
+ ],
+ 'options' => [
+ 'parameters' => [
+ 'password' => 'secret', // Or NULL
+ 'database' => 0,
+ 'persistent' => true,
+ 'async_connect' => true,
+ 'read_write_timeout' => 0.1,
+ ],
+ ],
+ ],
+ ]
+];
+```
+
+> 有关连接配置和选项的更多信息,请参阅 predis 文档。
+
+这通过“redis”应用程序组件提供了对redis存储的基本访问:
+
+```php
+Yii::$app->redis->set('mykey', 'some value');
+echo Yii::$app->redis->get('mykey');
+```
+
+附加主题
+-----------------
+
+* [使用 Predis 的 Cache 组件](topics-predis-cache.md)
+* [使用带有 predis 的 Session 组件](topics-predis-session.md)
+
diff --git a/docs/guide-zh-CN/topics-predis-cache.md b/docs/guide-zh-CN/topics-predis-cache.md
new file mode 100644
index 000000000..d5345aad4
--- /dev/null
+++ b/docs/guide-zh-CN/topics-predis-cache.md
@@ -0,0 +1,42 @@
+使用 Predis 的 Cache 组件
+=========================
+
+为了使用 `Cache` 组件,如 [predis](predis.md) 章节中所描述的,除了配置连接,
+你也需要配置 [[yii\redis\Cache]] 中的 `cache` 组件:
+
+```php
+return [
+ //....
+ 'components' => [
+ // ...
+ 'redis' => [
+ 'class' => 'yii\redis\predis\PredisConnection',
+ 'parameters' => 'tcp://redis:6379',
+ // ...
+ ],
+ 'cache' => [
+ 'class' => 'yii\redis\Cache',
+ ],
+ ]
+];
+```
+
+如果你只使用 redis 缓存(即,不使用它的活动记录或者会话),您还可以配置缓存组件内的
+连接参数(在这种情况下,不需要配置连接应用程序的组件):
+
+```php
+return [
+ //....
+ 'components' => [
+ // ...
+ 'cache' => [
+ 'class' => 'yii\redis\Cache',
+ 'redis' => [
+ 'class' => 'yii\redis\predis\PredisConnection',
+ 'parameters' => 'tcp://redis:6379',
+ // ...
+ ],
+ ],
+ ]
+];
+```
diff --git a/docs/guide-zh-CN/topics-predis-session.md b/docs/guide-zh-CN/topics-predis-session.md
new file mode 100644
index 000000000..d15bce17f
--- /dev/null
+++ b/docs/guide-zh-CN/topics-predis-session.md
@@ -0,0 +1,42 @@
+将 Session 组件与 predis 结合使用
+===========================
+
+为了使用 `Session` 组件,如 [predis](predis.md) 章节中所描述的,除了配置连接,
+你也需要配置 [[yii\redis\Session]] 中的 `session` 组件:
+
+```php
+return [
+ //....
+ 'components' => [
+ // ...
+ 'redis' => [
+ 'class' => 'yii\redis\predis\PredisConnection',
+ 'parameters' => 'tcp://redis:6379',
+ // ...
+ ],
+ 'session' => [
+ 'class' => 'yii\redis\Session',
+ ],
+ ]
+];
+```
+
+如果你只使用 redis 会话(即,不使用它的活动记录或者缓存),您还可以配置会话组件内的
+连接参数(在这种情况下,不需要配置连接应用程序的组件):
+
+```php
+return [
+ //....
+ 'components' => [
+ // ...
+ 'session' => [
+ 'class' => 'yii\redis\Session',
+ 'redis' => [
+ 'class' => 'yii\redis\predis\PredisConnection',
+ 'parameters' => 'tcp://redis:6379',
+ // ...
+ ],
+ ],
+ ]
+];
+```
diff --git a/docs/guide/README.md b/docs/guide/README.md
index 245b81dcd..31b3d517e 100644
--- a/docs/guide/README.md
+++ b/docs/guide/README.md
@@ -10,6 +10,7 @@ Getting Started
---------------
* [Installation](installation.md)
+* [predis support](predis.md)
Usage
-----
diff --git a/docs/guide/predis.md b/docs/guide/predis.md
new file mode 100644
index 000000000..e58f5a03f
--- /dev/null
+++ b/docs/guide/predis.md
@@ -0,0 +1,69 @@
+Predis for Redis Cache, Session, and ActiveRecord
+===============================================
+## Configuring application
+
+To use this extension, you have to configure the [[yii\redis\predis\PredisConnection]] class in your application configuration:
+
+> Warning: The yii\redis\predis\PredisConnection class supports redis-cluster connection, but does not provide support for the *cache*, *session*, *ActiveRecord*, *mutex* component interfaces.
+
+### standalone
+```php
+return [
+ //....
+ 'components' => [
+ 'redis' => [
+ 'class' => 'yii\redis\predis\PredisConnection',
+ 'parameters' => 'tcp://redis:6379',
+ 'options' => [
+ 'parameters' => [
+ 'password' => 'secret', // Or NULL
+ 'database' => 0,
+ 'persistent' => true,
+ 'async_connect' => true,
+ 'read_write_timeout' => 0.1,
+ ],
+ ],
+ ],
+ ]
+];
+```
+### sentinel
+```php
+return [
+ //....
+ 'components' => [
+ 'redis' => [
+ 'class' => 'yii\redis\predis\PredisConnection',
+ 'parameters' => [
+ 'tcp://redis-node-1:26379',
+ 'tcp://redis-node-2:26379',
+ 'tcp://redis-node-3:26379',
+ ],
+ 'options' => [
+ 'parameters' => [
+ 'password' => 'secret', // Or NULL
+ 'database' => 0,
+ 'persistent' => true,
+ 'async_connect' => true,
+ 'read_write_timeout' => 0.1,
+ ],
+ ],
+ ],
+ ]
+];
+```
+
+> More detailed information about the configuration and connection parameters can be found in the predis documentation.
+
+This provides the basic access to redis storage via the `redis` application component:
+
+```php
+Yii::$app->redis->set('mykey', 'some value');
+echo Yii::$app->redis->get('mykey');
+```
+
+Additional topics
+-----------------
+
+* [Using the Cache Component with Predis](topics-predis-cache.md)
+* [Using the Session Component with Predis](topics-predis-session.md)
diff --git a/docs/guide/topics-cache.md b/docs/guide/topics-cache.md
index c90610471..0aaa9569d 100644
--- a/docs/guide/topics-cache.md
+++ b/docs/guide/topics-cache.md
@@ -37,7 +37,7 @@ return [
```
The cache provides all methods of the [[yii\caching\CacheInterface]]. If you want to access redis specific methods that are not
-included in the interface, you can use them via [[yii\redis\Cache::$redis]], which is an instance of [[yii\redis\Connection]]:
+included in the interface, you can use them via [[yii\redis\Cache::$redis]], which is an instance of [[yii\redis\ConnectionInterface]]:
```php
Yii::$app->cache->redis->hset('mykey', 'somefield', 'somevalue');
diff --git a/docs/guide/topics-predis-cache.md b/docs/guide/topics-predis-cache.md
new file mode 100644
index 000000000..19a5a17e0
--- /dev/null
+++ b/docs/guide/topics-predis-cache.md
@@ -0,0 +1,53 @@
+Using the Cache component with predis
+=========================
+
+To use the `Cache` component, in addition to configuring the connection as described in the [predis](predis.md) section,
+you also have to configure the `cache` component to be [[yii\redis\Cache]]:
+
+```php
+return [
+ //....
+ 'components' => [
+ // ...
+ 'redis' => [
+ 'class' => 'yii\redis\predis\PredisConnection',
+ 'parameters' => 'tcp://redis:6379',
+ // ...
+ ],
+ 'cache' => [
+ 'class' => 'yii\redis\Cache',
+ ],
+ ]
+];
+```
+
+If you only use the redis cache (i.e., not using its ActiveRecord or Session), you can also configure the parameters of the connection within the
+cache component (no connection application component needs to be configured in this case):
+
+```php
+return [
+ //....
+ 'components' => [
+ // ...
+ 'cache' => [
+ 'class' => 'yii\redis\Cache',
+ 'redis' => [
+ 'class' => 'yii\redis\predis\PredisConnection',
+ 'parameters' => 'tcp://redis:6379',
+ // ...
+ ],
+ ],
+ ]
+];
+```
+
+The cache provides all methods of the [[yii\caching\CacheInterface]]. If you want to access redis specific methods that are not
+included in the interface, you can use them via [[yii\redis\Cache::$redis]], which is an instance of [[yii\redis\ConnectionInterface]]:
+
+```php
+Yii::$app->cache->redis->hset('mykey', 'somefield', 'somevalue');
+Yii::$app->cache->redis->hget('mykey', 'somefield');
+...
+```
+
+See [[yii\redis\predis\PredisConnection]] for a full list of available methods.
diff --git a/docs/guide/topics-predis-session.md b/docs/guide/topics-predis-session.md
new file mode 100644
index 000000000..ff39f8345
--- /dev/null
+++ b/docs/guide/topics-predis-session.md
@@ -0,0 +1,42 @@
+Using the Session component with predis
+===========================
+
+To use the `Session` component, in addition to configuring the connection as described in the [predis](predis.md) section,
+you also have to configure the `session` component to be [[yii\redis\Session]]:
+
+```php
+return [
+ //....
+ 'components' => [
+ // ...
+ 'redis' => [
+ 'class' => 'yii\redis\predis\PredisConnection',
+ 'parameters' => 'tcp://redis:6379',
+ // ...
+ ],
+ 'session' => [
+ 'class' => 'yii\redis\Session',
+ ],
+ ]
+];
+```
+
+If you only use redis session (i.e., not using its ActiveRecord or Cache), you can also configure the parameters of the connection within the
+session component (no connection application component needs to be configured in this case):
+
+```php
+return [
+ //....
+ 'components' => [
+ // ...
+ 'session' => [
+ 'class' => 'yii\redis\Session',
+ 'redis' => [
+ 'class' => 'yii\redis\predis\PredisConnection',
+ 'parameters' => 'tcp://redis:6379',
+ // ...
+ ],
+ ],
+ ]
+];
+```
diff --git a/phpunit.xml.dist b/phpunit.xml.dist
index 742d0b01b..b7fae8ff1 100644
--- a/phpunit.xml.dist
+++ b/phpunit.xml.dist
@@ -1,18 +1,22 @@
-
-
-
- ./tests
-
-
-
-
- src/
-
-
+
+
+
+ ./tests
+
+
+
+
+ src
+
+
diff --git a/src/Cache.php b/src/Cache.php
index d9a4ad791..003c0797d 100644
--- a/src/Cache.php
+++ b/src/Cache.php
@@ -7,7 +7,6 @@
namespace yii\redis;
-use Yii;
use yii\db\Exception;
use yii\di\Instance;
@@ -101,7 +100,7 @@
class Cache extends \yii\caching\Cache
{
/**
- * @var Connection|string|array the Redis [[Connection]] object or the application component ID of the Redis [[Connection]].
+ * @var ConnectionInterface|string|array the Redis [[Connection]] object or the application component ID of the Redis [[Connection]].
* This can also be an array that is used to create a redis [[Connection]] instance in case you do not want do configure
* redis connection as an application component.
* After the Cache object is created, if you want to change this property, you should only assign it
@@ -139,7 +138,7 @@ class Cache extends \yii\caching\Cache
* should be enabled, or false if it should be disabled.
* @since 2.0.11
*/
- public $forceClusterMode;
+ public $forceClusterMode = false;
/**
* @var bool whether redis [[Connection::$database|database]] is shared and can contain other data than cache.
* Setting this to `true` will change [[flush()]] behavior - instead of using [`FLUSHDB`](https://redis.io/commands/flushdb)
@@ -151,7 +150,7 @@ class Cache extends \yii\caching\Cache
public $shareDatabase = false;
/**
- * @var Connection currently active connection.
+ * @var ConnectionInterface currently active connection.
*/
private $_replica;
/**
@@ -172,7 +171,7 @@ class Cache extends \yii\caching\Cache
public function init()
{
parent::init();
- $this->redis = Instance::ensure($this->redis, Connection::className());
+ $this->redis = Instance::ensure($this->redis, ConnectionInterface::class);
}
/**
@@ -371,12 +370,13 @@ protected function flushValues()
* It will return the current Replica Redis [[Connection]], and fall back to default [[redis]] [[Connection]]
* defined in this instance. Only used in getValue() and getValues().
* @since 2.0.8
- * @return array|string|Connection
+ * @return array|string|ConnectionInterface
* @throws \yii\base\InvalidConfigException
*/
protected function getReplica()
{
- if ($this->enableReplicas === false) {
+ // @NOTE Predis uses its own implementation of balancing
+ if ($this->enableReplicas === false || $this->redis instanceof \yii\redis\Predis\PredisConnection) {
return $this->redis;
}
diff --git a/src/Connection.php b/src/Connection.php
index 3d35fd200..c334d4b0d 100644
--- a/src/Connection.php
+++ b/src/Connection.php
@@ -24,220 +24,6 @@
* When the server needs authentication, you can set the [[password]] property to
* authenticate with the server after connect.
*
- * The execution of [redis commands](https://redis.io/commands) is possible with via [[executeCommand()]].
- *
- * @method mixed append($key, $value) Append a value to a key.
- * @method mixed auth($password) Authenticate to the server.
- * @method mixed bgrewriteaof() Asynchronously rewrite the append-only file.
- * @method mixed bgsave() Asynchronously save the dataset to disk.
- * @method mixed bitcount($key, $start = null, $end = null) Count set bits in a string.
- * @method mixed bitfield($key, ...$operations) Perform arbitrary bitfield integer operations on strings.
- * @method mixed bitop($operation, $destkey, ...$keys) Perform bitwise operations between strings.
- * @method mixed bitpos($key, $bit, $start = null, $end = null) Find first bit set or clear in a string.
- * @method mixed blpop(...$keys, $timeout) Remove and get the first element in a list, or block until one is available.
- * @method mixed brpop(...$keys, $timeout) Remove and get the last element in a list, or block until one is available.
- * @method mixed brpoplpush($source, $destination, $timeout) Pop a value from a list, push it to another list and return it; or block until one is available.
- * @method mixed clientKill(...$filters) Kill the connection of a client.
- * @method mixed clientList() Get the list of client connections.
- * @method mixed clientGetname() Get the current connection name.
- * @method mixed clientPause($timeout) Stop processing commands from clients for some time.
- * @method mixed clientReply($option) Instruct the server whether to reply to commands.
- * @method mixed clientSetname($connectionName) Set the current connection name.
- * @method mixed clusterAddslots(...$slots) Assign new hash slots to receiving node.
- * @method mixed clusterCountkeysinslot($slot) Return the number of local keys in the specified hash slot.
- * @method mixed clusterDelslots(...$slots) Set hash slots as unbound in receiving node.
- * @method mixed clusterFailover($option = null) Forces a slave to perform a manual failover of its master..
- * @method mixed clusterForget($nodeId) Remove a node from the nodes table.
- * @method mixed clusterGetkeysinslot($slot, $count) Return local key names in the specified hash slot.
- * @method mixed clusterInfo() Provides info about Redis Cluster node state.
- * @method mixed clusterKeyslot($key) Returns the hash slot of the specified key.
- * @method mixed clusterMeet($ip, $port) Force a node cluster to handshake with another node.
- * @method mixed clusterNodes() Get Cluster config for the node.
- * @method mixed clusterReplicate($nodeId) Reconfigure a node as a slave of the specified master node.
- * @method mixed clusterReset($resetType = "SOFT") Reset a Redis Cluster node.
- * @method mixed clusterSaveconfig() Forces the node to save cluster state on disk.
- * @method mixed clusterSetslot($slot, $type, $nodeid = null) Bind a hash slot to a specific node.
- * @method mixed clusterSlaves($nodeId) List slave nodes of the specified master node.
- * @method mixed clusterSlots() Get array of Cluster slot to node mappings.
- * @method mixed command() Get array of Redis command details.
- * @method mixed commandCount() Get total number of Redis commands.
- * @method mixed commandGetkeys() Extract keys given a full Redis command.
- * @method mixed commandInfo(...$commandNames) Get array of specific Redis command details.
- * @method mixed configGet($parameter) Get the value of a configuration parameter.
- * @method mixed configRewrite() Rewrite the configuration file with the in memory configuration.
- * @method mixed configSet($parameter, $value) Set a configuration parameter to the given value.
- * @method mixed configResetstat() Reset the stats returned by INFO.
- * @method mixed dbsize() Return the number of keys in the selected database.
- * @method mixed debugObject($key) Get debugging information about a key.
- * @method mixed debugSegfault() Make the server crash.
- * @method mixed decr($key) Decrement the integer value of a key by one.
- * @method mixed decrby($key, $decrement) Decrement the integer value of a key by the given number.
- * @method mixed del(...$keys) Delete a key.
- * @method mixed discard() Discard all commands issued after MULTI.
- * @method mixed dump($key) Return a serialized version of the value stored at the specified key..
- * @method mixed echo($message) Echo the given string.
- * @method mixed eval($script, $numkeys, ...$keys, ...$args) Execute a Lua script server side.
- * @method mixed evalsha($sha1, $numkeys, ...$keys, ...$args) Execute a Lua script server side.
- * @method mixed exec() Execute all commands issued after MULTI.
- * @method mixed exists(...$keys) Determine if a key exists.
- * @method mixed expire($key, $seconds) Set a key's time to live in seconds.
- * @method mixed expireat($key, $timestamp) Set the expiration for a key as a UNIX timestamp.
- * @method mixed flushall($ASYNC = null) Remove all keys from all databases.
- * @method mixed flushdb($ASYNC = null) Remove all keys from the current database.
- * @method mixed geoadd($key, $longitude, $latitude, $member, ...$more) Add one or more geospatial items in the geospatial index represented using a sorted set.
- * @method mixed geohash($key, ...$members) Returns members of a geospatial index as standard geohash strings.
- * @method mixed geopos($key, ...$members) Returns longitude and latitude of members of a geospatial index.
- * @method mixed geodist($key, $member1, $member2, $unit = null) Returns the distance between two members of a geospatial index.
- * @method mixed georadius($key, $longitude, $latitude, $radius, $metric, ...$options) Query a sorted set representing a geospatial index to fetch members matching a given maximum distance from a point.
- * @method mixed georadiusbymember($key, $member, $radius, $metric, ...$options) Query a sorted set representing a geospatial index to fetch members matching a given maximum distance from a member.
- * @method mixed get($key) Get the value of a key.
- * @method mixed getbit($key, $offset) Returns the bit value at offset in the string value stored at key.
- * @method mixed getrange($key, $start, $end) Get a substring of the string stored at a key.
- * @method mixed getset($key, $value) Set the string value of a key and return its old value.
- * @method mixed hdel($key, ...$fields) Delete one or more hash fields.
- * @method mixed hexists($key, $field) Determine if a hash field exists.
- * @method mixed hget($key, $field) Get the value of a hash field.
- * @method mixed hgetall($key) Get all the fields and values in a hash.
- * @method mixed hincrby($key, $field, $increment) Increment the integer value of a hash field by the given number.
- * @method mixed hincrbyfloat($key, $field, $increment) Increment the float value of a hash field by the given amount.
- * @method mixed hkeys($key) Get all the fields in a hash.
- * @method mixed hlen($key) Get the number of fields in a hash.
- * @method mixed hmget($key, ...$fields) Get the values of all the given hash fields.
- * @method mixed hmset($key, $field, $value, ...$more) Set multiple hash fields to multiple values.
- * @method mixed hset($key, $field, $value) Set the string value of a hash field.
- * @method mixed hsetnx($key, $field, $value) Set the value of a hash field, only if the field does not exist.
- * @method mixed hstrlen($key, $field) Get the length of the value of a hash field.
- * @method mixed hvals($key) Get all the values in a hash.
- * @method mixed incr($key) Increment the integer value of a key by one.
- * @method mixed incrby($key, $increment) Increment the integer value of a key by the given amount.
- * @method mixed incrbyfloat($key, $increment) Increment the float value of a key by the given amount.
- * @method mixed info($section = null) Get information and statistics about the server.
- * @method mixed keys($pattern) Find all keys matching the given pattern.
- * @method mixed lastsave() Get the UNIX time stamp of the last successful save to disk.
- * @method mixed lindex($key, $index) Get an element from a list by its index.
- * @method mixed linsert($key, $where, $pivot, $value) Insert an element before or after another element in a list.
- * @method mixed llen($key) Get the length of a list.
- * @method mixed lpop($key) Remove and get the first element in a list.
- * @method mixed lpush($key, ...$values) Prepend one or multiple values to a list.
- * @method mixed lpushx($key, $value) Prepend a value to a list, only if the list exists.
- * @method mixed lrange($key, $start, $stop) Get a range of elements from a list.
- * @method mixed lrem($key, $count, $value) Remove elements from a list.
- * @method mixed lset($key, $index, $value) Set the value of an element in a list by its index.
- * @method mixed ltrim($key, $start, $stop) Trim a list to the specified range.
- * @method mixed mget(...$keys) Get the values of all the given keys.
- * @method mixed migrate($host, $port, $key, $destinationDb, $timeout, ...$options) Atomically transfer a key from a Redis instance to another one..
- * @method mixed monitor() Listen for all requests received by the server in real time.
- * @method mixed move($key, $db) Move a key to another database.
- * @method mixed mset(...$keyValuePairs) Set multiple keys to multiple values.
- * @method mixed msetnx(...$keyValuePairs) Set multiple keys to multiple values, only if none of the keys exist.
- * @method mixed multi() Mark the start of a transaction block.
- * @method mixed object($subcommand, ...$argumentss) Inspect the internals of Redis objects.
- * @method mixed persist($key) Remove the expiration from a key.
- * @method mixed pexpire($key, $milliseconds) Set a key's time to live in milliseconds.
- * @method mixed pexpireat($key, $millisecondsTimestamp) Set the expiration for a key as a UNIX timestamp specified in milliseconds.
- * @method mixed pfadd($key, ...$elements) Adds the specified elements to the specified HyperLogLog..
- * @method mixed pfcount(...$keys) Return the approximated cardinality of the set(s) observed by the HyperLogLog at key(s)..
- * @method mixed pfmerge($destkey, ...$sourcekeys) Merge N different HyperLogLogs into a single one..
- * @method mixed ping($message = null) Ping the server.
- * @method mixed psetex($key, $milliseconds, $value) Set the value and expiration in milliseconds of a key.
- * @method mixed psubscribe(...$patterns) Listen for messages published to channels matching the given patterns.
- * @method mixed pubsub($subcommand, ...$arguments) Inspect the state of the Pub/Sub subsystem.
- * @method mixed pttl($key) Get the time to live for a key in milliseconds.
- * @method mixed publish($channel, $message) Post a message to a channel.
- * @method mixed punsubscribe(...$patterns) Stop listening for messages posted to channels matching the given patterns.
- * @method mixed quit() Close the connection.
- * @method mixed randomkey() Return a random key from the keyspace.
- * @method mixed readonly() Enables read queries for a connection to a cluster slave node.
- * @method mixed readwrite() Disables read queries for a connection to a cluster slave node.
- * @method mixed rename($key, $newkey) Rename a key.
- * @method mixed renamenx($key, $newkey) Rename a key, only if the new key does not exist.
- * @method mixed restore($key, $ttl, $serializedValue, $REPLACE = null) Create a key using the provided serialized value, previously obtained using DUMP..
- * @method mixed role() Return the role of the instance in the context of replication.
- * @method mixed rpop($key) Remove and get the last element in a list.
- * @method mixed rpoplpush($source, $destination) Remove the last element in a list, prepend it to another list and return it.
- * @method mixed rpush($key, ...$values) Append one or multiple values to a list.
- * @method mixed rpushx($key, $value) Append a value to a list, only if the list exists.
- * @method mixed sadd($key, ...$members) Add one or more members to a set.
- * @method mixed save() Synchronously save the dataset to disk.
- * @method mixed scard($key) Get the number of members in a set.
- * @method mixed scriptDebug($option) Set the debug mode for executed scripts..
- * @method mixed scriptExists(...$sha1s) Check existence of scripts in the script cache..
- * @method mixed scriptFlush() Remove all the scripts from the script cache..
- * @method mixed scriptKill() Kill the script currently in execution..
- * @method mixed scriptLoad($script) Load the specified Lua script into the script cache..
- * @method mixed sdiff(...$keys) Subtract multiple sets.
- * @method mixed sdiffstore($destination, ...$keys) Subtract multiple sets and store the resulting set in a key.
- * @method mixed select($index) Change the selected database for the current connection.
- * @method mixed set($key, $value, ...$options) Set the string value of a key.
- * @method mixed setbit($key, $offset, $value) Sets or clears the bit at offset in the string value stored at key.
- * @method mixed setex($key, $seconds, $value) Set the value and expiration of a key.
- * @method mixed setnx($key, $value) Set the value of a key, only if the key does not exist.
- * @method mixed setrange($key, $offset, $value) Overwrite part of a string at key starting at the specified offset.
- * @method mixed shutdown($saveOption = null) Synchronously save the dataset to disk and then shut down the server.
- * @method mixed sinter(...$keys) Intersect multiple sets.
- * @method mixed sinterstore($destination, ...$keys) Intersect multiple sets and store the resulting set in a key.
- * @method mixed sismember($key, $member) Determine if a given value is a member of a set.
- * @method mixed slaveof($host, $port) Make the server a slave of another instance, or promote it as master.
- * @method mixed slowlog($subcommand, $argument = null) Manages the Redis slow queries log.
- * @method mixed smembers($key) Get all the members in a set.
- * @method mixed smove($source, $destination, $member) Move a member from one set to another.
- * @method mixed sort($key, ...$options) Sort the elements in a list, set or sorted set.
- * @method mixed spop($key, $count = null) Remove and return one or multiple random members from a set.
- * @method mixed srandmember($key, $count = null) Get one or multiple random members from a set.
- * @method mixed srem($key, ...$members) Remove one or more members from a set.
- * @method mixed strlen($key) Get the length of the value stored in a key.
- * @method mixed subscribe(...$channels) Listen for messages published to the given channels.
- * @method mixed sunion(...$keys) Add multiple sets.
- * @method mixed sunionstore($destination, ...$keys) Add multiple sets and store the resulting set in a key.
- * @method mixed swapdb($index, $index) Swaps two Redis databases.
- * @method mixed sync() Internal command used for replication.
- * @method mixed time() Return the current server time.
- * @method mixed touch(...$keys) Alters the last access time of a key(s). Returns the number of existing keys specified..
- * @method mixed ttl($key) Get the time to live for a key.
- * @method mixed type($key) Determine the type stored at key.
- * @method mixed unsubscribe(...$channels) Stop listening for messages posted to the given channels.
- * @method mixed unlink(...$keys) Delete a key asynchronously in another thread. Otherwise it is just as DEL, but non blocking..
- * @method mixed unwatch() Forget about all watched keys.
- * @method mixed wait($numslaves, $timeout) Wait for the synchronous replication of all the write commands sent in the context of the current connection.
- * @method mixed watch(...$keys) Watch the given keys to determine execution of the MULTI/EXEC block.
- * @method mixed xack($stream, $group, ...$ids) Removes one or multiple messages from the pending entries list (PEL) of a stream consumer group
- * @method mixed xadd($stream, $id, $field, $value, ...$fieldsValues) Appends the specified stream entry to the stream at the specified key
- * @method mixed xclaim($stream, $group, $consumer, $minIdleTimeMs, $id, ...$options) Changes the ownership of a pending message, so that the new owner is the consumer specified as the command argument
- * @method mixed xdel($stream, ...$ids) Removes the specified entries from a stream, and returns the number of entries deleted
- * @method mixed xgroup($subCommand, $stream, $group, ...$options) Manages the consumer groups associated with a stream data structure
- * @method mixed xinfo($subCommand, $stream, ...$options) Retrieves different information about the streams and associated consumer groups
- * @method mixed xlen($stream) Returns the number of entries inside a stream
- * @method mixed xpending($stream, $group, ...$options) Fetching data from a stream via a consumer group, and not acknowledging such data, has the effect of creating pending entries
- * @method mixed xrange($stream, $start, $end, ...$options) Returns the stream entries matching a given range of IDs
- * @method mixed xread(...$options) Read data from one or multiple streams, only returning entries with an ID greater than the last received ID reported by the caller
- * @method mixed xreadgroup($subCommand, $group, $consumer, ...$options) Special version of the XREAD command with support for consumer groups
- * @method mixed xrevrange($stream, $end, $start, ...$options) Exactly like XRANGE, but with the notable difference of returning the entries in reverse order, and also taking the start-end range in reverse order
- * @method mixed xtrim($stream, $strategy, ...$options) Trims the stream to a given number of items, evicting older items (items with lower IDs) if needed
- * @method mixed zadd($key, ...$options) Add one or more members to a sorted set, or update its score if it already exists.
- * @method mixed zcard($key) Get the number of members in a sorted set.
- * @method mixed zcount($key, $min, $max) Count the members in a sorted set with scores within the given values.
- * @method mixed zincrby($key, $increment, $member) Increment the score of a member in a sorted set.
- * @method mixed zinterstore($destination, $numkeys, $key, ...$options) Intersect multiple sorted sets and store the resulting sorted set in a new key.
- * @method mixed zlexcount($key, $min, $max) Count the number of members in a sorted set between a given lexicographical range.
- * @method mixed zrange($key, $start, $stop, $WITHSCORES = null) Return a range of members in a sorted set, by index.
- * @method mixed zrangebylex($key, $min, $max, $LIMIT = null, $offset = null, $count = null) Return a range of members in a sorted set, by lexicographical range.
- * @method mixed zrevrangebylex($key, $max, $min, $LIMIT = null, $offset = null, $count = null) Return a range of members in a sorted set, by lexicographical range, ordered from higher to lower strings..
- * @method mixed zrangebyscore($key, $min, $max, ...$options) Return a range of members in a sorted set, by score.
- * @method mixed zrank($key, $member) Determine the index of a member in a sorted set.
- * @method mixed zrem($key, ...$members) Remove one or more members from a sorted set.
- * @method mixed zremrangebylex($key, $min, $max) Remove all members in a sorted set between the given lexicographical range.
- * @method mixed zremrangebyrank($key, $start, $stop) Remove all members in a sorted set within the given indexes.
- * @method mixed zremrangebyscore($key, $min, $max) Remove all members in a sorted set within the given scores.
- * @method mixed zrevrange($key, $start, $stop, $WITHSCORES = null) Return a range of members in a sorted set, by index, with scores ordered from high to low.
- * @method mixed zrevrangebyscore($key, $max, $min, $WITHSCORES = null, $LIMIT = null, $offset = null, $count = null) Return a range of members in a sorted set, by score, with scores ordered from high to low.
- * @method mixed zrevrank($key, $member) Determine the index of a member in a sorted set, with scores ordered from high to low.
- * @method mixed zscore($key, $member) Get the score associated with the given member in a sorted set.
- * @method mixed zunionstore($destination, $numkeys, $key, ...$options) Add multiple sorted sets and store the resulting sorted set in a new key.
- * @method mixed scan($cursor, $MATCH = null, $pattern = null, $COUNT = null, $count = null) Incrementally iterate the keys space.
- * @method mixed sscan($key, $cursor, $MATCH = null, $pattern = null, $COUNT = null, $count = null) Incrementally iterate Set elements.
- * @method mixed hscan($key, $cursor, $MATCH = null, $pattern = null, $COUNT = null, $count = null) Incrementally iterate hash fields and associated values.
- * @method mixed zscan($key, $cursor, $MATCH = null, $pattern = null, $COUNT = null, $count = null) Incrementally iterate sorted sets elements and associated scores.
- *
* @property-read string $connectionString Socket connection string.
* @property-read string $driverName Name of the DB driver.
* @property-read bool $isActive Whether the DB connection is established.
@@ -247,7 +33,7 @@
* @author Carsten Brandt
* @since 2.0
*/
-class Connection extends Component
+class Connection extends Component implements ConnectionInterface
{
/**
* @event Event an event that is triggered after a DB connection is established
@@ -614,7 +400,7 @@ public function getSocket()
* Returns a value indicating whether the DB connection is established.
* @return bool whether the DB connection is established
*/
- public function getIsActive()
+ public function getIsActive(): bool
{
return ArrayHelper::getValue($this->_pool, $this->connectionString, false) !== false;
}
@@ -624,14 +410,14 @@ public function getIsActive()
* It does nothing if a DB connection has already been established.
* @throws Exception if connection fails
*/
- public function open()
+ public function open(): void
{
if ($this->socket !== false) {
return;
}
$connection = $this->connectionString . ', database=' . $this->database;
- \Yii::trace('Opening redis DB connection: ' . $connection, __METHOD__);
+ \Yii::debug('Opening redis DB connection: ' . $connection, __METHOD__);
$socket = @stream_socket_client(
$this->connectionString,
$errorNumber,
@@ -668,11 +454,11 @@ public function open()
* Closes the currently active DB connection.
* It does nothing if the connection is already closed.
*/
- public function close()
+ public function close(): void
{
foreach ($this->_pool as $socket) {
$connection = $this->connectionString . ', database=' . $this->database;
- \Yii::trace('Closing DB connection: ' . $connection, __METHOD__);
+ \Yii::debug('Closing DB connection: ' . $connection, __METHOD__);
try {
$this->executeCommand('QUIT');
} catch (SocketException $e) {
@@ -769,7 +555,7 @@ public function executeCommand($name, $params = [])
$command .= '$' . mb_strlen($arg ?? '', '8bit') . "\r\n" . $arg . "\r\n";
}
- \Yii::trace("Executing Redis Command: {$name}", __METHOD__);
+ \Yii::debug("Executing Redis Command: {$name}", __METHOD__);
if ($this->retries > 0) {
$tries = $this->retries;
while ($tries-- > 0) {
diff --git a/src/ConnectionInterface.php b/src/ConnectionInterface.php
new file mode 100644
index 000000000..4547d37aa
--- /dev/null
+++ b/src/ConnectionInterface.php
@@ -0,0 +1,234 @@
+
+ * @method mixed auth($password) Authenticate to the server.
+ * @method mixed bgrewriteaof() Asynchronously rewrite the append-only file.
+ * @method mixed bgsave() Asynchronously save the dataset to disk.
+ * @method mixed bitcount($key, $start = null, $end = null) Count set bits in a string.
+ * @method mixed bitfield($key, ...$operations) Perform arbitrary bitfield integer operations on strings.
+ * @method mixed bitop($operation, $destkey, ...$keys) Perform bitwise operations between strings.
+ * @method mixed bitpos($key, $bit, $start = null, $end = null) Find first bit set or clear in a string.
+ * @method mixed blpop(...$keys, $timeout) Remove and get the first element in a list, or block until one is available.
+ * @method mixed brpop(...$keys, $timeout) Remove and get the last element in a list, or block until one is available.
+ * @method mixed brpoplpush($source, $destination, $timeout) Pop a value from a list, push it to another list and return it; or block until one is available.
+ * @method mixed clientKill(...$filters) Kill the connection of a client.
+ * @method mixed clientList() Get the list of client connections.
+ * @method mixed clientGetname() Get the current connection name.
+ * @method mixed clientPause($timeout) Stop processing commands from clients for some time.
+ * @method mixed clientReply($option) Instruct the server whether to reply to commands.
+ * @method mixed clientSetname($connectionName) Set the current connection name.
+ * @method mixed clusterAddslots(...$slots) Assign new hash slots to receiving node.
+ * @method mixed clusterCountkeysinslot($slot) Return the number of local keys in the specified hash slot.
+ * @method mixed clusterDelslots(...$slots) Set hash slots as unbound in receiving node.
+ * @method mixed clusterFailover($option = null) Forces a slave to perform a manual failover of its master..
+ * @method mixed clusterForget($nodeId) Remove a node from the nodes table.
+ * @method mixed clusterGetkeysinslot($slot, $count) Return local key names in the specified hash slot.
+ * @method mixed clusterInfo() Provides info about Redis Cluster node state.
+ * @method mixed clusterKeyslot($key) Returns the hash slot of the specified key.
+ * @method mixed clusterMeet($ip, $port) Force a node cluster to handshake with another node.
+ * @method mixed clusterNodes() Get Cluster config for the node.
+ * @method mixed clusterReplicate($nodeId) Reconfigure a node as a slave of the specified master node.
+ * @method mixed clusterReset($resetType = "SOFT") Reset a Redis Cluster node.
+ * @method mixed clusterSaveconfig() Forces the node to save cluster state on disk.
+ * @method mixed clusterSetslot($slot, $type, $nodeid = null) Bind a hash slot to a specific node.
+ * @method mixed clusterSlaves($nodeId) List slave nodes of the specified master node.
+ * @method mixed clusterSlots() Get array of Cluster slot to node mappings.
+ * @method mixed command() Get array of Redis command details.
+ * @method mixed commandCount() Get total number of Redis commands.
+ * @method mixed commandGetkeys() Extract keys given a full Redis command.
+ * @method mixed commandInfo(...$commandNames) Get array of specific Redis command details.
+ * @method mixed configGet($parameter) Get the value of a configuration parameter.
+ * @method mixed configRewrite() Rewrite the configuration file with the in memory configuration.
+ * @method mixed configSet($parameter, $value) Set a configuration parameter to the given value.
+ * @method mixed configResetstat() Reset the stats returned by INFO.
+ * @method mixed dbsize() Return the number of keys in the selected database.
+ * @method mixed debugObject($key) Get debugging information about a key.