Skip to content
This repository was archived by the owner on Aug 7, 2024. It is now read-only.

Commit fa4ee3f

Browse files
authored
Merge pull request #3 from change/chris/updates
Update Node.js version, dependencies, code style
2 parents 83cb5d5 + dfb5ada commit fa4ee3f

File tree

9 files changed

+3317
-320
lines changed

9 files changed

+3317
-320
lines changed

.circleci/config.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
version: 2
2+
jobs:
3+
4+
build:
5+
working_directory: ~/change/redis-key-scanner
6+
docker:
7+
- image: node:10.13-stretch
8+
- image: redis:2.8.8
9+
10+
steps:
11+
- checkout
12+
13+
- restore_cache:
14+
key: v1-npmdeps-{{ checksum "package-lock.json" }}
15+
- run:
16+
name: Install dependencies
17+
command: npm i --progress=false
18+
- save_cache:
19+
key: v1-npmdeps-{{ checksum "package-lock.json" }}
20+
paths: node_modules
21+
22+
- run: npm test

.eslintrc.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
module.exports = {
2+
extends: ['change-base', 'change-base/mocha'],
3+
4+
rules: {
5+
'object-curly-newline': ['error', {
6+
ObjectPattern: { multiline: true },
7+
}],
8+
},
9+
};

.gitignore

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
*.swp
2+
.eslintcache
23
logs
34
node_modules
4-
5-
*.pem

.nvmrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
6.2.0
1+
v10.13.0

README.md

Lines changed: 18 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,47 @@
11
redis-key-scanner
22
=================
33

4-
Scan a redis server for keys matching specified criteria, including key
5-
patterns, TTL and IDLETIME. Selected/matched keys are output in a JSON log
6-
format. The scan is non-destructive, and doesn't even read any actual key
7-
values.
8-
9-
Note that if you are checking TTL times, due to an acknowledged
10-
[bug][redis-ttl-bug] in Redis, this will actually reset the IDLETIME to 0 for
11-
the selected keys, so subsequent scans may not return the same results.
12-
13-
Example command-line usage, querying a locally running redis server for keys
14-
that start with the prefix "mykeys:" and have been idle (ie., not written or
15-
read) for at least one week:
4+
Scan a redis server for keys matching specified criteria, including key patterns, TTL and IDLETIME.
5+
Selected/matched keys are output in a JSON log format. The scan is non-destructive, and doesn't
6+
even read any actual key values.
7+
8+
Note that if you are checking TTL times, due to an acknowledged [bug][redis-ttl-bug] in Redis, this
9+
will actually reset the IDLETIME to 0 for the selected keys, so subsequent scans may not return the
10+
same results.
11+
12+
Example command-line usage, querying a locally running redis server for keys that start with the
13+
prefix "mykeys:" and have been idle (ie., not written or read) for at least one week:
1614
```
1715
> npm install -g redis-key-scanner
1816
> redis-key-scanner localhost --pattern=mykeys:* --min-idle=1w
1917
```
2018

21-
Output will be one JSON line per selected key, followed by a "summary" line with
22-
total stats:
19+
Output will be one JSON line per selected key, followed by a "summary" line with total stats:
2320
```
2421
{"name":"localhost:6379","key":"mykeys:larry","idletime":604800}
2522
{"name":"localhost:6379","key":"mykeys:curly","idletime":900000}
2623
{"name":"localhost:6379","key":"mykeys:moe","idletime":1000000}
2724
{"keysScanned":17,"keysSelected":3,"host":"localhost","port":6379,"scanBatch":1000,"scanLimit":null,"limit":null,"pattern":"mykeys:*"}
2825
```
2926

30-
You can alternatively require `redis-key-scanner` as a Node.js module, in which
31-
case it implements a stream interface and each record will be emitted as a
32-
separate 'data' event.
27+
You can alternatively require `redis-key-scanner` as a Node.js module, in which case it implements a
28+
stream interface and each record will be emitted as a separate 'data' event.
3329
```js
34-
var RedisKeyScanner = require('redis-key-scanner');
35-
var scanner = new RedisKeyScanner({
30+
const RedisKeyScanner = require('redis-key-scanner');
31+
const scanner = new RedisKeyScanner({
3632
host: 'localhost',
3733
pattern: 'mykeys:*',
3834
minIdle: '1w'
3935
});
40-
scanner.on('data', function(data) {
36+
scanner.on('data', (data) => {
4137
console.log(data);
4238
});
43-
scanner.on('end', function() {
39+
scanner.on('end', () => {
4440
// clean up
4541
});
4642
```
4743

48-
Run `node redis-key-scanner` to see the full list of available options.
44+
Run `redis-key-scanner` to see the full list of available options.
4945

5046

5147
[redis-ttl-bug]: https://github.com/antirez/redis/pull/2090#issuecomment-75944263

0 commit comments

Comments
 (0)