Is there any way to flushdb with go redis cache?
lqn0011 opened this issue · 2 comments
lqn0011 commented
How can we clear all cache with a function call?
nwtnsqrd commented
Hello, in case you still need an answer. You can use functionality from package https://github.com/go-redis/redis
var (
rdb = redis.NewClient(&redis.Options{
Addr: "localhost:6379",
DB: 0,
})
ctx = context.Background()
)
func FlushRedisCache() {
if _, err := rdb.Do(ctx, "flushdb").Result(); err != nil {
fmt.Println("ERROR: Could not flush Redis cache:", err.Error())
}
}
lqn0011 commented
Thanks, this one is straightforward🤝.