mkorkmaz / redislabs-common
Common library for Redislabs Modules. Contains Interfaces, General Exceptions, Abstracts and Traits
Requires
- php: ^8.5
- ext-json: *
Requires (Dev)
- ext-redis: *
- codeception/codeception: ^5.3
- codeception/module-asserts: ^3.0
- predis/predis: ^2.0 || ^3.0
- squizlabs/php_codesniffer: ^4.0
Suggests
- ext-redis: If your application depends of redis extention.
- predis/predis: If your application depends on predis.
Provides
None
Conflicts
None
Replaces
None
README
Contains Interfaces, General Exceptions, Abstracts and Traits
PhpRedis Cluster
The PhpRedis adapter accepts Redis and RedisCluster. For cluster commands,
it supplies the first command argument as the routing key without removing it
from the command. JSON.DEBUG MEMORY uses the second argument; JSON.DEBUG HELP
and commands without arguments use an empty routing key to select one node.
Node commands are not broadcast to all masters.
Raw commands with other key positions (for example, EVAL) need the native
RedisCluster API with an explicit routing key. Multi-key commands must use keys
in the same hash slot. This change does not add Predis cluster routing.
Run the adapter regression tests without a server:
vendor/bin/phpunit --bootstrap vendor/autoload.php tests/RedisClusterTest.php
Release the cluster routing fix as 2.0.0 before releasing the corresponding
redislabs-rejson dependency update.
PHP 8.5 migration
PHP 8.5 or later in the 8.x series is required (^8.5). Development tools and
CI now target PHP 8.5. This is a breaking release; publish it as a new major
version. The common package must be released as 2.0.0 before the corresponding
rejson release.
Command properties now have native types: string $command, array $arguments,
and ?Closure $responseCallback. Custom command subclasses must use compatible
property types. Convert callable arrays or strings with Closure::fromCallable()
before assigning a response callback. Module client references are readonly;
create a new module instance to replace its connection.
The refactor uses PHP 8.5 property #[Override] checks, first-class callables in
property defaults, and clone($object, $properties) for debug command copies.
See the PHP 8.5 migration guide.
Standalone integration tests use REDIS_PORT (default 6379). Run them only
against a disposable Redis instance: the existing standalone suite uses FLUSHALL.
REDIS_PORT=16379 vendor/bin/codecept run unit
createWithPredis() now requires Predis\Client (including subclasses), because
it uses executeRaw(), which is not part of Predis\ClientInterface. For a custom
transport, implement Redislabs\Interfaces\RedisClientInterface and pass that
adapter to the module constructor.