PERF: do not expire cache when PostActionType is saved (#28337)
Reload is too expensive in a multisite environment. A proper way to expire cache is coming with the next PR.
This commit is contained in:
parent
47f749744f
commit
d2c09e5ce1
|
@ -5,8 +5,10 @@ class PostActionType < ActiveRecord::Base
|
||||||
POST_ACTION_TYPE_PUBLIC_TYPE_IDS_KEY = "post_action_public_type_ids"
|
POST_ACTION_TYPE_PUBLIC_TYPE_IDS_KEY = "post_action_public_type_ids"
|
||||||
LIKE_POST_ACTION_ID = 2
|
LIKE_POST_ACTION_ID = 2
|
||||||
|
|
||||||
after_save :expire_cache
|
after_save { expire_cache if !skip_expire_cache_callback }
|
||||||
after_destroy :expire_cache
|
after_destroy { expire_cache if !skip_expire_cache_callback }
|
||||||
|
|
||||||
|
attr_accessor :skip_expire_cache_callback
|
||||||
|
|
||||||
include AnonCacheInvalidator
|
include AnonCacheInvalidator
|
||||||
|
|
||||||
|
|
|
@ -6,6 +6,7 @@ PostActionType.seed do |s|
|
||||||
s.is_flag = false
|
s.is_flag = false
|
||||||
s.icon = "heart"
|
s.icon = "heart"
|
||||||
s.position = 2
|
s.position = 2
|
||||||
|
s.skip_expire_cache_callback = true
|
||||||
end
|
end
|
||||||
|
|
||||||
PostActionType.seed do |s|
|
PostActionType.seed do |s|
|
||||||
|
@ -13,6 +14,7 @@ PostActionType.seed do |s|
|
||||||
s.name_key = "off_topic"
|
s.name_key = "off_topic"
|
||||||
s.is_flag = true
|
s.is_flag = true
|
||||||
s.position = 3
|
s.position = 3
|
||||||
|
s.skip_expire_cache_callback = true
|
||||||
end
|
end
|
||||||
|
|
||||||
PostActionType.seed do |s|
|
PostActionType.seed do |s|
|
||||||
|
@ -20,6 +22,7 @@ PostActionType.seed do |s|
|
||||||
s.name_key = "inappropriate"
|
s.name_key = "inappropriate"
|
||||||
s.is_flag = true
|
s.is_flag = true
|
||||||
s.position = 4
|
s.position = 4
|
||||||
|
s.skip_expire_cache_callback = true
|
||||||
end
|
end
|
||||||
|
|
||||||
PostActionType.seed do |s|
|
PostActionType.seed do |s|
|
||||||
|
@ -27,6 +30,7 @@ PostActionType.seed do |s|
|
||||||
s.name_key = "spam"
|
s.name_key = "spam"
|
||||||
s.is_flag = true
|
s.is_flag = true
|
||||||
s.position = 6
|
s.position = 6
|
||||||
|
s.skip_expire_cache_callback = true
|
||||||
end
|
end
|
||||||
|
|
||||||
PostActionType.seed do |s|
|
PostActionType.seed do |s|
|
||||||
|
@ -34,6 +38,7 @@ PostActionType.seed do |s|
|
||||||
s.name_key = "notify_user"
|
s.name_key = "notify_user"
|
||||||
s.is_flag = true
|
s.is_flag = true
|
||||||
s.position = 7
|
s.position = 7
|
||||||
|
s.skip_expire_cache_callback = true
|
||||||
end
|
end
|
||||||
|
|
||||||
PostActionType.seed do |s|
|
PostActionType.seed do |s|
|
||||||
|
@ -41,4 +46,5 @@ PostActionType.seed do |s|
|
||||||
s.name_key = "notify_moderators"
|
s.name_key = "notify_moderators"
|
||||||
s.is_flag = true
|
s.is_flag = true
|
||||||
s.position = 8
|
s.position = 8
|
||||||
|
s.skip_expire_cache_callback = true
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue