Skip to content

Commit 391a72b

Browse files
committed
feat(graphql): log the APQ errors
1 parent 9d975eb commit 391a72b

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

internal/graphql/apq/apq.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ package apq
44

55
import (
66
"context"
7+
"log/slog"
78
"time"
89

910
"github.com/99designs/gqlgen/graphql"
@@ -24,14 +25,22 @@ func NewCache(client rueidis.Client, ttl time.Duration) *Cache {
2425
func (c *Cache) Get(ctx context.Context, query string) (string, bool) {
2526
reply, err := c.client.Do(ctx, c.client.B().Get().Key(redisApqPrefix+query).Build()).ToString()
2627
if err != nil {
28+
if rueidis.IsRedisNil(err) {
29+
return "", false
30+
}
31+
32+
slog.Warn("error getting apq from cache", "error", err, "query", query)
2733
return "", false
2834
}
2935

3036
return reply, true
3137
}
3238

3339
func (c *Cache) Add(ctx context.Context, query string, value string) {
34-
c.client.Do(ctx, c.client.B().Set().Key(redisApqPrefix+query).Value(value).Ex(c.ttl).Build())
40+
err := c.client.Do(ctx, c.client.B().Set().Key(redisApqPrefix+query).Value(value).Ex(c.ttl).Build()).Error()
41+
if err != nil {
42+
slog.Warn("error adding apq to cache", "error", err, "query", query)
43+
}
3544
}
3645

3746
var _ graphql.Cache[string] = &Cache{}

0 commit comments

Comments
 (0)