Commit Graph

1031 Commits

Author SHA1 Message Date
Daniele Alessandri 2d53db7b9b Rework PR to use "goto" instead of a "while ... do" loop. 2014-07-07 10:50:17 +02:00
Gwilym Evans f05cb1b46d use a loop instead of recursion in CursorBasedIterator
servers with large sets of keys will cause memory and stack exhaustion if recursion is used
2014-06-26 12:56:00 +10:00
Daniele Alessandri 4db00173f3 Use stream_socket_recvfrom() in PhpiredisStreamConnection.
Similarly to the socket-ext based connection using phpiredis, in our
stream based PhpiredisStreamConnection class we should read data from
the stream using stream_socket_recvfrom() instead of fread() because
the latter could block until a timeout is reached when the read buffer
contains less data then the specified length.

IMPORTANT: stream_socket_recvfrom() bypasses stream wrappers which
means that TLS/SSL, as requested by PR #158, won't ever work with
this connection class as the function returns the original encrypted
bytes.

This commit fixes issue #180.
2014-06-23 14:31:02 +02:00
Daniele Alessandri a2265b12b3 Remove implementation of Predis\Command\RawCommand::__toString().
See #151 and message of commit 5c5dd40, forgot to apply the same
change to the Predis\Command\RawCommand class.
2014-06-12 11:57:54 +02:00
Daniele Alessandri 0cd56406fe Just rename a couple of local variables. 2014-06-10 10:56:33 +02:00
Daniele Alessandri e575c32cb4 Rename RedisCluster::askClusterNodes() to askSlotsMap().
This is more consistent with the actual purpose of this method and
more in-line with a possible future change in the underlying command
used to retrieve the slots map if redis-cluster will implement the
CLUSTER SLOTS command.
2014-06-10 10:36:17 +02:00
Daniele Alessandri 940326e5bd New command: ZREMRANGEBYLEX (Redis 2.8.9). 2014-06-09 15:35:28 +02:00
Daniele Alessandri ea32f74512 New command: ZRANGEBYLEX (Redis 2.8.9). 2014-06-09 15:26:17 +02:00
Daniele Alessandri 8dbac3dd73 New command: ZLEXCOUNT (Redis 2.8.9). 2014-06-09 15:17:36 +02:00
Daniele Alessandri 5a474c5a32 Rename alias used in Predis\Client for Predis\Transaction\MultiExec. 2014-06-03 18:56:48 +02:00
Daniele Alessandri 0148743a76 Fix parsing of the output of CLUSTER NODES to fetch slots map.
There was an error in presence of slaves in the cluster configuration,
see #165 for reference.
2014-06-03 16:24:27 +02:00
Daniele Alessandri 1fd113c570 Rename ComposableProtocolProcessor to CompositeProtocolProcessor. 2014-06-03 15:45:40 +02:00
Daniele Alessandri abd284c972 Complete reorganization of the Predis\Connection namespace.
* Renamed SingleConnectionInterface to NodeConnectionInterface since
  this name is better and makes even more sense in the context of
  cluster and replication scenarios.

* Moved specialized aggregate connections (the ones implementing both
  predis and redis cluster and master/slave replication) in a newly
  created Predis\Connection\Aggregate sub-namespace.

* Removed the "Connection" part from names of aggregate connection
  interfaces in the Predis\Connection\Aggregate sub-namespace.

* Changed "Composable" to "Composite" in the name of interfaces and
  classes that can use pluggable protocol processors.
2014-06-03 15:19:32 +02:00
Daniele Alessandri 2aa0b071fc New commands: PFADD, PFCOUNT, PFMERGE (Redis 2.8.9).
Many thanks to @rubensayshi for his initial commits on this in #163,
but I had to start from scratch for the master branch first.
2014-05-30 11:32:39 +02:00
Alexey Kupershtokh f784dfad84 Enable INCRBYFLOAT in cluster mode 2014-05-28 13:00:24 +02:00
Daniele Alessandri 5c5dd40527 Remove implementation of Predis\Command\Command::__toString().
Issue #151 pointed to a flaw in how command instances were converted
to strings: we were simply truncating their arguments when exceeding
a certain size as this was mostly intended for logging or debugging,
but this approach breaks strings containing multibyte characters so
we decided to drop this feature altogether for the sake of simplicity.

It is still possible to replicate the same (and eventually improved)
behavior externally by fetching ID and arguments of a command out of
a command instance using the public methods made available by the
Predis\Command\CommandInterface.
2014-03-25 15:32:20 +01:00
Daniele Alessandri a51ff2d6e5 Port #156 to the current master branch.
This fix the parsing of responses to INFO when the node is configured
to work with redis-sentinel.
2014-03-25 14:49:25 +01:00
Daniele Alessandri 451d28ee66 Let's set this in stone: next major version is going to be v1.0.0.
[ci skip]
2014-02-12 10:27:42 +01:00
Daniele Alessandri e23fd9bea8 Use redis-cluster rules for empty key tags for client-side sharding.
This commit represents a breaking change when the first occurrence of
"{}" is found in a key because it will produce a different hash than
previous versions of Predis, thus leading to a different partitioning.

If you really need to stick with the old behavior, you can subclass
Predis\Cluster\PredisStrategy and override extractKeyTag() using the
old implementation of this method and pass the strategy instance when
initializing the cluster connection via client options.
2014-02-11 19:06:47 +01:00
Daniele Alessandri 8fbe658ca8 Fix implementation for hash tags extraction from keys.
We now fully comply with the specifications defined by Redis.
2014-02-11 19:06:44 +01:00
Daniele Alessandri 26289f47ec Add support for key hash tags in redis-cluster (Redis 3.0.0b1).
Multi-keys operations are not allowed even when keys generate the same
hash but this will probably be supported in later betas of Redis which
means we will basically end up reusing the whole strategy used for
client-side sharding.

