Browse Source

Removed unnecessary indentations and added some js syntax highlighting

greenkeeper-update-all
Jason Kim 10 years ago
parent
commit
b63863ed35
  1. 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. a variable number of individual arguments followed by an optional callback.
Here is an example of passing an array of arguments and a 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) {}); 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: 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) {}); 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: Note that in either form the `callback` is optional:
```js
client.set("some key", "some val"); client.set("some key", "some val");
client.set(["some other key", "some val"]); client.set(["some other key", "some val"]);
```
If the key is missing, reply will be null (probably): If the key is missing, reply will be null (probably):
```js
client.get("missingkey", function(err, reply) { client.get("missingkey", function(err, reply) {
// reply is null when the key is missing // reply is null when the key is missing
console.log(reply); console.log(reply);
}); });
```
For a list of Redis commands, see [Redis Command Reference](http://redis.io/commands) 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: Example:
```js
client.hmset("hosts", "mjr", "1", "another", "23", "home", "1234"); client.hmset("hosts", "mjr", "1", "another", "23", "home", "1234");
client.hgetall("hosts", function (err, obj) { client.hgetall("hosts", function (err, obj) {
console.dir(obj); console.dir(obj);
}); });
```
Output: Output:
```js
{ mjr: '1', another: '23', home: '1234' } { mjr: '1', another: '23', home: '1234' }
```
### client.hmset(hash, obj, [callback]) ### client.hmset(hash, obj, [callback])
Multiple values in a hash can be set by supplying an object: Multiple values in a hash can be set by supplying an object:
```js
client.HMSET(key2, { client.HMSET(key2, {
"0123456789": "abcdefghij", // NOTE: key and value will be coerced to strings "0123456789": "abcdefghij", // NOTE: key and value will be coerced to strings
"some manner of key": "a type of value" "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. 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: Multiple values may also be set by supplying a list:
```js
client.HMSET(key1, "0123456789", "abcdefghij", "some manner of key", "a type of value"); client.HMSET(key1, "0123456789", "abcdefghij", "some manner of key", "a type of value");
```
## Publish / Subscribe ## Publish / Subscribe

Loading…
Cancel
Save