https://github.com/shimohq/redis-scan
Scan redis keys with pattern and do something to them
https://github.com/shimohq/redis-scan
aliyun cluster redis scan
Last synced: 6 months ago
JSON representation
Scan redis keys with pattern and do something to them
- Host: GitHub
- URL: https://github.com/shimohq/redis-scan
- Owner: shimohq
- License: mit
- Created: 2017-09-21T02:43:34.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2017-09-28T01:56:42.000Z (about 8 years ago)
- Last Synced: 2025-02-15T07:47:15.322Z (8 months ago)
- Topics: aliyun, cluster, redis, scan
- Language: JavaScript
- Size: 19.5 KB
- Stars: 3
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# redis-scan
Scan redis keys with pattern and do something to them, Aliyun redis cluster is supported.## install
```
npm i shimo-redis-scan
```## usage
```javascript
const RedisScan = require('shimo-redis-scan')
const Ioredis = require('ioredis')// All keys is optional
const task = new RedisScan({
// pattern
pattern: 'key:*',
// redis client
redis: new Ioredis(),
// scan count per time
size: 1000,
// handler function which return promise
handler: function ({ key, index, stop, clusterIndex }) {
console.log('current index:', index)
if (index > 10000) {
stop()
}
},
// aliyun redis cluster
aliyun: false
})task.start().then(() => process.exit(0))
```## notes
1. You need to make your own catch-error logic
2. Your node.js version must support async function
3. Cluster mode is only enabled in Aliyun redis cluster## License
MIT