You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+17-12Lines changed: 17 additions & 12 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -39,7 +39,7 @@ local rc = require("resty.redis.connector").new({
39
39
connect_timeout=50,
40
40
read_timeout=5000,
41
41
keepalive_timeout=30000,
42
-
42
+
43
43
host="127.0.0.1",
44
44
port=6379,
45
45
db=2,
@@ -53,7 +53,7 @@ local redis, err = rc:connect()
53
53
localok, err=rc:set_keepalive(redis)
54
54
```
55
55
56
-
`connect` can be used to override defaults given in `new`
56
+
[connect](#connect) can be used to override some defaults given in [new](#new), which are pertinent to this connection only.
57
57
58
58
59
59
```lua
@@ -71,7 +71,9 @@ local redis, err = rc:connect({
71
71
72
72
## DSN format
73
73
74
-
If the `params.url` field is present then it will be parsed, overriding values supplied in the parameters table.
74
+
If the `params.url` field is present then it will be parsed to set the other params. Any manually specified params will override values given in the DSN.
75
+
76
+
*Note: this is a behaviour change as of v0.06. Previously, the DSN values would take precedence.*
75
77
76
78
### Direct Redis connections
77
79
@@ -87,11 +89,7 @@ When connecting via Redis Sentinel, the format is as follows:
87
89
88
90
`sentinel://PASSWORD@MASTER_NAME:ROLE/DB`
89
91
90
-
Again, `PASSWORD` and `DB` are optional. `ROLE` must be any of `m`, `s` or `a`, meaning:
91
-
92
-
*`m`: master
93
-
*`s`: slave
94
-
*`a`: any (first tries the master, but will failover to a slave if required)
92
+
Again, `PASSWORD` and `DB` are optional. `ROLE` must be either `m` or `s` for master / slave respectively.
95
93
96
94
A table of `sentinels` must also be supplied. e.g.
97
95
@@ -106,11 +104,11 @@ local redis, err = rc:connect{
106
104
107
105
## Proxy Mode
108
106
109
-
Enable the `connection_is_proxied` parameter if connecting to Redis through a proxy service (e.g. Twemproxy).
110
-
These proxies generally only support a limited sub-set of Redis commands, those which do not require state and do not affect multiple keys.
107
+
Enable the `connection_is_proxied` parameter if connecting to Redis through a proxy service (e.g. Twemproxy).
108
+
These proxies generally only support a limited sub-set of Redis commands, those which do not require state and do not affect multiple keys.
111
109
Databases and transactions are also not supported.
112
110
113
-
Proxy mode will disable switching to a DB on connect.
111
+
Proxy mode will disable switching to a DB on connect.
114
112
Unsupported commands (defaults to those not supported by Twemproxy) will return `nil, err` immediately rather than being sent to the proxy, which can result in dropped connections.
115
113
116
114
`discard` will not be sent when adding connections to the keepalive pool
@@ -138,7 +136,7 @@ If configured as a table of commands, the command methods will be replaced by a
138
136
db=0,
139
137
140
138
master_name="mymaster",
141
-
role="master", -- master | slave | any
139
+
role="master", -- master | slave
142
140
sentinels= {},
143
141
144
142
connection_is_proxied=false,
@@ -174,6 +172,13 @@ Creates the Redis Connector object, overring default params with the ones given.
174
172
175
173
Attempts to create a connection, according to the [params](#parameters) supplied, falling back to defaults given in `new` or the predefined defaults. If a connection cannot be made, returns `nil` and a string describing the reason.
176
174
175
+
Note that `params` given here do not change the connector's own configuration, and are only used to alter this particular connection operation. As such, the following parameters have no meaning when given in `connect`.
0 commit comments