Skip to content

Commit

Permalink
fixup! Add randomisation test for cache concurrency.
Browse files Browse the repository at this point in the history
  • Loading branch information
lukaszraczylo committed Apr 8, 2023
1 parent 07e4f75 commit 833517f
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions query.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 833517f

Please sign in to comment.