Fixed leak

This commit is contained in:
Atridad Lahiji 2023-12-27 12:48:47 -07:00
parent f75db108a7
commit ead52d8740
No known key found for this signature in database

View file

@ -19,6 +19,8 @@ func SetCache(key string, value string, ttlMinutes int) bool {
DB: 0,
})
defer redis.Client.Close(*rdb)
err := rdb.Set(ctx, key, value, time.Minute*time.Duration(ttlMinutes)).Err()
return err != nil
@ -31,6 +33,8 @@ func GetCache(key string) string {
DB: 0,
})
defer redis.Client.Close(*rdb)
val, err := rdb.Get(ctx, key).Result()
if err != nil {
return "nil"