From 31ccb72ad2c3a2798444ed6a66881debca97ba8f Mon Sep 17 00:00:00 2001 From: Jonathan LEI Date: Sun, 1 Sep 2024 04:51:34 +0800 Subject: [PATCH] revert: fix: avoid caching empty values for now Partially reverts 2d8f5c806a005cd2aebe6e04e22e4299648e9edb. --- erpc/evm_json_rpc_cache.go | 6 +----- erpc/networks.go | 2 +- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/erpc/evm_json_rpc_cache.go b/erpc/evm_json_rpc_cache.go index ac358989..7ca40965 100644 --- a/erpc/evm_json_rpc_cache.go +++ b/erpc/evm_json_rpc_cache.go @@ -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, @@ -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 } diff --git a/erpc/networks.go b/erpc/networks.go index e4c23405..e437b4a9 100644 --- a/erpc/networks.go +++ b/erpc/networks.go @@ -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()