Get an item from the redis cache
(ctx context.Context, key string)
| 27 | |
| 28 | // Get an item from the redis cache |
| 29 | func (cache *redisCache) Get(ctx context.Context, key string) (value string, err error) { |
| 30 | ctx, span := cache.tracer.Start(ctx) |
| 31 | defer span.End() |
| 32 | |
| 33 | response, err := cache.client.Get(ctx, key).Result() |
| 34 | if errors.Is(err, redis.Nil) { |
| 35 | return "", stacktrace.Propagate(err, fmt.Sprintf("no item found in redis with key [%s]", key)) |
| 36 | } |
| 37 | if err != nil { |
| 38 | return "", stacktrace.Propagate(err, fmt.Sprintf("cannot get item in redis with key [%s]", key)) |
| 39 | } |
| 40 | return response, nil |
| 41 | } |
| 42 | |
| 43 | // Set an item in the redis cache |
| 44 | func (cache *redisCache) Set(ctx context.Context, key string, value string, ttl time.Duration) error { |