mirror of
https://github.com/lukaszraczylo/graphql-monitoring-proxy.git
synced 2026-10-18 06:17:56 +00:00
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:
Vendored
+8
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user