From 833517f35ca3e2418c8edacde4838957296f8ba4 Mon Sep 17 00:00:00 2001 From: Lukasz Raczylo Date: Sat, 8 Apr 2023 03:13:30 +0100 Subject: [PATCH] fixup! Add randomisation test for cache concurrency. --- query.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/query.go b/query.go index c05032f..1492434 100644 --- a/query.go +++ b/query.go @@ -92,7 +92,7 @@ func (c *BaseClient) Query(queryContent string, queryVariables interface{}, quer queryHash = strutil.Md5(fmt.Sprintf("%s-%+v", query.compiledQuery, queryHeaders)) cacheBaseClient.Logger.Debug(cacheBaseClient, "Hash calculated;", "hash:", queryHash) - cachedResponse = cacheBaseClient.cacheLookup(queryHash) + cachedResponse = c.cacheLookup(queryHash) if cachedResponse != nil { cacheBaseClient.Logger.Debug(cacheBaseClient, "Found cached response") return cacheBaseClient.decodeResponse(cachedResponse), nil @@ -113,8 +113,8 @@ func (c *BaseClient) Query(queryContent string, queryVariables interface{}, quer return nil, err } - if cacheBaseClient.cache.enabled { - cacheBaseClient.cache.client.Set(queryHash, jsonData) + if cacheBaseClient.cache.enabled && jsonData != nil && queryHash != "" { + c.cache.client.Set(queryHash, jsonData) } return cacheBaseClient.decodeResponse(jsonData), err