@@ -13,8 +13,8 @@ import (
1313 "time"
1414
1515 "github.com/darkweak/storages/core"
16- lz4 "github.com/pierrec/lz4/v4"
17- redis "github.com/redis/go-redis/v9"
16+ "github.com/pierrec/lz4/v4"
17+ "github.com/redis/go-redis/v9"
1818)
1919
2020// Redis provider type.
@@ -121,9 +121,22 @@ func (provider *Redis) ListKeys() []string {
121121
122122 keys := []string {}
123123
124- iter := provider .inClient .Scan (provider .ctx , 0 , "*" , 0 ).Iterator ()
124+ iter := provider .inClient .Scan (provider .ctx , 0 , provider . hashtags + core . MappingKeyPrefix + "*" , 0 ).Iterator ()
125125 for iter .Next (provider .ctx ) {
126- keys = append (keys , iter .Val ())
126+ value := provider .Get (iter .Val ())
127+
128+ mapping , err := core .DecodeMapping (value )
129+ if err != nil {
130+ continue
131+ }
132+
133+ for _ , v := range mapping .GetMapping () {
134+ if v .GetFreshTime ().AsTime ().Before (time .Now ()) && v .GetStaleTime ().AsTime ().Before (time .Now ()) {
135+ continue
136+ }
137+
138+ keys = append (keys , v .GetRealKey ())
139+ }
127140 }
128141
129142 if err := iter .Err (); err != nil {
@@ -160,7 +173,10 @@ func (provider *Redis) MapKeys(prefix string) map[string]string {
160173
161174 for idx , item := range keys {
162175 k , _ := strings .CutPrefix (item , prefix )
163- mapKeys [k ] = vals [idx ].(string )
176+
177+ if vals [idx ] != nil {
178+ mapKeys [k ] = vals [idx ].(string )
179+ }
164180 }
165181
166182 return mapKeys
0 commit comments