21 lines
466 B
Go
21 lines
466 B
Go
package redisdb
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
)
|
|
|
|
// DelWithPrefix ...
|
|
func (s Server) DelWithPrefix(ctx context.Context, prefix string) {
|
|
iter := s.rdb.Scan(ctx, 0, prefix, 0).Iterator()
|
|
for iter.Next(ctx) {
|
|
err := s.rdb.Del(ctx, iter.Val()).Err()
|
|
if err != nil {
|
|
fmt.Println("[redisdb] cannot delete redis key with prefix", prefix)
|
|
}
|
|
}
|
|
if err := iter.Err(); err != nil {
|
|
fmt.Println("[redisdb] cannot (LOOP) delete redis key with prefix", prefix)
|
|
}
|
|
}
|