You've already forked node-redis
mirror of
https://github.com/redis/node-redis.git
synced 2025-08-10 11:43:01 +03:00
Removed unnecessary indentations and added some js syntax highlighting
This commit is contained in:
17
README.md
17
README.md
@@ -93,23 +93,31 @@ All functions take either an `args` Array plus optional `callback` Function or
|
||||
a variable number of individual arguments followed by an optional callback.
|
||||
Here is an example of passing an array of arguments and a callback:
|
||||
|
||||
```js
|
||||
client.mset(["test keys 1", "test val 1", "test keys 2", "test val 2"], function (err, res) {});
|
||||
```
|
||||
|
||||
Here is that same call in the second style:
|
||||
|
||||
```js
|
||||
client.mset("test keys 1", "test val 1", "test keys 2", "test val 2", function (err, res) {});
|
||||
```
|
||||
|
||||
Note that in either form the `callback` is optional:
|
||||
|
||||
```js
|
||||
client.set("some key", "some val");
|
||||
client.set(["some other key", "some val"]);
|
||||
```
|
||||
|
||||
If the key is missing, reply will be null (probably):
|
||||
|
||||
```js
|
||||
client.get("missingkey", function(err, reply) {
|
||||
// reply is null when the key is missing
|
||||
console.log(reply);
|
||||
});
|
||||
```
|
||||
|
||||
For a list of Redis commands, see [Redis Command Reference](http://redis.io/commands)
|
||||
|
||||
@@ -305,23 +313,29 @@ with the responses using JavaScript syntax.
|
||||
|
||||
Example:
|
||||
|
||||
```js
|
||||
client.hmset("hosts", "mjr", "1", "another", "23", "home", "1234");
|
||||
client.hgetall("hosts", function (err, obj) {
|
||||
console.dir(obj);
|
||||
});
|
||||
```
|
||||
|
||||
Output:
|
||||
|
||||
```js
|
||||
{ mjr: '1', another: '23', home: '1234' }
|
||||
```
|
||||
|
||||
### client.hmset(hash, obj, [callback])
|
||||
|
||||
Multiple values in a hash can be set by supplying an object:
|
||||
|
||||
```js
|
||||
client.HMSET(key2, {
|
||||
"0123456789": "abcdefghij", // NOTE: key and value will be coerced to strings
|
||||
"some manner of key": "a type of value"
|
||||
});
|
||||
```
|
||||
|
||||
The properties and values of this Object will be set as keys and values in the Redis hash.
|
||||
|
||||
@@ -329,8 +343,9 @@ The properties and values of this Object will be set as keys and values in the R
|
||||
|
||||
Multiple values may also be set by supplying a list:
|
||||
|
||||
```js
|
||||
client.HMSET(key1, "0123456789", "abcdefghij", "some manner of key", "a type of value");
|
||||
|
||||
```
|
||||
|
||||
## Publish / Subscribe
|
||||
|
||||
|
Reference in New Issue
Block a user