module Aqila::Cache::Methods
Public Class Methods
cache_ttl()
click to toggle source
# File lib/aqila/cache/methods.rb, line 13 def self.cache_ttl @cache_ttl || Aqila::Cache.configuration.default_ttl end
cache_ttl=(cache_ttl)
click to toggle source
# File lib/aqila/cache/methods.rb, line 9 def self.cache_ttl=(cache_ttl) @cache_ttl = cache_ttl end
check_ttl()
click to toggle source
# File lib/aqila/cache/methods.rb, line 31 def self.check_ttl return unless cache_ttl log_table = Aqila::Cache::TableLastChange.for(model: self) return update_log_table unless log_table expired = (Time.current - log_table) > cache_ttl update_log_table if expired end
stale?(controller:)
click to toggle source
# File lib/aqila/cache/methods.rb, line 23 def self.stale?(controller:) check_ttl controller.response.headers['Cache-Control'] = 'public' controller.stale?(last_modified: Aqila::Cache::TableLastChange.for(model: self)) end
update_log_table()
click to toggle source
# File lib/aqila/cache/methods.rb, line 17 def self.update_log_table Aqila::Cache::TableLastChange .find_or_initialize_by(table_name: table_name) .update(updated_at: Time.current) end