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 brings the W32 compilation fixes done by @char101 up to date and
allows building of php_redis.dll with VC11 on Win32 (allows for a php5.5
version).
adjust the format string passed to redis_cmd_format_static() to
properly handle long int, in order to prevent integer overflows
resulting in negative expire times passed to redis.
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
Use the lengths for our optional parameters, as NULL will
come through as a non null zval pointer with a zero length
Properly return the length from the redis_cmd_sstr_init function
This commit changes how we build the Redis protocol string for
ZUNIONSTORE and ZINTERSTORE such that we avoid reallocating
memory for the command buffer for each new key or weight
This commit changes the way we construct the MGET command
such that we avoid allocating and reallocating the command
string pointer for every new key that is added.
This means that MGET performance scales in a linear way rather
than exponentially.
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
When Redis::(p)connect() is called on a newly created Redis instance that will always cause an exception to be thrown. The connect code will actually try and cancel the
exception but this is problematic when you are using tools like APM (pecl.php.net/apm) which hook into the exception handler: it will already have handled it. This change simply stops the connect from throwing exceptions for that situation.