Synchronously bust cache after save for comments (#1275)
This commit is contained in:
parent
86e55c2b6d
commit
fbe586497b
1 changed files with 6 additions and 1 deletions
|
|
@ -20,6 +20,7 @@ class Comment < ApplicationRecord
|
|||
after_create :after_create_checks
|
||||
after_save :calculate_score
|
||||
after_save :bust_cache
|
||||
after_save :synchronous_bust
|
||||
before_destroy :before_destroy_actions
|
||||
after_create :send_email_notification, if: :should_send_email_notification?
|
||||
after_create :create_first_reaction
|
||||
|
|
@ -292,11 +293,15 @@ class Comment < ApplicationRecord
|
|||
Comment.comment_async_bust(commentable, user.username)
|
||||
expire_root_fragment
|
||||
cache_buster = CacheBuster.new
|
||||
cache_buster.bust(commentable.path.to_s) if commentable
|
||||
cache_buster.bust("#{commentable.path}/comments") if commentable
|
||||
end
|
||||
handle_asynchronously :bust_cache
|
||||
|
||||
def synchronous_bust
|
||||
cache_buster = CacheBuster.new
|
||||
cache_buster.bust(commentable.path.to_s) if commentable
|
||||
end
|
||||
|
||||
def send_email_notification
|
||||
NotifyMailer.new_reply_email(self).deliver
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue