@@ -2,6 +2,7 @@ package cache
22
33import (
44 "context"
5+ "errors"
56 "fmt"
67 "time"
78
@@ -10,27 +11,27 @@ import (
1011 "github.com/redis/go-redis/v9"
1112)
1213
13- // RedisCache is the Cache implementation in redis
14- type RedisCache struct {
14+ // redisCache is the Cache implementation in redis
15+ type redisCache struct {
1516 tracer telemetry.Tracer
1617 client * redis.Client
1718}
1819
1920// NewRedisCache creates a new instance of RedisCache
2021func NewRedisCache (tracer telemetry.Tracer , client * redis.Client ) Cache {
21- return & RedisCache {
22+ return & redisCache {
2223 tracer : tracer ,
2324 client : client ,
2425 }
2526}
2627
2728// Get an item from the redis cache
28- func (cache * RedisCache ) Get (ctx context.Context , key string ) (value string , err error ) {
29+ func (cache * redisCache ) Get (ctx context.Context , key string ) (value string , err error ) {
2930 ctx , span := cache .tracer .Start (ctx )
3031 defer span .End ()
3132
3233 response , err := cache .client .Get (ctx , key ).Result ()
33- if err == redis .Nil {
34+ if errors . Is ( err , redis .Nil ) {
3435 return "" , stacktrace .Propagate (err , fmt .Sprintf ("no item found in redis with key [%s]" , key ))
3536 }
3637 if err != nil {
@@ -40,7 +41,7 @@ func (cache *RedisCache) Get(ctx context.Context, key string) (value string, err
4041}
4142
4243// Set an item in the redis cache
43- func (cache * RedisCache ) Set (ctx context.Context , key string , value string , ttl time.Duration ) error {
44+ func (cache * redisCache ) Set (ctx context.Context , key string , value string , ttl time.Duration ) error {
4445 ctx , span := cache .tracer .Start (ctx )
4546 defer span .End ()
4647
0 commit comments