Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
colinlyguo committed Dec 6, 2023
1 parent e79900e commit 5902bee
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions bridge-history-api/internal/logic/history_logic.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const (
cacheKeyPrefixL2WithdrawalsByAddr = "l2WithdrawalsByAddr:"
cacheKeyPrefixTxsByAddr = "txsByAddr:"
cacheKeyPrefixQueryTxsByHashes = "queryTxsByHashes:"
cacheExpiredTime = 30 * time.Minute
cacheKeyExpiredTime = 30 * time.Minute
)

// HistoryLogic services.
Expand Down Expand Up @@ -230,13 +230,13 @@ func (h *HistoryLogic) GetTxsByHashes(ctx context.Context, txHashes []string) ([
if err != nil {
log.Error("failed to marshal data", "error", err)
} else {
if err := h.redis.Set(ctx, cacheKey, jsonData, cacheExpiredTime).Err(); err != nil {
if err := h.redis.Set(ctx, cacheKey, jsonData, cacheKeyExpiredTime).Err(); err != nil {
log.Error("failed to set data to Redis", "error", err)
}
}
} else {
// tx hash not found, which is also a valid result, cache empty string.
if err := h.redis.Set(ctx, cacheKey, "", cacheExpiredTime).Err(); err != nil {
if err := h.redis.Set(ctx, cacheKey, "", cacheKeyExpiredTime).Err(); err != nil {
log.Error("failed to set data to Redis", "error", err)
}
}
Expand Down Expand Up @@ -333,7 +333,7 @@ func (h *HistoryLogic) cacheTxsInfo(ctx context.Context, cacheKey string, txs []
}
}

if err := pipe.Expire(ctx, cacheKey, cacheExpiredTime).Err(); err != nil {
if err := pipe.Expire(ctx, cacheKey, cacheKeyExpiredTime).Err(); err != nil {
log.Error("failed to set expiry time", "error", err)
return err
}
Expand Down

0 comments on commit 5902bee

Please sign in to comment.