Skip to content

Commit 7c24786

Browse files
committed
Merge branch 'master' into serializer
2 parents 8287e8d + 0267ad8 commit 7c24786

File tree

8 files changed

+268
-120
lines changed

8 files changed

+268
-120
lines changed

README.markdown

Lines changed: 49 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ phpize
2020
make && make install
2121
</pre>
2222

23-
You can generate a debian package for PHP5, accessible from Apache 2 by running `./mkdeb-apache2.sh`.
23+
You can generate a debian package for PHP5, accessible from Apache 2 by running `./mkdeb-apache2.sh` or with `dpkg-buildpackage` or `svn-buildpackage`.
2424

25-
This extension exports a single class, `Redis`.
25+
This extension exports a single class, `Redis` (and `RedisException` used in case of errors).
2626

2727
Install on OSX
2828
==============
@@ -43,10 +43,15 @@ Session handler (new)
4343
phpredis can be used to store PHP sessions. To do this, configure `session.save_handler` and `session.save_path` in your php.ini to tell phpredis where to store the sessions:
4444
<pre>
4545
session.save_handler = redis
46-
session.save_path = "tcp://host1:6379?weight=1, tcp://host2:6379?weight=2, tcp://host3:6379?weight=2"
46+
session.save_path = "tcp://host1:6379?weight=1, tcp://host2:6379?weight=2&timeout=2.5, tcp://host3:6379?weight=2"
4747
</pre>
4848

49-
`session.save_path` can have a simple `host:port` format too, but you need to provide the `tcp://` scheme if you want to use the weight parameter.
49+
`session.save_path` can have a simple `host:port` format too, but you need to provide the `tcp://` scheme if you want to use the parameters. The following parameters are available:
50+
51+
* weight (integer): the weight of a host is used in comparison with the others in order to customize the session distribution on several hosts. If host A has twice the weight of host B, it will get twice the amount of sessions. In the example, *host1* stores 20% of all the sessions (1/(1+2+2)) while *host2* and *host3* each store 40% (2/1+2+2). The target host is determined once and for all at the start of the session, and doesn't change. The default weight is 1.
52+
* timeout (float): the connection timeout to a redis host, expressed in seconds. If the host is unreachable in that amount of time, the session storage will be unavailable for the client. The default timeout is very high (86400 seconds).
53+
54+
Sessions have a lifetime expressed in seconds and stored in the INI variable "session.gc_maxlifetime". You can change it with [`ini_set()`](http://php.net/ini_set).
5055

5156
Error handling
5257
==============
@@ -63,7 +68,9 @@ Creates a Redis client
6368

6469
##### *Example*
6570

71+
<pre>
6672
$redis = new Redis();
73+
</pre>
6774

6875
## connect, open
6976
##### *Description*
@@ -82,10 +89,46 @@ Connects to a Redis instance.
8289

8390
##### *Example*
8491

92+
<pre>
8593
$redis->connect('127.0.0.1', 6379);
8694
$redis->connect('127.0.0.1'); // port 6379 by default
8795
$redis->connect('127.0.0.1', 6379, 2.5); // 2.5 sec timeout.
8896
$redis->connect('/tmp/redis.sock'); // unix domain socket.
97+
</pre>
98+
99+
## pconnect, popen
100+
##### *Description*
101+
102+
Connects to a Redis instance or reuse a connection already established with `pconnect`/`popen`.
103+
104+
The connection will not be closed on `close` or end of request until the php process ends.
105+
So be patient on to many open FD's (specially on redis server side) when using persistent
106+
connections on many servers connecting to one redis server.
107+
108+
Also more than one persistent connection can be made identified by either host + port + timeout
109+
or unix socket + timeout.
110+
111+
This feature is not available in threaded versions. `pconnect` and `popen` then working like their non
112+
persistent equivalents.
113+
114+
##### *Parameters*
115+
116+
*host*: string. can be a host, or the path to a unix domain socket
117+
*port*: int, optional
118+
*timeout*: float, value in seconds (optional, default is 0 meaning unlimited)
119+
120+
##### *Return Value*
121+
122+
*BOOL*: `TRUE` on success, `FALSE` on error.
123+
124+
##### *Example*
125+
126+
<pre>
127+
$redis->pconnect('127.0.0.1', 6379);
128+
$redis->pconnect('127.0.0.1'); // port 6379 by default - same connection like before.
129+
$redis->pconnect('127.0.0.1', 6379, 2.5); // 2.5 sec timeout and would be another connection then the two before.
130+
$redis->pconnect('/tmp/redis.sock'); // unix domain socket - would be another connection then the three before.
131+
</pre>
89132

90133

91134
## setOption
@@ -152,7 +195,9 @@ Get the value related to the specified key
152195

153196
##### *Examples*
154197

198+
<pre>
155199
$redis->get('key');
200+
</pre>
156201

157202
## set
158203
##### Description

common.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@ typedef struct {
145145
double timeout;
146146
int failed;
147147
int status;
148+
int persistent;
148149

149150
int serializer;
150151

0 commit comments

Comments
 (0)