Resolve issue when proxy could panic.

Issue occured when cache was disabled via environment variables but
graphql queries contained the cache directive.
This commit is contained in:
2024-08-19 11:27:06 +01:00
parent 016374722d
commit dc9e0906fd
2 changed files with 9 additions and 0 deletions
+8
View File
@@ -76,6 +76,10 @@ func EnableCache(cfg *CacheConfig) {
}
func CacheLookup(hash string) []byte {
if !IsCacheInitialized() {
return nil
}
obj, found := config.Client.Get(hash)
if found {
atomic.AddInt64(&cacheStats.CacheHits, 1)
@@ -157,3 +161,7 @@ func GetCacheStats() *CacheStats {
func ShouldUseRedisCache(cfg *CacheConfig) bool {
return cfg.Redis.Enable
}
func IsCacheInitialized() bool {
return config != nil && config.Client != nil
}