Skip to content

Commit f4a2050

Browse files
authored
Yet another redis client. (#1)
1 parent a0043d0 commit f4a2050

File tree

12 files changed

+1091
-1
lines changed

12 files changed

+1091
-1
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,5 @@
1919

2020
# Go workspace file
2121
go.work
22+
23+
debug.log

.golangci.yaml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
linters:
2+
disable-all: true
3+
enable:
4+
- errcheck
5+
- exhaustive
6+
- goconst
7+
- gocritic
8+
- gocyclo
9+
- gofmt
10+
- goimports
11+
- gosimple
12+
- govet
13+
- ineffassign
14+
- staticcheck
15+
- tenv
16+
- typecheck
17+
- unconvert
18+
- unused
19+
- stylecheck

README.md

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,16 @@
1-
# readis
1+
# readis
2+
3+
Readis is a TUI Redis browser, built with [Charm](https://charm.sh/) libraries, inspired by [Redis Insight](https://redislabs.com/redis-enterprise/redis-insight/) [and](https://github.com/snmaynard/redis-audit) [other](https://github.com/antirez/redis-sampler) [tools](https://github.com/gamenet/redis-memory-analyzer).
4+
5+
6+
# Running readis
7+
8+
```bash
9+
go install github.com/sethrylan/readis@latest
10+
11+
readis --help
12+
13+
readis // defaults to localhost:6379
14+
15+
readis -c rediss://mycluster.example.com:10000
16+
```

cmd/main.go

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
package exec
2+
3+
import (
4+
"context"
5+
"fmt"
6+
"os"
7+
8+
"github.com/redis/go-redis/v9"
9+
)
10+
11+
// export REDIS_URI=$(vault-secret --application actions-redis -e lab | jq -r '.ACTIONS_REDIS_URIS | split(" ")[0]')
12+
func main() {
13+
find_keys_without_ttl()
14+
}
15+
16+
func find_keys_without_ttl() {
17+
opts, err := redis.ParseClusterURL(os.Getenv("REDIS_URI"))
18+
if err != nil {
19+
fmt.Printf("Error: %s\n", err)
20+
return
21+
}
22+
23+
cc := redis.NewClusterClient(opts)
24+
var cmds []redis.Cmder
25+
var ctx = context.Background()
26+
27+
fmt.Println("total:", cc.DBSize(ctx).Val())
28+
29+
err = cc.ForEachMaster(ctx, func(ctx context.Context, rc *redis.Client) error {
30+
fmt.Println("master:", rc.Options().Addr)
31+
scan := rc.Scan(ctx, 0, "*", 1000)
32+
iter := scan.Iterator()
33+
page, cursor := scan.Val()
34+
35+
shardcmds, err := rc.Pipelined(ctx, func(pipe redis.Pipeliner) error {
36+
for iter.Next(ctx) {
37+
pipe.TTL(ctx, iter.Val())
38+
}
39+
return nil
40+
})
41+
if err != nil {
42+
panic(err)
43+
}
44+
cmds = append(cmds, shardcmds...)
45+
46+
fmt.Println("cursor:", cursor)
47+
fmt.Println("pagesize:", len(page))
48+
49+
return iter.Err()
50+
})
51+
52+
if err != nil {
53+
panic(err)
54+
}
55+
56+
for _, cmd := range cmds {
57+
if cmd.(*redis.DurationCmd).Val() == -1 {
58+
fmt.Println(cmd.Args()[1])
59+
}
60+
}
61+
}

0 commit comments

Comments
 (0)