Skip to content

Commit ed81fc3

Browse files
committed
fix
1 parent 7745cdf commit ed81fc3

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

certcache/redis.go

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,19 @@ import (
88
)
99

1010
type RedisCache struct {
11-
r redis.Cmdable
11+
r redis.Cmdable
12+
pfx string
1213
}
1314

14-
func NewRedisCache(r redis.Cmdable) RedisCache {
15-
return RedisCache{r}
15+
func NewRedisCache(r redis.Cmdable, prefix string) *RedisCache {
16+
return &RedisCache{
17+
r: r,
18+
pfx: prefix,
19+
}
1620
}
1721

1822
func (r RedisCache) Get(ctx context.Context, key string) ([]byte, error) {
19-
res, err := r.r.Get(ctx, key).Bytes()
23+
res, err := r.r.Get(ctx, r.pfx+key).Bytes()
2024
if err != nil {
2125
if err == redis.Nil {
2226
return nil, autocert.ErrCacheMiss
@@ -27,9 +31,9 @@ func (r RedisCache) Get(ctx context.Context, key string) ([]byte, error) {
2731
}
2832

2933
func (r RedisCache) Put(ctx context.Context, key string, data []byte) error {
30-
return r.r.Set(ctx, key, data, 0).Err()
34+
return r.r.Set(ctx, r.pfx+key, data, 0).Err()
3135
}
3236

3337
func (r RedisCache) Delete(ctx context.Context, key string) error {
34-
return r.r.Del(ctx, key).Err()
38+
return r.r.Del(ctx, r.pfx+key).Err()
3539
}

0 commit comments

Comments
 (0)