-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
28 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
'use strict'; | ||
|
||
var Redis = require('ioredis'); | ||
var redis = new Redis(); | ||
|
||
// ioredis supports all Redis commands: | ||
redis.set('foo', 'bar'); | ||
redis.get('foo', function (err, result) { | ||
if (err) { | ||
console.error(err); | ||
} else { | ||
console.log(result); | ||
} | ||
}); | ||
|
||
// Or using a promise if the last argument isn't a function | ||
redis.get('foo').then(function (result) { | ||
console.log(result); | ||
}); | ||
|
||
// Arguments to commands are flattened, so the following are the same: | ||
redis.sadd('set', 1, 3, 5, 7); | ||
redis.sadd('set', [1, 3, 5, 7]); | ||
|
||
// All arguments are passed directly to the redis server: | ||
redis.set('key', 100, 'EX', 10); |