Return cached query when hit

The code was calling into the cache twice, even if the first
call was a cache hit and not a miss.

Signed-off-by: Alex Ellis (OpenFaaS Ltd) <alexellis2@gmail.com>
This commit is contained in:
Alex Ellis (OpenFaaS Ltd)
2020-05-06 18:32:51 +01:00
parent c45334657a
commit 5741610f31

View File

@ -42,6 +42,8 @@ func (c *CachedFunctionQuery) Get(fn string, ns string) (ServiceQueryResponse, e
return ServiceQueryResponse{}, err return ServiceQueryResponse{}, err
} }
c.cache.Set(fn, ns, queryResponse) c.cache.Set(fn, ns, queryResponse)
} else {
return query, nil
} }
// At this point the value almost certainly must be present, so if not // At this point the value almost certainly must be present, so if not