Ported from the v0.8 branch.
2014-02-11 15:44:37 +01:00
Daniele Alessandri e04c7d51b8 Explicitly return null value. 2013-12-22 16:19:05 +01:00
Daniele Alessandri da8a203a75 Remove useless return statement. 2013-12-22 16:19:04 +01:00
Daniele Alessandri 9a38d2caec Move @property-read tags for parameters and options to interfaces.
This actually makes sense since whatever the actual implementation is,
classes implementing these interfaces should provide at least those
properties that are actively used through the library.
2013-12-22 15:03:31 +01:00
Daniele Alessandri 6a577a0eb5 Apply more phpdoc fixes. 2013-12-22 15:00:51 +01:00
Daniele Alessandri a092f6d4da Fix phpdocs for fluent interfaces.
[ci skip]
2013-12-22 13:52:57 +01:00
Daniele Alessandri 3befbb3ac2 Make Pipeline::executeCommand() return $this for fluent interface. 2013-12-22 13:40:36 +01:00
Daniele Alessandri 8d8a618d0e Add @property-read tags to client options class.
[ci skip]
2013-12-22 13:28:22 +01:00
Daniele Alessandri 5e1ea94f4a Add @property-read tags to parameters class.
[ci skip]
2013-12-22 12:59:40 +01:00
Daniele Alessandri b9b899eaf0 Fix incorrect usage of instance method in static method.
We also added a test to check that the socket-based connection backend
throws an exception when unable to resolve hostnames.
2013-12-22 12:38:54 +01:00
Daniele Alessandri 5065541cc6 Remove erroneous duplication of INFO in Redis profiles.
This oversight didn't end up in a blatant bug only because the correct
handler definition for INFO replaced the old class in the profile.
2013-12-22 12:23:55 +01:00
Daniele Alessandri f5a7d8ece8 Add a note about missing break in switch statement.
[ci skip]
2013-12-22 12:20:59 +01:00
Daniele Alessandri 25cd43033f Fix some errors in phpdocs.
[ci skip]
2013-12-22 12:12:49 +01:00
Daniele Alessandri 90d8c684f0 Use a more dynamic variant for caching common status responses. 2013-12-22 11:01:54 +01:00
Daniele Alessandri 09f9133df7 Fix small oversight.
Bug was not severe since +QUEUED status responses were returned anyway
but they were not cached as expected. We added a test in the suite.

This fixes #142.
2013-12-22 10:53:32 +01:00
Daniele Alessandri bff7906f68 Apply minor CS fixes.
[ci skip]
2013-12-21 18:24:51 +01:00
Daniele Alessandri b73606de68 Replace remaining occurrences of "boolean" with "bool" in phpdocs.
[ci skip]
2013-12-21 12:48:43 +01:00
Daniele Alessandri c127d02e92 Remove leftover "use" directive.
[ci skip]
2013-12-21 12:46:22 +01:00
Daniele Alessandri 7ba465048f Do not throw exception when connection has been already established.
The base abstract connection class now returns a bool to indicate when
the actual connect() operation has been performed on the underlying
resource. This return value is not part of the interface so extending
classes can decide to not return any value.
2013-12-21 12:32:15 +01:00
Daniele Alessandri 5f81bfcde3 Improve handling of -MOVED and -ASK responses.
This change improves code reusing and simplifies the internals of
our redis-cluster connection backend.
2013-12-21 11:56:40 +01:00
Daniele Alessandri 2aa97e3e61 Apply fixes for consistency.
I know that importing classes and interfaces for the root namespace
using the "use" directive is weird and totally uncommon...
2013-12-21 11:26:09 +01:00
Daniele Alessandri 131a5a4ef9 Fix a few exceptions. 2013-12-21 11:08:29 +01:00
Daniele Alessandri 8916f9a9ee Fix a few exception messages. 2013-12-21 10:07:56 +01:00
Daniele Alessandri 7cf9cfc496 Update phpdocs.
[ci skip]
2013-12-19 11:20:27 +01:00
Daniele Alessandri fdf63bc03d Make Predis compatible with HHVM (at least 2.3.0).
Achieving compatibility actually required a few marginal changes:

  - HHVM still has some issues with re-entrant calls to __get(). The
    applied change is an hack simply because it is ugly, but it is not
    wrong and does not break the signature of the options interface.
  - Since we cannot rely on the PHP version to detect the availability
    of socket_import_stream(), we switched to function_exists(). As an
    added bonus, using function_exists() is twice faster.
  - In the test suite we removed an assertion for the message of an
    E_WARNING simply because HHVM emits a different message. Checking
    for the warning is actually enough in that context.

While the whole test suite passes on HHVM 2.3.0, please remember that
HHVM is still in development and things could break anytime especially
in some obscure corner cases.
2013-12-17 16:09:20 +01:00
Daniele Alessandri 02e43143d3 Run php-cs against codebase. 2013-12-17 12:53:36 +01:00
Daniele Alessandri 5529e33047 Rework classes and interfaces in Predis\Command\Processor namespace.
- Renamed `Predis\Command\Processor\CommandProcessorInterface`
  - Removed `Predis\Command\Processor\CommandProcessorChainInterface`
2013-12-17 10:57:43 +01:00
Daniele Alessandri 1125dc1bdd Apply minor change in command serialization. 2013-12-16 18:46:17 +01:00
Daniele Alessandri 0f34f41ccf Fix and reword some exception messages. 2013-12-16 15:13:18 +01:00
Daniele Alessandri 7e89719ceb Revert usage of "short" namespaces in use directives.
We started using partially-qualified names as an experiment but we are
reverting to using fully-qualified names + aliases in use directives.
2013-12-15 17:00:45 +01:00