Skip to content

Commit

Permalink
Add check for whether cache is not nil
Browse files Browse the repository at this point in the history
  • Loading branch information
ishank011 committed Feb 2, 2022
1 parent c3b3f80 commit c4d4620
Showing 1 changed file with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1051,10 +1051,15 @@ func (h *Handler) getResourceInfo(ctx context.Context, client gateway.GatewayAPI
var pinfo *provider.ResourceInfo
var status *rpc.Status
var err error
if pinfo, err = h.resourceInfoCache.Get(key); h.resourceInfoCacheTTL > 0 && err == nil {
logger.Debug().Msgf("cache hit for resource %+v", key)
status = &rpc.Status{Code: rpc.Code_CODE_OK}
} else {
var foundInCache bool
if h.resourceInfoCacheTTL > 0 && h.resourceInfoCache != nil {
if pinfo, err = h.resourceInfoCache.Get(key); err == nil {
logger.Debug().Msgf("cache hit for resource %+v", key)
status = &rpc.Status{Code: rpc.Code_CODE_OK}
foundInCache = true
}
}
if !foundInCache {
logger.Debug().Msgf("cache miss for resource %+v, statting", key)
statReq := &provider.StatRequest{
Ref: ref,
Expand Down

0 comments on commit c4d4620

Please sign in to comment.