Move caching of reaction to rediscache (#4819)
This commit is contained in:
parent
7cc5ef5e40
commit
e92b005d02
1 changed files with 2 additions and 2 deletions
|
|
@ -59,8 +59,8 @@ class Reaction < ApplicationRecord
|
|||
|
||||
def cached_any_reactions_for?(reactable, user, category)
|
||||
class_name = reactable.class.name == "ArticleDecorator" ? "Article" : reactable.class.name
|
||||
cache_name = "any_reactions_for-#{class_name}-#{reactable.id}-#{user.updated_at}-#{category}"
|
||||
Rails.cache.fetch(cache_name, expires_in: 24.hours) do
|
||||
cache_name = "any_reactions_for-#{class_name}-#{reactable.id}-#{user.updated_at&.rfc3339}-#{category}"
|
||||
RedisRailsCache.fetch(cache_name, expires_in: 24.hours) do
|
||||
Reaction.where(reactable_id: reactable.id, reactable_type: class_name, user: user, category: category).any?
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue