Move moderator_for_tags Cache Key to Redis (#4690)
* Move moderator_for_tags cache key to Redis * move delete commands for tag moderator list to Redis as well
This commit is contained in:
parent
faaf6e35f1
commit
78f1eb2b11
2 changed files with 3 additions and 3 deletions
|
|
@ -17,7 +17,7 @@ module AssignTagModerator
|
|||
def self.add_tag_mod_role(user, tag)
|
||||
user.update(email_tag_mod_newsletter: true) if user.email_tag_mod_newsletter == false
|
||||
user.add_role(:tag_moderator, tag)
|
||||
Rails.cache.delete("user-#{user.id}/tag_moderators_list")
|
||||
RedisRailsCache.delete("user-#{user.id}/tag_moderators_list")
|
||||
MailchimpBot.new(user).manage_tag_moderator_list
|
||||
end
|
||||
|
||||
|
|
@ -35,7 +35,7 @@ module AssignTagModerator
|
|||
def self.remove_tag_moderator(user, tag)
|
||||
user.remove_role(:tag_moderator, tag)
|
||||
user.update(email_tag_mod_newsletter: false) if user.email_tag_mod_newsletter == true
|
||||
Rails.cache.delete("user-#{user.id}/tag_moderators_list")
|
||||
RedisRailsCache.delete("user-#{user.id}/tag_moderators_list")
|
||||
MailchimpBot.new(user).manage_tag_moderator_list
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -337,7 +337,7 @@ class User < ApplicationRecord
|
|||
end
|
||||
|
||||
def moderator_for_tags
|
||||
Rails.cache.fetch("user-#{id}/tag_moderators_list", expires_in: 200.hours) do
|
||||
RedisRailsCache.fetch("user-#{id}/tag_moderators_list", expires_in: 200.hours) do
|
||||
tag_ids = roles.where(name: "tag_moderator").pluck(:resource_id)
|
||||
Tag.where(id: tag_ids).pluck(:name)
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue