Commit Graph

356 Commits

Author SHA1 Message Date
michael-grunder
b144743345 Rework the HMGET command to skip invalid keys
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
2013-09-05 15:08:30 -07:00
michael-grunder
18339ec05b If no valid keys are found when processing an HMGET command,
free up our command and keys pointer and simply return FALSE.

Addresses #379
2013-09-03 21:13:57 -07:00
michael-grunder
02bac74dc3 Initialize agg_op_len to zero 2013-09-01 13:24:48 -07:00
michael-grunder
5c4fe08b69 generic_z_command fixes
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
2013-09-01 09:33:20 -07:00
michael-grunder
6e0f0d786c Rework generic_z_command to build the command in linear time
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
2013-09-01 07:48:08 -07:00
michael-grunder
20a3ef42d8 Merge branch 'feature/mobli_ra_changes' into develop 2013-08-31 14:12:13 -07:00
michael-grunder
60e3ba781e Merge branch 'feature/new_set_args' into develop 2013-08-31 14:09:58 -07:00
michael-grunder
8e81c49b55 Performance increase for MGET
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.
2013-08-31 11:27:54 -07:00
michael-grunder
77b17e52ea Merge in MatMol's changes so we don't throw and then clear an
exception in the context of connect or pconnect

Addresses #361
2013-08-30 21:30:00 -07:00
michael-grunder
677c8df7c1 Merge remote-tracking branch 'matmol/dont_throw_exception_on_pconnect' into feature/matmol_connect_ex 2013-08-30 21:18:00 -07:00
michael-grunder
7207aae8aa Add SLOWLOG command
Add support for the various slowlog commands you can execute
in Redis, including:

SLOWLOG GET [len]
SLOWLOG RESET
SLOWLOG LIST
2013-08-27 21:26:51 -07:00
michael-grunder
d1eddc4b87 Incorporate reflection flags from euskadi31
References #344

Merge remote-tracking branch 'euskadi31/patch-1' into feature/reflection_flags
2013-08-23 11:07:53 -07:00
Marlies Heijkoop
68605de48c Allow weights array to be null in generic_z_command (zUnion/zInter)
This way we can pass an aggregate function without having to also pass a dummy array(1,1,1..) with weights.
2013-08-12 21:37:16 +02:00
michael-grunder
8443769dc3 Merge remote-tracking branch 'mobli/develop' into feature/mobli_ra_changes
Conflicts:
	redis_array.c
	redis_array_impl.c
	redis_array_impl.h
2013-08-11 11:29:29 -07:00
michael-grunder
711f053b9f Redis >= 2.6.12 extended set options
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
2013-08-02 23:31:27 -07:00
Mathieu Kooiman
7e4cdb47f4 Don't throw exceptions for (p)connect calls.
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.
2013-07-29 14:00:36 +02:00
michael-grunder
e47e18c4b2 Create an alias for echo, called sendEcho
Addresses #345
2013-06-24 11:56:38 -07:00
Axel Etcheverry
e74e98e0d7 Add ZEND_ACC_CTOR and ZEND_ACC_DTOR for Reflection 2013-06-24 15:59:29 +02:00
michael-grunder
e9d5e21980 Support for '-inf', 'inf', and '+inf' for WEIGHTS
Redis allows the use of these specialized numbers in the
WEIGHTS argument for things like ZUNIONSTORE AND ZINTERSTORE
2013-05-09 11:03:43 -07:00
michael-grunder
4080dd9d0b Fix comment format 2013-04-28 11:39:34 -07:00
michael-grunder
3e6d5b60d6 Cutting a release for 2.2.3. Added myself as a maintainer
in the header files
2013-04-28 11:09:58 -07:00
michael-grunder
578bdf08cd Merge branch 'hotfix/tsrmls_cc' into develop 2013-03-28 07:58:47 -07:00
michael-grunder
411100da9e Don't duplicate TSRMLS_CC 2013-03-28 07:56:54 -07:00
michael-grunder
e914485313 Merge branch 'hotfix/inspection_methods' into develop
Conflicts:
	php_redis.h
	redis.c
2013-03-27 11:21:02 -07:00
michael-grunder
ef792320e7 Introspection methods
This commit adds methods to get information about the state
of our phpredis object, such as what host/port we are connected
to, our timeout, etc...

The following methods have been added:

getHost()
getPort()
getDBNum()
getTimeout()
getReadTimeout()
isConnected()
getPersistentID()
getAuth()

