Skip to content

Commit

Permalink
fix: use cache_version instead of cache_key (#1539)
Browse files Browse the repository at this point in the history
  • Loading branch information
rabbitz authored Dec 22, 2023
1 parent 8864b57 commit dfd4a68
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions app/serializers/ckb_transaction_serializer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class CkbTransactionSerializer
end

attribute :display_inputs do |object, params|
cache_key = "display_inputs_previews_#{params[:previews].present?}_#{object.id}_#{object.inputs.cache_key}"
cache_key = "display_inputs_previews_#{params[:previews].present?}_#{object.id}_#{object.inputs.cache_version}"
Rails.cache.fetch(cache_key, expires_in: 1.day) do
if params && params[:previews]
object.display_inputs(previews: true)
Expand All @@ -56,7 +56,7 @@ class CkbTransactionSerializer
end

attribute :display_outputs do |object, params|
cache_key = "display_outputs_previews_#{params[:previews].present?}_#{object.id}_#{object.outputs.cache_key}"
cache_key = "display_outputs_previews_#{params[:previews].present?}_#{object.id}_#{object.outputs.cache_version}"
Rails.cache.fetch(cache_key, expires_in: 1.day) do
if params && params[:previews]
object.display_outputs(previews: true)
Expand Down
4 changes: 2 additions & 2 deletions app/serializers/ckb_transactions_serializer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class CkbTransactionsSerializer
end

attribute :display_inputs do |object, params|
cache_key = "display_inputs_previews_#{params[:previews].present?}_#{object.id}_#{object.inputs.cache_key}"
cache_key = "display_inputs_previews_#{params[:previews].present?}_#{object.id}_#{object.inputs.cache_version}"
Rails.cache.fetch(cache_key, expires_in: 1.day) do
if params && params[:previews]
object.display_inputs(previews: true)
Expand All @@ -35,7 +35,7 @@ class CkbTransactionsSerializer
end

attribute :display_outputs do |object, params|
cache_key = "display_outputs_previews_#{params[:previews].present?}_#{object.id}_#{object.outputs.cache_key}"
cache_key = "display_outputs_previews_#{params[:previews].present?}_#{object.id}_#{object.outputs.cache_version}"
Rails.cache.fetch(cache_key, expires_in: 1.day) do
if params && params[:previews]
object.display_outputs(previews: true)
Expand Down

0 comments on commit dfd4a68

Please sign in to comment.