From a6874a3629012067b7e67fdca13e5100d93554a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Neto?= Date: Mon, 28 Jun 2021 09:58:01 -0300 Subject: [PATCH] redis: Fix error handling The error `redis.Nil` is only returned when no key is found in the Redis database. In that case, we should only return and nil value instead of an error. Therefore, this patch fixes the `Get` method to only return an error when necessary. --- pkg/network/redis.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/network/redis.go b/pkg/network/redis.go index 74315d9..9713310 100644 --- a/pkg/network/redis.go +++ b/pkg/network/redis.go @@ -46,7 +46,7 @@ func (r *Redis) Set(key string, value interface{}, expiration time.Duration) err // Get retrieves a value from the Redis database according to key, which is returned as a string. func (r *Redis) Get(key string) (string, error) { val, err := r.rdb.Get(ctx, key).Result() - if err != redis.Nil { + if err != nil && err != redis.Nil { return "", err }