Skip to content

Commit

Permalink
revert: fix: avoid caching empty values for now
Browse files Browse the repository at this point in the history
Partially reverts 2d8f5c8.
  • Loading branch information
xJonathanLEI committed Aug 31, 2024
1 parent 1088150 commit 31ccb72
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 6 deletions.
6 changes: 1 addition & 5 deletions erpc/evm_json_rpc_cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,6 @@ func (c *EvmJsonRpcCache) Get(ctx context.Context, req *common.NormalizedRequest
return nil, err
}

if resultString == `""` || resultString == "null" || resultString == "[]" || resultString == "{}" {
return nil, nil
}

jrr := &common.JsonRpcResponse{
JSONRPC: rpcReq.JSONRPC,
ID: rpcReq.ID,
Expand All @@ -114,7 +110,7 @@ func (c *EvmJsonRpcCache) Set(ctx context.Context, req *common.NormalizedRequest

lg := c.logger.With().Str("network", req.NetworkId()).Str("method", rpcReq.Method).Logger()

if resp == nil || resp.IsObjectNull() || resp.IsResultEmptyish() || rpcResp == nil || rpcResp.Result == nil || rpcResp.Error != nil {
if rpcResp == nil || rpcResp.Result == nil || rpcResp.Error != nil {
lg.Debug().Msg("not caching response because it has no result or has error")
return nil
}
Expand Down
2 changes: 1 addition & 1 deletion erpc/networks.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ func (n *Network) Forward(ctx context.Context, req *common.NormalizedRequest) (*
if err != nil {
lg.Debug().Err(err).Msgf("could not find response in cache")
health.MetricNetworkCacheMisses.WithLabelValues(n.ProjectId, n.NetworkId, method).Inc()
} else if resp != nil && !resp.IsObjectNull() && !resp.IsResultEmptyish() {
} else if resp != nil {
resp.SetFromCache(true)
lg.Info().Msgf("response served from cache")
health.MetricNetworkCacheHits.WithLabelValues(n.ProjectId, n.NetworkId, method).Inc()
Expand Down

0 comments on commit 31ccb72

Please sign in to comment.