A platform for community discussion. Free, open, simple.
PERF: do not expire cache when PostActionType is saved (#28337)
Krzysztof Kotlarekd2c09e5ce100
diff --git a/app/models/post_action_type.rb b/app/models/post_action_type.rbindex 27fbd5fcbe7..b0a47dcaa8e 100644--- a/app/models/post_action_type.rb+++ b/app/models/post_action_type.rb@@ -5,8 +5,10 @@ class PostActionType < ActiveRecord::BasePOST_ACTION_TYPE_PUBLIC_TYPE_IDS_KEY = "post_action_public_type_ids"LIKE_POST_ACTION_ID = 2- after_save :expire_cache- after_destroy :expire_cache+ after_save { expire_cache if !skip_expire_cache_callback }+ after_destroy { expire_cache if !skip_expire_cache_callback }++ attr_accessor :skip_expire_cache_callbackinclude AnonCacheInvalidatordiff --git a/db/fixtures/003_post_action_types.rb b/db/fixtures/003_post_action_types.rbindex be504a0eac9..fd631fcb0f2 100644--- a/db/fixtures/003_post_action_types.rb+++ b/db/fixtures/003_post_action_types.rb@@ -6,6 +6,7 @@ PostActionType.seed do |s|s.is_flag = falses.icon = "heart"s.position = 2+ s.skip_expire_cache_callback = trueendPostActionType.seed do |s|@@ -13,6 +14,7 @@ PostActionType.seed do |s|s.name_key = "off_topic"s.is_flag = trues.position = 3+ s.skip_expire_cache_callback = trueendPostActionType.seed do |s|@@ -20,6 +22,7 @@ PostActionType.seed do |s|s.name_key = "inappropriate"s.is_flag = trues.position = 4+ s.skip_expire_cache_callback = trueendPostActionType.seed do |s|@@ -27,6 +30,7 @@ PostActionType.seed do |s|s.name_key = "spam"s.is_flag = trues.position = 6+ s.skip_expire_cache_callback = trueendPostActionType.seed do |s|@@ -34,6 +38,7 @@ PostActionType.seed do |s|s.name_key = "notify_user"s.is_flag = trues.position = 7+ s.skip_expire_cache_callback = trueendPostActionType.seed do |s|@@ -41,4 +46,5 @@ PostActionType.seed do |s|s.name_key = "notify_moderators"s.is_flag = trues.position = 8+ s.skip_expire_cache_callback = trueend