diff options
author | Emmanuel Merali <emmanuel@mobli.com> | 2013-02-25 02:38:47 +0400 |
---|---|---|
committer | Emmanuel Merali <emmanuel@mobli.com> | 2013-02-25 02:38:47 +0400 |
commit | acd324545685e3368bd8d9c626e7e019d4cdeb79 (patch) | |
tree | f9bba2226073d4c8c6eb5c8014476e70786f8710 /redis.c | |
parent | 4ae635fddf7839c0e8282bcaa36bada2756eeacd (diff) |
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.
Diffstat (limited to 'redis.c')
-rw-r--r-- | redis.c | 9 |
1 files changed, 8 insertions, 1 deletions
@@ -377,6 +377,13 @@ PHPAPI int redis_sock_get(zval *id, RedisSock **redis_sock TSRMLS_DC, int no_thr } return -1; } + if ((*redis_sock)->lazy_connect) + { + (*redis_sock)->lazy_connect = 0; + if (redis_sock_server_open(*redis_sock, 1 TSRMLS_CC) < 0) { + return -1; + } + } return Z_LVAL_PP(socket); } @@ -603,7 +610,7 @@ PHPAPI int redis_connect(INTERNAL_FUNCTION_PARAMETERS, int persistent) { zend_clear_exception(TSRMLS_C); /* clear exception triggered by non-existent socket during connect(). */ } - redis_sock = redis_sock_create(host, host_len, port, timeout, persistent, persistent_id, retry_interval); + redis_sock = redis_sock_create(host, host_len, port, timeout, persistent, persistent_id, retry_interval, 0); if (redis_sock_server_open(redis_sock, 1 TSRMLS_CC) < 0) { redis_free_socket(redis_sock); |