Skip to content

Commit e6e48c2

Browse files
committed
Add keys() to README.
1 parent 9585852 commit e6e48c2

File tree

1 file changed

+29
-5
lines changed

1 file changed

+29
-5
lines changed

README.md

+29-5
Original file line numberDiff line numberDiff line change
@@ -79,13 +79,37 @@ redisCache.wrap(key, function (cb) {
7979
// The del() method accepts a single key or array of keys,
8080
// with or without a callback.
8181
redisCache.set('foo', 'bar', function () {
82-
redisCache.set('bar', 'baz', function() {
83-
redisCache.set('baz', 'foo', function() {
84-
redisCache.del('foo');
85-
redisCache.del(['bar', 'baz'], function() { });
82+
redisCache.set('bar', 'baz', function() {
83+
redisCache.set('baz', 'foo', function() {
84+
redisCache.del('foo');
85+
redisCache.del(['bar', 'baz'], function() { });
86+
});
8687
});
87-
});
8888
});
89+
90+
// The keys() method uses the Redis SCAN command and accepts
91+
// optional `pattern` and `options` arguments. The `pattern`
92+
// must be a Redis glob-style string and defaults to '*'. The
93+
// options argument must be an object and accepts a single
94+
// `scanCount` property, which determines the number of elements
95+
// returned internally per call to SCAN. The default `scanCount`
96+
// is 100.
97+
redisCache.set('foo', 'bar', function () {
98+
redisCache.set('far', 'boo', function () {
99+
redisCache.keys('fo*', function (err, arrayOfKeys) {
100+
// arrayOfKeys: ['foo']
101+
});
102+
103+
redisCache.keys(function (err, arrayOfKeys) {
104+
// arrayOfKeys: ['foo', 'far']
105+
});
106+
107+
redisCache.keys('fa*', { scanCount: 10 }, function (err, arrayOfKeys) {
108+
// arrayOfKeys: ['far']
109+
});
110+
});
111+
});
112+
89113
```
90114

91115
### Multi-store

0 commit comments

Comments
 (0)