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
For a list of Redis commands, see [Redis Command Reference](http://redis.io/commands)
102
-
103
101
Minimal parsing is done on the replies. Commands that return a integer return
104
102
JavaScript Numbers, arrays return JavaScript Array. `HGETALL` returns an Object
105
103
keyed by the hash keys. All strings will either be returned as string or as
106
104
buffer depending on your setting. Please be aware that sending null, undefined
107
105
and Boolean values will result in the value coerced to a string!
108
106
109
-
# Redis Commands
110
-
111
-
This library is a 1 to 1 mapping to [Redis commands](https://redis.io/commands).
112
-
It is not a cache library so please refer to Redis commands page for full usage
113
-
details.
114
-
115
-
Example setting key to auto expire using [SET command](https://redis.io/commands/set)
116
-
117
-
```js
118
-
// this key will expire after 10 seconds
119
-
client.set("key", "value!", "EX", 10);
120
-
```
121
-
122
-
# API
107
+
## API
123
108
124
-
## Connection and other Events
109
+
###Connection and other Events
125
110
126
111
`client` will emit some events about the state of the connection to the Redis server.
127
112
128
-
### "ready"
113
+
####"ready"
129
114
130
115
`client` will emit `ready` once a connection is established. Commands issued
131
116
before the `ready` event are queued, then replayed just before this event is
132
117
emitted.
133
118
134
-
### "connect"
119
+
####"connect"
135
120
136
121
`client` will emit `connect` as soon as the stream is connected to the server.
137
122
138
-
### "reconnecting"
123
+
####"reconnecting"
139
124
140
125
`client` will emit `reconnecting` when trying to reconnect to the Redis server
141
126
after losing the connection. Listeners are passed an object containing `delay`
142
127
(in ms from the previous try) and `attempt` (the attempt #) attributes.
143
128
144
-
### "error"
129
+
####"error"
145
130
146
131
`client` will emit `error` when encountering an error connecting to the Redis
147
132
server or when any other in node_redis occurs. If you use a command without
@@ -150,16 +135,16 @@ listener.
150
135
151
136
So please attach the error listener to node_redis.
152
137
153
-
### "end"
138
+
####"end"
154
139
155
140
`client` will emit `end` when an established Redis server connection has closed.
156
141
157
-
### "warning"
142
+
####"warning"
158
143
159
144
`client` will emit `warning` when password was set but none is needed and if a
160
145
deprecated option / function / similar is used.
161
146
162
-
## redis.createClient()
147
+
###redis.createClient()
163
148
164
149
If you have `redis-server` running on the same machine as node, then the
165
150
defaults for port and host are probably fine and you don't need to supply any
@@ -201,9 +186,11 @@ using unix sockets if possible to increase throughput.
201
186
| prefix | null | A string used to prefix all used keys (e.g. `namespace:test`). Please be aware that the `keys` command will not be prefixed. The `keys` command has a "pattern" as argument and no key and it would be impossible to determine the existing keys in Redis if this would be prefixed. |
202
187
| retry_strategy | function | A function that receives an options object as parameter including the retry `attempt`, the `total_retry_time` indicating how much time passed since the last time connected, the `error` why the connection was lost and the number of `times_connected` in total. If you return a number from this function, the retry will happen exactly after that time in milliseconds. If you return a non-number, no further retry will happen and all offline commands are flushed with errors. Return an error to return that specific error to all offline commands. Example below. |
203
188
189
+
**`detect_buffers` example:**
190
+
204
191
```js
205
-
var redis =require("redis");
206
-
var client =redis.createClient({ detect_buffers:true });
0 commit comments