// Package cache provides cache implementations and adapters. package cache import ( "context" "time" ) // GraphQLCacheAdapter adapts the RedisCache to the graphql.Cache[string] interface type GraphQLCacheAdapter struct { RedisCache *RedisCache } // Get looks up a key in the cache func (a *GraphQLCacheAdapter) Get(ctx context.Context, key string) (string, bool) { // gqlgen APQ stores strings. var s string err := a.RedisCache.Get(ctx, key, &s) if err != nil { return "", false } return s, true } // Add adds a key to the cache func (a *GraphQLCacheAdapter) Add(ctx context.Context, key, value string) { // Use default TTL of 24 hours for APQ. The interface does not provide TTL. _ = a.RedisCache.Set(ctx, key, value, 24*time.Hour) }