2026-01-02 13:41:09 +00:00
|
|
|
# Copyright (C) 2012-2026 Zammad Foundation, https://zammad-foundation.org/
|
2021-06-01 12:20:20 +00:00
|
|
|
|
2017-05-02 15:21:13 +00:00
|
|
|
module ApplicationModel::HasCache
|
2017-01-31 17:13:45 +00:00
|
|
|
extend ActiveSupport::Concern
|
|
|
|
|
|
2022-06-28 20:28:40 +00:00
|
|
|
included do
|
|
|
|
|
after_commit :cache_delete
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def cache_update(other)
|
|
|
|
|
cache_delete if respond_to?(:cache_delete)
|
|
|
|
|
other.cache_delete if other.respond_to?(:cache_delete)
|
2021-08-25 12:24:42 +00:00
|
|
|
ActiveSupport::CurrentAttributes.clear_all
|
2017-06-16 20:43:09 +00:00
|
|
|
true
|
2017-01-31 17:13:45 +00:00
|
|
|
end
|
2022-06-28 20:28:40 +00:00
|
|
|
|
|
|
|
|
def cache_delete
|
|
|
|
|
Rails.cache.delete("#{self.class}::aws::#{id}")
|
|
|
|
|
end
|
2017-01-31 17:13:45 +00:00
|
|
|
end
|