From f96b37bec42d6dde66634477eadf4a624bf6b97a Mon Sep 17 00:00:00 2001
From: Jimmie Han <hanjinming@outlook.com>
Date: Wed, 8 Dec 2021 19:19:29 +0800
Subject: [PATCH 1/3] docs: add changelog about redis cache

Signed-off-by: Jimmie Han <hanjinming@outlook.com>
---
 CHANGELOG.md | 1 +
 1 file changed, 1 insertion(+)

diff --git a/CHANGELOG.md b/CHANGELOG.md
index f7e9ab494f..adb88d9ca1 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -32,6 +32,7 @@ We use *breaking :warning:* to mark changes that are not backward compatible (re
 - [#4903](https://github.com/thanos-io/thanos/pull/4903) Compactor: Added tracing support for compaction.
 - [#4909](https://github.com/thanos-io/thanos/pull/4909) Compactor: Add flag --max-time / --min-time to filter blocks that are ready to be compacted.
 - [#4942](https://github.com/thanos-io/thanos/pull/4942) Tracing: add `traceid_128bit` support for jaeger.
+- [#4888](https://github.com/thanos-io/thanos/pull/4888) Cache: support redis cache backend.
 
 ### Fixed
 

From ff16a7afedbb4a55695749a2ebca59888bb8fde6 Mon Sep 17 00:00:00 2001
From: Jimmie Han <hanjinming@outlook.com>
Date: Wed, 8 Dec 2021 19:19:55 +0800
Subject: [PATCH 2/3] docs: fix comment

Signed-off-by: Jimmie Han <hanjinming@outlook.com>
---
 pkg/queryfrontend/cache.go | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/pkg/queryfrontend/cache.go b/pkg/queryfrontend/cache.go
index c41321e1e4..0a18a95d81 100644
--- a/pkg/queryfrontend/cache.go
+++ b/pkg/queryfrontend/cache.go
@@ -34,7 +34,7 @@ func (t thanosCacheKeyGenerator) GenerateCacheKey(userID string, r queryrange.Re
 		i := 0
 		for ; i < len(t.resolutions) && t.resolutions[i] > tr.MaxSourceResolution; i++ {
 		}
-		// Cache key should has a uniq prefix, We use `fe` represent frontend.
+		// Cache key should have a unique prefix. `fe` represents frontend.
 		return fmt.Sprintf("fe:%s:%s:%d:%d:%d", userID, tr.Query, tr.Step, currentInterval, i)
 	case *ThanosLabelsRequest:
 		return fmt.Sprintf("fe:%s:%s:%s:%d", userID, tr.Label, tr.Matchers, currentInterval)

From 651489c57851818e97819fa0a35271aab7c2cb5c Mon Sep 17 00:00:00 2001
From: Jimmie Han <hanjinming@outlook.com>
Date: Sat, 11 Dec 2021 21:10:43 +0800
Subject: [PATCH 3/3] docs: fix typo

Signed-off-by: Jimmie Han <hanjinming@outlook.com>
---
 pkg/cacheutil/redis_client.go             | 2 +-
 pkg/queryfrontend/cache.go                | 1 -
 pkg/store/cache/caching_bucket_factory.go | 2 +-
 pkg/store/cache/memcached.go              | 2 +-
 4 files changed, 3 insertions(+), 4 deletions(-)

diff --git a/pkg/cacheutil/redis_client.go b/pkg/cacheutil/redis_client.go
index 9b15585d60..e7cdec606b 100644
--- a/pkg/cacheutil/redis_client.go
+++ b/pkg/cacheutil/redis_client.go
@@ -168,7 +168,7 @@ func NewRedisClientWithConfig(logger log.Logger, name string, config RedisClient
 	}
 	duration := promauto.With(reg).NewHistogramVec(prometheus.HistogramOpts{
 		Name:    "thanos_redis_operation_duration_seconds",
-		Help:    "Duration of operations against memcached.",
+		Help:    "Duration of operations against redis.",
 		Buckets: []float64{0.001, 0.005, 0.01, 0.025, 0.05, 0.1, 0.2, 0.5, 1, 3, 6, 10},
 	}, []string{"operation"})
 	c.durationSet = duration.WithLabelValues(opSet)
diff --git a/pkg/queryfrontend/cache.go b/pkg/queryfrontend/cache.go
index 0a18a95d81..47b948c4c7 100644
--- a/pkg/queryfrontend/cache.go
+++ b/pkg/queryfrontend/cache.go
@@ -34,7 +34,6 @@ func (t thanosCacheKeyGenerator) GenerateCacheKey(userID string, r queryrange.Re
 		i := 0
 		for ; i < len(t.resolutions) && t.resolutions[i] > tr.MaxSourceResolution; i++ {
 		}
-		// Cache key should have a unique prefix. `fe` represents frontend.
 		return fmt.Sprintf("fe:%s:%s:%d:%d:%d", userID, tr.Query, tr.Step, currentInterval, i)
 	case *ThanosLabelsRequest:
 		return fmt.Sprintf("fe:%s:%s:%s:%d", userID, tr.Label, tr.Matchers, currentInterval)
diff --git a/pkg/store/cache/caching_bucket_factory.go b/pkg/store/cache/caching_bucket_factory.go
index 7ba4a6da81..f73e4a833d 100644
--- a/pkg/store/cache/caching_bucket_factory.go
+++ b/pkg/store/cache/caching_bucket_factory.go
@@ -101,7 +101,7 @@ func NewCachingBucketFromYaml(yamlContent []byte, bucket objstore.Bucket, logger
 	case string(RedisBucketCacheProvider):
 		redisCache, err := cacheutil.NewRedisClient(logger, "caching-bucket", backendConfig, reg)
 		if err != nil {
-			return nil, errors.Wrapf(err, "failed to create memcached client")
+			return nil, errors.Wrapf(err, "failed to create redis client")
 		}
 		c = cache.NewRedisCache("caching-bucket", logger, redisCache, reg)
 	default:
diff --git a/pkg/store/cache/memcached.go b/pkg/store/cache/memcached.go
index a103667c76..c997759a4e 100644
--- a/pkg/store/cache/memcached.go
+++ b/pkg/store/cache/memcached.go
@@ -53,7 +53,7 @@ func NewRemoteIndexCache(logger log.Logger, cacheClient cacheutil.RemoteCacheCli
 	c.hits.WithLabelValues(cacheTypePostings)
 	c.hits.WithLabelValues(cacheTypeSeries)
 
-	level.Info(logger).Log("msg", "created cacheClient index cache")
+	level.Info(logger).Log("msg", "created index cache")
 
 	return c, nil
 }