543 Commits

Author SHA1 Message Date
Nicolas Favre-Felix e1a65fda48 Merge pull request #156 from Breathless/master
.deb related fixes
2.2.0
2012-04-03 01:46:47 -07:00
BreathLess 42e2c340a5 Correct debian package filename.
Unified php5/conf.d support.
2012-04-02 16:32:45 +04:00
Nicolas Favre-Felix 199d5e696f Fix issue with interned igbinary strings.
Possibly related to ticket #145.
2012-03-15 00:05:17 +00:00
Nicolas Favre-Felix ae147cfaed Add missing checks for sessions in igbinary.c
Tentative fix for #137.
2012-03-12 07:34:10 +00:00
Nicolas Favre-Felix 32e8d4143c More fixes for PHP 5.4 2012-03-12 07:05:30 +00:00
Nicolas Favre-Felix 9577b82bc3 Add conditional on include of php_session.h
Fix for GitHub issue #137.
2012-03-11 23:56:08 +00:00
Nicolas Favre-Felix f8c8ab24c3 Fix compilation issue with PHP 5.4
zend_list_insert now takes an extra TSRMLS_CC.
Resolves GitHub issue #144.
2012-03-11 16:17:59 +00:00
Nicolas Favre-Felix 4cf7677d05 Make sure stream exists when checking for EOF.
Addressing issue #143.
2012-03-11 13:40:16 +00:00
Nicolas Favre-Felix c18dcca608 Merge pull request #141 from rjack/patch-1
README: fix rPop
2012-03-06 02:27:49 -08:00
Giacomo Ritucci 29eca3fdef README: fix rPop 2012-03-06 11:23:32 +01:00
Nicolas Favre-Felix 8ebb811294 Fix for issue #134 (missing port for sessions).
The port is set to 6379 if not specified.
2012-02-27 13:47:19 +00:00
Nicolas Favre-Felix a5e53f1bbc Fixed compilation issues with Clang.
(GitHub issue #116).
2012-01-30 21:13:06 +00:00
Nicolas Favre-Felix 5d8839f15e Fixed small leak with info().
Thanks to @kotas for reporting and @chobie for fixing.
This closes GitHub issue #125.
2012-01-30 20:43:09 +00:00
Nicolas Favre-Felix 43571d1a43 Added mGet as an alias to GetMultiple in doc.
Fixes GitHub issue #123.
2012-01-30 19:45:19 +00:00
Nicolas Favre-Felix edf8aee8fd Fixed missing parameter in ZTS maintainer mode.
Fixes GitHub issue #128 (Thanks @sztanpet!)
2012-01-30 19:40:13 +00:00
Nicolas Favre-Felix ac11fab300 Merge branch 'imvu-master' 2012-01-02 16:07:11 +00:00
Nicolas Favre-Felix 61746ac9be Fixed typo 2012-01-02 16:06:57 +00:00
Nicolas Favre-Felix 99387710de Merge branch 'master' of https://github.com/imvu/phpredis into imvu-master 2012-01-02 16:03:53 +00:00
Nicolas Favre-Felix 1a1a81bf62 Fixed issue with HDEL in serialize mode.
Addresses GitHub issue #114. Fixed unit test as well.
2011-12-30 13:50:39 +00:00
Nicolas Favre-Felix 45f41a4bd3 Make Redis Array tests work on 32-bit.
The custom key distribution function was returning negative
ring offsets. This fix makes sure we always return positive or zero.
2011-12-29 17:16:40 +00:00
Nicolas Favre-Felix b15e78ba62 Merge branch 'edlerd-master' 2011-12-29 15:21:20 +00:00
Nicolas Favre-Felix 8edc96e8db Added documentation for CONFIG. 2011-12-29 15:21:00 +00:00
Nicolas Favre-Felix 5509b54903 Small changes to CONFIG contribution.
Code cleanup, removed serialize and key prefix, added extra checks.
Now returning an associative array on GET, bool on SET.
2011-12-29 15:16:19 +00:00
Nicolas Favre-Felix 8f341001ba Merge branch 'master' into edlerd-master 2011-12-29 14:17:42 +00:00
Nicolas Favre-Felix 87dfaf4212 Properly parse new-style info blocks. 2011-12-29 14:16:47 +00:00
David Edler ccc824a779 add config function 2011-12-29 14:40:12 +01:00
Nicolas Favre-Felix c6672f0a96 Fixed weight type issue in ZUNION.
(Fixes GitHub issue #109).
2011-12-26 18:01:51 +00:00
Emmanuel Merali 07bb4d6a08 Performance improvements for expire on rehash
Improves the performance of rehashing either with auto-rehash or with
the _rehash method by pipelining the call to TYPE and TTL and using
SETEX instead of SET and EXPIRE for string keys.
2011-12-25 17:19:16 +02:00
Eric Hohenstein 39df0b7a2c fixing issue with re-connect logic
There was an issue with the re-connect logic such that it would sometimes only partially apply a transaction. The redis_check_eof() function in library.c was automatically and invisibly re-connecting to the redis server when php_stream_eof() returned non-zero. If this happened to happen after a transaction had been partially stored, the server was rolling back the transaction but the phpredis library was continuing as if it was still applying the transaction so the remaining commands were being applied immediately. The result was that the portion of the transaction after the re-connect was applied (although not atomically) but the portion before the reconnect was thrown away by the server.

This change causes the phpredis library to fail (by throwing a RedisException) instead of reconnecting if the client session is in multi mode or it is watching any keys. Either of these conditions indicate that the server has lost the state of the session and the client needs to rebuild it. Because transactions can fail due to watched keys having been changed, clients that use transactions should already be coded to handle transaction failures using retry logic. With this change, clients that use transactions when talking to redis servers that use connection timeout, they will have to add a try...catch within the transaction retry loop to handle this type of failure. Clients that do not use transactions and clients that use transactions with redis servers that do not use connection timeout will be unaffected.

Perhaps not coincidentally, this change also fixes a well known but previously not well understood bug that causes RedisExceptions to be thrown with a message like  "protocol error, got '*' as reply type byte". My company began integrating redis into our service that handles 500,000 daily active users in April of this year. Prior to this fix, when we had our redis server connection timeout set to 5 seconds we would get hundreds of those error messages showing up in our php error logs per day. This wasn't a huge problem but it was concerning enough to raise the connection timeout to 30 seconds which reduced the rate of the errors but didn't eliminate them. At one point we had a process that was failing repeatedly with this error with a 30 second timeout so we had to raise the timeout all the way up to 300 seconds. A long timeout is not idea for a high throughput website like ours since it can cause failures to cascade from one system to another due to resource limits and requests holding on to connections for a long time. After introducing this fix roughly a month ago we have not had a single instance of RedisException show up in our php error logs (except for legitimate errors related to the server being down) even after lowering the server timeout back down to 5 seconds.

To reproduce the problem without this fix, set the redis server timeout configuration to 3 seconds and use the following test php script:

<?php

define('MAX_FAILURES', 1);

function get_redis() {
    $r = new Redis();
    $r->connect('localhost');
    return $r;
}

$r = get_redis();

$r->set('foo', '123');
$r->set('bar', 'abc');

if (isset($_GET['trans']) && $_GET['trans']) {
    $completed = false;
    $failures = 0;
    while (!$completed && ($failures < MAX_FAILURES)) {
        try {
            $trans = $r->multi();
            $trans->set('foo', $_GET['foo']);
            if (isset($_GET['sleep']) && $_GET['sleep']) {
                sleep($_GET['sleep']);
            }
            $trans->set('bar', $_GET['bar']);
            var_export($trans->exec());
            echo '<br/>';
            $completed = true;
        } catch (RedisException $e) {
            echo 'transaction failed<br/>';
            $failures++;
            $r = get_redis();
        }
    }
} else {
    $r->set('foo', $_GET['foo']);
    if (isset($_GET['sleep']) && $_GET['sleep']) {
        sleep($_GET['sleep']);
    }
    $r->set('bar', $_GET['bar']);
}

echo $r->get('foo');
echo '<br/>';
echo $r->get('bar');

?>

****************************
*** Results without this fix
****************************

foo=bar&bar=baz&trans=0&sleep=0
bar
baz

foo=bar&bar=baz&trans=1&sleep=0
array ( 0 => true, 1 => true, )
bar
baz

foo=bar&bar=baz&trans=0&sleep=30
bar
baz

foo=bar&bar=baz&trans=1&sleep=30
NULL
123
baz

Notice in this last example the call to exec() did not return anything and the value of the key 'bar' was modified by the transaction but the value of the key 'foo' was not even though the calls to set() on both keys were made between a call to multi() and a call to exec().

*************************
*** Results with this fix
*************************

foo=bar&bar=baz&trans=0&sleep=0
bar
baz

foo=bar&bar=baz&trans=1&sleep=0
array ( 0 => true, 1 => true, )
bar
baz

foo=bar&bar=baz&trans=0&sleep=30
bar
baz

foo=bar&bar=baz&trans=1&sleep=30
transaction failed
123
abc

Notice in the last example where the transaction failed message is printed, it is necessary to explicitly reconnect to the redis server. Trying to reuse the same redis object after it has failed to reconnect will result in a segmentation fault. I believe this was an existing problem with the phpredis library and it is not addressed by this change.
2011-12-22 12:26:36 -08:00
Emmanuel Merali c7f5eebad7 Added key expiry on rehash
Added a call to expire when migrating a key that has an TTL other than
-1
2011-12-22 17:37:26 +02:00
Nicolas Favre-Felix 31663d433f Make sure to avoid overflows on 32-bits. 2011-12-19 23:11:13 +00:00
Nicolas Favre-Felix 04bcecde74 Added missing parameter. 2011-12-19 22:54:53 +00:00
Nicolas Favre-Felix 53e61a1e53 Merge branch 'iFullgaz-master' 2011-12-13 21:37:29 +00:00
Nicolas Favre-Felix 70371fa39d s/_specified/_instance 2011-12-13 21:37:19 +00:00
Nicolas Favre-Felix 72a0ea6590 Merge branch 'master' of https://github.com/iFullgaz/phpredis into iFullgaz-master 2011-12-13 21:32:44 +00:00
Nicolas Favre-Felix d0d00341ff Make sure publish() can be called in a pipeline.
This will also make it possible to use publish()
in a MULTI/EXEC context. Fixes GitHub issue #104.
2011-12-13 19:54:13 +00:00
Emmanuel Merali 5bc6a4c842 Added retrieval of specific instance form Array
Added the possibility to retrieve a specific Redis instance from the
array. For instance:
$r = $ra->_specified($ra->_target($key));
2011-12-12 19:05:59 +02:00
Nicolas Favre-Felix 78f0abf3ec Fixed crash on ZREM with missing parameter.
generic_multiple_args_cmd() checked for missing
parameters but was missing a return FAILURE when
the number of parameters was lower than expected.

A unit test was added. This fixes GiHub issue #102.
2011-12-11 22:32:57 +00:00
Nicolas Favre-Felix b5be148e00 Merge branch 'master' of https://github.com/zhangjiayin/phpredis into zhangjiayin-master 2011-12-11 22:21:07 +00:00
Nicolas Favre-Felix a3016a95b1 Merge branch 'iFullgaz-master' 2011-12-11 22:16:59 +00:00
Nicolas Favre-Felix 67c6417a7a Added unit test for key distribution function. 2011-12-11 22:16:30 +00:00
Nicolas Favre-Felix 8f5783cb4c Reordered arguments to ra_index_multi(). 2011-12-11 22:15:58 +00:00
Nicolas Favre-Felix 09527a6b2d Merge branch 'master' of https://github.com/iFullgaz/phpredis into iFullgaz-master 2011-12-11 22:03:17 +00:00
Emmanuel Merali 2f58629e0c External key distributor
Added possibility to specify a user land key distributor function.
2011-12-11 19:19:24 +02:00
Emmanuel Merali 497300afda Fixed move zset
Checked for values type to take into account numeric values
2011-12-11 11:23:47 +02:00
Nicolas Favre-Felix dc4bc40ce5 Merge pull request #96 from joedevon/master
Added ZSCE instruction
2011-12-08 10:37:53 -08:00
Emmanuel Merali f0a2dc0ec3 Renamed crc32 to rcrc32
The function crc32 was not being called so I renamed it to make sure
that it's being called
2011-12-08 13:42:54 +02:00
Emmanuel Merali b408f7aa06 Allow use of pipeline in RedisArray 2011-12-08 01:52:21 +02:00
joedevon e5141478df Added instruction in case of fail on Zend Server CE 2011-12-07 09:52:34 -08:00
yanli dd42be6a87 change exception message 2011-12-07 15:36:13 +08:00