In addition, there is a small memory leak fix when a persistent id
was specifically passed to connect() (it wasn't beeing freed).

Addresses issue #320
2013-03-27 10:21:18 -07:00
michael-grunder
25a1593d73 Merge branch 'develop' of github.com:nicolasff/phpredis into develop 2013-03-16 11:55:09 -07:00
michael-grunder
c39ecd52f3 Alias eval and evalsha 2013-03-16 11:48:51 -07:00
Emmanuel Merali
ec74ab98df Merge remote-tracking branch 'upstream/develop' into develop
Conflicts:
	library.c
	library.h
	redis.c
	redis_array.c
	redis_array_impl.c
	redis_array_impl.h
	redis_session.c
2013-02-25 00:54:48 +02:00
Emmanuel Merali
acd3245456 Added lazy_connect option to RedisArray
Added an option to let each RedisArray connection connect lazily to
their respective server. This is useful then working with a redis
cluster composed of many shards which are not necessarily in use all at
once.
2013-02-25 00:38:47 +02:00
Emmanuel Merali
4ae635fddf Merge remote-tracking branch 'upstream/master'
Conflicts:
	common.h
2013-02-24 23:41:12 +02:00
Emmanuel Merali
6d3c9990a5 Merged changes from @mobli
New select DB command to RedisArray - Added retry delay on reconnect

Added the possibility to delay each reconnection attempt, including a
random factor to prevent several or many concurrent connections from
trying to reconnect at the same time.
Added the select command to RedisArray to select a DB on every
connections in one instruction.
Also, fixed a compiler warning:
redis_array_impl.c:1115:15: warning: incompatible pointer types
assigning to 'zval **' (aka 'struct _zval_struct **') from 'zval
**(*)[2]' [-Wincompatible-pointer-types]

Conflicts:
	common.h
2013-02-22 09:35:22 -08:00
michael-grunder
e1234f1772 Merge branch 'feature/client-commands' into develop 2013-02-16 17:58:55 -08:00
michael-grunder
9a5196ed2e CLIENT Commands
This commit adds support for the CLIENT commands (list, getname,
setname, kill).

You can call them like so:

$redis->client('list');
$redis->client('getname');
$redis->client('setname', $name);
$redis->client('kill', $ip_port);

Solves issue #300
2013-02-16 17:57:32 -08:00
michael-grunder
31174e8e77 Just removed a debug line 2013-02-15 18:01:11 -08:00
michael-grunder
55dd05356d Merge remote-tracking branch 'kotas/opt-read-timeout'
Conflicts:
	library.c
2013-02-11 12:42:49 -08:00
michael-grunder
85ee61d19b Add prefix support to SUBSCRIBE/PSUBSCRIBE
Now the Redis::OPT_PREFIX will apply to subscribe/psubscribe
channels and will be applied before searching for messages.
2013-02-04 14:45:54 -08:00
michael-grunder
242a16d50a Merge branch 'srandmember_count'
Conflicts:
	tests/TestRedis.php
2013-02-04 13:22:29 -08:00
Emmanuel Merali
d4c7f64131 New select DB command to RedisArray - Added retry delay on reconnect
Added the possibility to delay each reconnection attempt, including a
random factor to prevent several or many concurrent connections from
trying to reconnect at the same time.
Added the select command to RedisArray to select a DB on every
connections in one instruction.
Also, fixed a compiler warning:
redis_array_impl.c:1115:15: warning: incompatible pointer types
assigning to 'zval **' (aka 'struct _zval_struct **') from 'zval
**(*)[2]' [-Wincompatible-pointer-types]
2013-01-29 11:47:36 +02:00
Emmanuel Merali
9ba000c54c Revert "Retry delay - selectDB on array"
This reverts commit 3fb643211e.
2013-01-29 11:40:06 +02:00
Emmanuel Merali
3fb643211e Retry delay - selectDB on array
Added the possibility to delay each reconnection attempt, including a
random factor to prevent several or many concurrent connections from
trying to reconnect at the same time.
Added the select command to RedisArray to select a DB on every
connections in one instruction.
2013-01-21 18:10:16 +02:00
michael-grunder
e1a5145ad2 Changed the way we build the HMSET command such that we don't
continue to destroy and reallocate the command buffer

Added a simply library routine to append to a command buffer
using a smart_str

Made the unit tests work even if you're not compiled with
igbinary

Addresses issue #287
2013-01-18 18:05:02 -08:00
michael-grunder
5cbe1cf6f9 Fix formatting issue, remove unneccisary variable 2012-10-25 14:49:29 -07:00
michael-grunder
51b96938bc SRANDMEMBER optional COUNT argument
Adds support for the new COUNT argument to SRANDMEMBER.  If called
without a count, we will still return a string response (with one
randome member from the set, or false on a failure/type error).

If the count argument is passed, we return instead an array up to
the number asked for, given how Redis will process this value.

http://redis.io/commands/srandmember
2012-10-25 14:19:04 -07:00
michael-grunder
70430fb4f1 Ignore OPT_PREFIX for a timeout argument
When arguments were passed in the form ($key1, $key2, ...) to BLPOP
or BRPOP with a prefix, the timeout value was also being prefixed
causing it to misbehave.

Now for these commands we ignore the prefix on our timeout argument

Fixes issue #158
2012-10-22 13:22:41 -07:00
kotas
3764a6cd80 add Redis::OPT_READ_TIMEOUT option for issue #70 2012-10-04 22:18:18 +09:00
Nicolas Favre-Felix
7dfac44c8f Add missing serializer in zInter args
Fixes GitHub issue #252
2012-09-21 18:05:15 +01:00
michael-grunder
b4735e578b Merge branch 'master' of github.com:nicolasff/phpredis 2012-09-10 08:25:52 -07:00
Nicolas Favre-Felix
5855cfc2ca Add clearLastError 2012-09-09 22:09:27 +01:00
michael-grunder
4c72cbc323 Support closures for SUBSCRIBE/PSUBSCRIBE
Change how we detect a callback such that we can use closures
in SUBSCRIBE/PSUBSCRIBE commands.
2012-09-09 14:05:33 -07:00
michael-grunder
d1b1216852 PSUBSCRIBE
Implemented PSUBSCRIBE/PUNSUBSCRIBE and changed the present
subscribe and unsubscribe functions into generic versions
that can handle both cases.
2012-09-09 08:13:44 -07:00