This probably isn't a very common scenerio since we've never had someone
ask it in a decade, but it was very simple to get them working.
Primarily we just needed to test for `STDTOUT`/`STDERR` and use
`__DIR__` instead of `$_SERVER['PHP_SELF']`.
Fixes#2507
* Switch remaining old-style PHP 5.4 `Array(...)` declarations to `[...]`
* Update variable names getting rid hungarian notation prefixes (e.g.
`str_`, `i_`, etc).
* Allow cluster seeds to be passed on the command-line instead of soley
relying on either a node environment variable or our
tests/nodes/nodemap file. This should make it easier to run ad-hoc
cluster tests by specifying just a single seed.
* Add some diagnostics for when we can't find a suitable cluster to run
our tests against indicating exactly where we looked for the env var
and node file.
* Refactor RedisArray tests to use our newer TestSuite assertions.
* Allow `RedisArray` ports to be specified on the command-line as well.
* Various formatting fixes.
* More robust KeyDB detection.
Add a mechanism that allows users to specify an arbitrary class name, in
combination with a search path so that PhpRedis unit tests can be run
against a different client.
Additionally, this commit allows multiple classes to be invoked in one
test execution either by passing multiple `--class` arguments, or a
class argument with a comma separated value.
Add support for Redis 6 ACLs in the `Redis`, `RedisCluster`, and `RedisArray` classes.
On a related note, it adds a mechanism for users to customize how we generate persistent connection IDs such that they can be grouped in different ways depending on the specific use case required (e.g. it would allow connections to be grouped by username, or by user-defined persistent_id, or both).
Right now cloning the repo and running unit tests will all fail if the
Redis/RedisCluster instances aren't configured with the password
'phpredis'.
This commit simply makes authentication during the tests optional via a
command-line argument.
* Added a test specifically for RedisCluster to test slave failover
settings.
* Added an option to specifically disable colorization, as well as
a mechanism to determine if the output is being piped, such that
we can turn colorization off in that case as well.
* Updated the unit test suite to print each unit test method name we're
running as we do so, and also with fancy colors :-)
* Added functionality to handle failed transactions, where Redis will send
us a multi bulk length of -1. This can happen because of an EXECABORT
error, or because a watched key was modified during the transaction
* Initialize serialized return value to NULL to avoid segfault
* use strtol not atoi in our long response handler, to handle large values
* Fixed our return value in multi responses
* Fiexed type() command as cluster doesn't still have the '+' prefix when
checking for what TYPE returns
* Exists should return a BOOLEAN not 1/0
* Fixed sRandMember to work in the context of a MULTI block
* Use "LINDEX" not "LGET" as "LGET" isn't a valid Redis command
* Properly set our slot for the PFCOUNT command
* Many unit test changes such that Redis and RedisCluster are happy using
mostly the same ones.
* Properly handle single array as well as variadic arguments for
things like RedisCluster::del
* Wrapping keys in {} such that Redis and RedisCluster tests can
use the same methods (avoiding CROSSSLOT).
* Fixed a double-free scenerio in redis_array_impl.c
This commit reworks the unit tests such that all three classes
(Redis, RedisArray, and RedisCluster) can be tested using the
TestRedis.php script.
Now, when running TestRedis.php an option can be passed for which
part of phpredis we would like to test (defaults to Redis).
When first creating the pfCount function, I simply allowed for one
string value for the key. Either Redis changed since then, or I
just missed it initially, but the PFCOUNT command can take one or
more keys.
This change doesn't break the API (in case anyone is using it under
develop now) as it can still take a single string argument, or can
take an array.
As discovered in issue #523, phpredis was attempting to unserialize
both the keys *and* scores for commands like zRangeByScore. This
had to do with the logic around deserialization in the response.
In addition, this same bug would have caused issues when running
commands like $r->config('get'), because that too, would have tried
to unserialize the values, which we don't want to do.
This commit reworks parsing and zipping up replies by allowing the
call to be configured to unseraialize any combination of keys or
values (or none or both).
This commit adds the command ZRANGEBYLEX to phpredis, which was
introduced in 2.8.9. Like with most commands, phpredis will do
some simple validation on the client side, to avoid sending
calls which are not correct (e.g. min/max that aren't valid
for the call, etc).
Addresses #498 and #465
This is the initial commit of the HyperLogLog probabilistic counting
command introduced in Redis.
Support for the following commands is implemented
* PFADD <key> <member1> <member2> ... <memberN>
* PFCOUNT <key>
* PFMERGE <dstkey> <srckey1> <srckey2> ... <srckeyN>
This commit adds a utility method as a counterpart to the _unserialize
utility method, allowing users to manually serialize data themselves
before sending it to Redis. This could be useful for calls going through
EVAL, as phpredis can't automatically serialize/unserialize in that case.
Addresses #431
This commit implements the Redis PUBSUB command, a new command
available since Redis 2.8.0 and described here:
http://redis.io/commands/pubsub
Addresses #427
This commit introduces support for the Redis SCAN, HSCAN, SSCAN,
and ZSCAN commands.
In the case of HSCAN, SSCAN, and ZSCAN, we take a key and iterator
as required arguments, and for SCAN just an iterator. Matching
the Redis commands, each variant can optionally take a pattern
to match against and a count value which hints at Redis how many
keys to return at a time.
When scanning keys or members (especially with a large keyspace when
searching for a pattern), Redis will sometimes return an empty result
of keys/members. PHPRedis can be set up to abstract this from the
caller by setting:
$redis->setOption(Redis::OPT_SCAN, Redis::SCAN_RETRY);
Which instructs PHPRedis to keep retrying the scan until members are
returned OR the iteration completes (Redis returns to us a zero iterator).
By default this option is set to Redis::SCAN_NORETRY, meaning that
empty results are possible, requiring an explicit check for FALSE in the
scanning loop, like so:
```php
$it = NULL;
while(($arr_keys = $redis->scan($it, "*pattern*"))!==FALSE) {
print_r($arr_keys);
}
```
This commit implements the new WAIT command which currently lives
in redis unstable, along with a unit test.
Also added myself to the README.markdown file, as well as a link to
"the twitter".
This relates to a previous hotfix for issue #379 where phpredis
would time out if you sent an array of empty values. The reason
it was timing out is that the argument count being sent wasn't
reflecting any skipped items in the array (meaning redis was
waiting for the rest of the command).
I realized that the previous fix would still fail if you were to
send some valid values, with invalid (null, empty string, etc)
ones mixed in.
Presently, we're just skipping invalid items in the array but there
might be a case to issue a php_error_docref type warning when we
encounter them, so the user can know that it happened.
In addition, HMGET now uses a smart_str to build the command, which
means the time it takes to build the key will scale in a linear fashion
When using the TTL command, Redis >= 2.8 will return -1 for a key
with no TTL and -2 for a key that doesn't exist. This fixes the
unit tests so they don't expect this in versions < 2.8.
Implement the new SET options as per the redis documentation:
http://redis.io/commands/set
You can now pass the new options (ex=>sec, px=>milisec, xx, nx) as
an array of options to the SET command and phpredis will handle them.
If you pass key, value, <long> phpredis will still redirect to SETEX
as it did before (to avoid breaking implementations).
Addresses #364