Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
df14e11
Added support for tests running against redis cluster (#1236)
vladvildanov Jul 24, 2023
a3311d6
2.2.1 version changes (#1349)
vladvildanov Aug 3, 2023
4172d22
Client set name and version on connection (#1347)
vladvildanov Aug 3, 2023
1b2fd52
Added support for Redis 7.0 arguments (#1359)
vladvildanov Aug 10, 2023
ffd31cf
Added missing redis-stack commands to KeyPrefix processor (#1358)
vladvildanov Aug 10, 2023
311cd2b
Added support for WAITAOF command (#1357)
vladvildanov Aug 14, 2023
f6cf2af
Updated CHANGELOG.md (#1363)
vladvildanov Aug 15, 2023
5f2b410
Update CHANGELOG.md (#1364)
tillkruss Aug 15, 2023
c5ee202
bump version (#1365)
tillkruss Aug 15, 2023
2d74db1
Changes related to Redis 7.2 image update (#1366)
vladvildanov Aug 16, 2023
912af82
Added support for CLUSTER container command (#1360)
vladvildanov Aug 17, 2023
16bdd83
Added EXPIRETIME command to KeyPrefixProcessor (#1369)
vladvildanov Aug 25, 2023
a9be327
Update Prefix.php
mmodler Jul 20, 2023
c6bf644
bump dev version
tillkruss Sep 13, 2023
cbf394b
Disable `CLIENT SETINFO` calls by default (#1399)
tillkruss Sep 13, 2023
b1d3255
tag v2.2.2
tillkruss Sep 13, 2023
d88153b
Add 7.2 to supported Redis versions (#1367)
uglide Sep 13, 2023
08d5298
fix typos
tillkruss Sep 13, 2023
92b2849
Fix `cmsincrby` method annotation in `ClientInterface` (#1333)
vjik Sep 13, 2023
4846e2a
back to dev version
tillkruss Sep 13, 2023
6372661
Make Relay work with Redis cluster (#1397)
dorrogeray Sep 13, 2023
577bd39
ClientInterface: using set with NX flag can return null (#1394)
glaubinix Sep 14, 2023
0ac4ae9
Merge branch 'predis:v2.x' into prefix-fix
mmodler Sep 18, 2023
d201140
Update Prefix.php - Re-added callable check, allow objects and closures
mmodler Sep 18, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .codespellrc
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ skip=./.git
check-hidden=
check-filenames=
builtin=clear,rare,informal,usage,code,names
ignore-words-list=master,masters,slave,slaves,whitelist,cas,exat,smove,SUGGET,sugget
ignore-words-list=master,masters,slave,slaves,whitelist,cas,exat,smove,SUGGET,sugget,ro
1 change: 1 addition & 0 deletions .coveralls.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
coverage_clover: build/logs/clover-*.xml
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ block_comment_end = */
[*.php]
max_line_length = 150

[*.{md,yml,yaml,neon}]
[*.{md,yml,yaml,neon,sh}]
indent_size = 2

[tests/**.php]
Expand Down
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
/examples export-ignore
/tests export-ignore
/.codespellrc export-ignore linguist-language=INI
/.coveralls.yml export-ignore
/.editorconfig export-ignore
/.gitattributes export-ignore
/.gitignore export-ignore
Expand Down
7 changes: 7 additions & 0 deletions .github/workflows/cluster/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
FROM redis/redis-stack-server:latest as rss

COPY create_cluster.sh /create_cluster.sh
RUN ls -R /opt/redis-stack
RUN chmod a+x /create_cluster.sh

ENTRYPOINT [ "/create_cluster.sh"]
47 changes: 47 additions & 0 deletions .github/workflows/cluster/create_cluster.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#! /bin/bash

mkdir -p /nodes
touch /nodes/nodemap
if [ -z ${START_PORT} ]; then
START_PORT=6372
fi
if [ -z ${END_PORT} ]; then
END_PORT=6377
fi
if [ ! -z "$3" ]; then
START_PORT=$2
START_PORT=$3
fi
echo "STARTING: ${START_PORT}"
echo "ENDING: ${END_PORT}"

for PORT in `seq ${START_PORT} ${END_PORT}`; do
mkdir -p /nodes/$PORT
if [[ -e /redis.conf ]]; then
cp /redis.conf /nodes/$PORT/redis.conf
else
touch /nodes/$PORT/redis.conf
fi
cat << EOF >> /nodes/$PORT/redis.conf
port ${PORT}
cluster-enabled yes
daemonize yes
logfile /redis.log
dir /nodes/$PORT
EOF

set -x
/opt/redis-stack/bin/redis-server /nodes/$PORT/redis.conf
sleep 1
if [ $? -ne 0 ]; then
echo "Redis failed to start, exiting."
continue
fi
echo 127.0.0.1:$PORT >> /nodes/nodemap
done
if [ -z "${REDIS_PASSWORD}" ]; then
echo yes | /opt/redis-stack/bin/redis-cli --cluster create `seq -f 127.0.0.1:%g ${START_PORT} ${END_PORT}` --cluster-replicas 1
else
echo yes | opt/redis-stack/bin/redis-cli -a ${REDIS_PASSWORD} --cluster create `seq -f 127.0.0.1:%g ${START_PORT} ${END_PORT}` --cluster-replicas 1
fi
tail -f /redis.log
17 changes: 17 additions & 0 deletions .github/workflows/cluster/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
version: "3.9"
services:
cluster:
container_name: redis-cluster
build:
context: .
dockerfile: Dockerfile
ports:
- "6372:6372"
- "6373:6373"
- "6374:6374"
- "6375:6375"
- "6376:6376"
- "6377:6378"
volumes:
- "./redis.conf:/redis.conf:ro"

8 changes: 8 additions & 0 deletions .github/workflows/cluster/redis.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Redis Cluster config file will be shared across all nodes.
# Do not change the following configurations that are already set:
# port, cluster-enabled, daemonize, logfile, dir
protected-mode no
loadmodule /opt/redis-stack/lib/redisearch.so
loadmodule /opt/redis-stack/lib/redistimeseries.so
loadmodule /opt/redis-stack/lib/rejson.so
loadmodule /opt/redis-stack/lib/redisbloom.so
54 changes: 53 additions & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,16 +65,68 @@ jobs:

- name: Run tests with coverage
if: ${{ matrix.php == '8.1' && matrix.redis == '7' }}
run: vendor/bin/phpunit --coverage-clover build/logs/clover.xml --coverage-filter ./src
run: vendor/bin/phpunit --coverage-clover build/logs/clover-default.xml --coverage-filter ./src

- name: Run tests using Relay
if: ${{ matrix.redis >= '6' }}
run: vendor/bin/phpunit -c phpunit.relay.xml

- name: Run tests using Relay with coverage
if: ${{ matrix.php == '8.1' && matrix.redis == '7' }}
run: vendor/bin/phpunit -c phpunit.relay.xml --coverage-clover build/logs/clover-relay.xml --coverage-filter ./src

- name: Send coverage to Coveralls
env:
COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }}
if: ${{ env.COVERALLS_REPO_TOKEN && matrix.php == '8.1' && matrix.redis == '7' }}
run: |
wget "https://github.com/php-coveralls/php-coveralls/releases/download/v2.5.3/php-coveralls.phar"
php ./php-coveralls.phar -v

predis-cluster:

name: PHP ${{ matrix.php }} (Redis Cluster latest)
runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
php:
- '7.2'
- '7.3'
- '7.4'
- '8.0'
- '8.1'
- '8.2'

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Run Redis cluster
uses: isbang/compose-action@v1.4.1
with:
compose-file: .github/workflows/cluster/docker-compose.yml

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: relay
coverage: ${{ (matrix.php == '8.1') && 'xdebug' || 'none' }}

- name: Install Composer dependencies
uses: ramsey/composer-install@v2
with:
dependency-versions: highest
composer-options: ${{ matrix.php == '8.0' && '--ignore-platform-reqs' || '' }}

- name: Run tests against cluster
run: |
sleep 5 # make sure that docker image is setup
vendor/bin/phpunit --group cluster

- name: Run tests against cluster using Relay
run: |
sleep 5 # make sure nodes are stable and fully joined
vendor/bin/phpunit -c phpunit.relay.xml --group cluster
22 changes: 22 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,27 @@
## Changelog

## v2.2.2 (2023-09-13)

### Added
- Added `client_info` client parameter
- Added support for `CLUSTER` container command

### Fixed
- Fixed `EXPIRETIME` not using `prefix`
- Disabled `CLIENT SETINFO` calls by default

## v2.2.1 (2023-08-15)

### Added
- Added support for `WAITAOF` command (#1357)
- Added support for `SHUTDOWN` command (#1359)
- Added support for `FUNCTION` command (#1332)
- Added support for new optional `PEXPIRE`, `PEXPIREAT` and `COMMAND`
- Added missing Redis Stack commands to `KeyPrefixProcessor` (#1358)

### Changed
- Set client name and version when establishing a connection (#1347)

## v2.2.0 (2023-06-14)

Predis v2.2.0 introduces official support for [Redis Stack](https://redis.io/docs/stack/) as well as a [Relay](https://github.com/cachewerk/relay) integration for substantially [faster read performance](https://github.com/predis/predis/wiki/Using-Relay).
Expand Down
4 changes: 2 additions & 2 deletions FAQ.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ but significantly reduces bytes sent over the network and Redis memory usage.

Without Relay, Predis will not serialize data and will never do that by default. The reason
behind this decision is that serialization is usually something that developers prefer to
customize depending on their needs and can not be easilygeneralized when using Redis because
customize depending on their needs and can not be easily generalized when using Redis because
of the many possible access patterns for your data. This does not mean that it is impossible
to have such a feature since you can leverage the extensibility of this library to define
your own serialization-aware commands. You can find more details about how to do that
Expand Down Expand Up @@ -90,7 +90,7 @@ Predis is fast enough when Redis is located on the same machine as PHP, more on
[PhpRedis](https://github.com/phpredis/phpredis) (and Relay) perform significantly better when
network I/O is involved, due to their ability to compress data by ~75%. Fewer bytes and received
sent over the network [means faster operations](https://akalongman.medium.com/phpredis-vs-predis-comparison-on-real-production-data-a819b48cbadb),
and potentially cost savings when network traffic isn't free (e.g. AWS Elasticache Inter-AZ transfer costs).
and potentially cost savings when network traffic isn't free (e.g. AWS ElastiCache Inter-AZ transfer costs).

## Predis is a pure-PHP implementation: it can not be fast enough! ##

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ More details about this project can be found on the [frequently asked questions]

## Main features ##

- Support for Redis from __3.0__ to __7.0__.
- Support for Redis from __3.0__ to __7.2__.
- Support for clustering using client-side sharding and pluggable keyspace distributors.
- Support for [redis-cluster](http://redis.io/topics/cluster-tutorial) (Redis >= 3.0).
- Support for master-slave replication setups and [redis-sentinel](http://redis.io/topics/sentinel).
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.2.0-RC1
2.2.3-dev
41 changes: 41 additions & 0 deletions examples/Commands/waitaof.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?php

/*
* This file is part of the Predis package.
*
* (c) 2009-2020 Daniele Alessandri
* (c) 2021-2023 Till Krüss
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

use Predis\Client;

require __DIR__ . '/../shared.php';

// Example of WAITAOF command usage:

// 1. Enable appendonly mode if it's not (command works only in appendonly mode)
$client = new Client($single_server);
$info = $client->info();
$enabled = false;

if ($info['Persistence']['aof_enabled'] === '0') {
$client->config('set', 'appendonly', 'yes');
$enabled = true;
}

// 2. Set key value pair
$response = $client->set('foo', 'bar');
echo "Key-value pair set status: {$response}\n";

// 3. Run WAITAOF command to make sure that all previous writes was fsynced
$response = $client->waitaof(1, 0, 0);

echo "Quantity of local instances that was fsynced - {$response[0]}, quantity of replicas - {$response[1]}";

// 4. Disable appendonly mode if it was enabled during script execution
if ($enabled) {
$client->config('set', 'appendonly', 'no');
}
6 changes: 6 additions & 0 deletions phpunit.relay.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,12 @@
<groups>
<exclude>
<group>relay-incompatible</group>
<group>relay-resp3</group>
<group>realm-webdis</group>
<group>realm-stack</group>
<group>ext-curl</group>
<group>ext-phpiredis</group>
<group>cluster</group>
</exclude>
</groups>

Expand All @@ -38,5 +40,9 @@
<const name="REDIS_SERVER_PORT" value="6379" />
<const name="REDIS_SERVER_DBNUM" value="0" />
<env name="USE_RELAY" value="true" />

<!-- Redis Cluster -->
<!-- Only master nodes endpoints included -->
<const name="REDIS_CLUSTER_ENDPOINTS" value="127.0.0.1:6372,127.0.0.1:6373,127.0.0.1:6374" />
</php>
</phpunit>
5 changes: 5 additions & 0 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
<group>ext-relay</group>
<group>ext-curl</group>
<group>ext-phpiredis</group>
<group>cluster</group>
<!-- <group>connected</group> -->
<!-- <group>disconnected</group> -->
<!-- <group>commands</group> -->
Expand All @@ -51,5 +52,9 @@
<const name="REDIS_SERVER_PORT" value="6379" />
<const name="REDIS_SERVER_DBNUM" value="0" />
<env name="USE_RELAY" value="false" />

<!-- Redis Cluster -->
<!-- Only master nodes endpoints included -->
<const name="REDIS_CLUSTER_ENDPOINTS" value="127.0.0.1:6372,127.0.0.1:6373,127.0.0.1:6374" />
</php>
</phpunit>
2 changes: 1 addition & 1 deletion src/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
*/
class Client implements ClientInterface, IteratorAggregate
{
public const VERSION = '2.2.0-RC1';
public const VERSION = '2.2.3-dev';

/** @var OptionsInterface */
private $options;
Expand Down
4 changes: 4 additions & 0 deletions src/ClientContextInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
use Predis\Command\Argument\TimeSeries\RangeArguments;
use Predis\Command\CommandInterface;
use Predis\Command\Redis\Container\ACL;
use Predis\Command\Redis\Container\CLUSTER;
use Predis\Command\Redis\Container\FunctionContainer;
use Predis\Command\Redis\Container\Json\JSONDEBUG;
use Predis\Command\Redis\Container\Search\FTCONFIG;
Expand Down Expand Up @@ -304,12 +305,14 @@
* @method $this exec()
* @method $this multi()
* @method $this unwatch()
* @method $this waitaof(int $numLocal, int $numReplicas, int $timeout)
* @method $this watch($key)
* @method $this eval($script, $numkeys, $keyOrArg1 = null, $keyOrArgN = null)
* @method $this eval_ro(string $script, array $keys, ...$argument)
* @method $this evalsha($script, $numkeys, $keyOrArg1 = null, $keyOrArgN = null)
* @method $this evalsha_ro(string $sha1, array $keys, ...$argument)
* @method $this script($subcommand, $argument = null)
* @method $this shutdown(bool $noSave = null, bool $now = false, bool $force = false, bool $abort = false)
* @method $this auth($password)
* @method $this echo($message)
* @method $this ping($message = null)
Expand Down Expand Up @@ -338,6 +341,7 @@
* @method $this geosearchstore(string $destination, string $source, FromInterface $from, ByInterface $by, ?string $sorting = null, int $count = -1, bool $any = false, bool $storeDist = false)
*
* Container commands
* @property CLUSTER $cluster
* @property FunctionContainer $function
* @property FTCONFIG $ftconfig
* @property FTCURSOR $ftcursor
Expand Down
Loading