class CriticalPathCssWorker::CacheState

Constants

CRITICAL_CSS_CACHE_HELPER_NAMESPACE
FRESH
PROCESSING

Public Class Methods

clear_matched(routes) click to toggle source
# File lib/critical_path_css_worker/cache_state.rb, line 38
def self.clear_matched(routes)
  Rails.cache.delete_matched(routes, namespace: CRITICAL_CSS_CACHE_HELPER_NAMESPACE)
end
fresh(route) click to toggle source
# File lib/critical_path_css_worker/cache_state.rb, line 11
def self.fresh(route)
  set_state(route, FRESH, 6.days)
end
fresh?(route) click to toggle source
# File lib/critical_path_css_worker/cache_state.rb, line 31
def self.fresh?(route)
  Rails.cache.read(
    route,
    namespace: CRITICAL_CSS_CACHE_HELPER_NAMESPACE
  ) == FRESH
end
processing(route) click to toggle source
# File lib/critical_path_css_worker/cache_state.rb, line 7
def self.processing(route)
  set_state(route, PROCESSING)
end
processing?(route) click to toggle source
# File lib/critical_path_css_worker/cache_state.rb, line 24
def self.processing?(route)
  Rails.cache.read(
    route,
    namespace: CRITICAL_CSS_CACHE_HELPER_NAMESPACE
  ) == PROCESSING
end
set_state(route, state, expiry = 1.hour) click to toggle source
# File lib/critical_path_css_worker/cache_state.rb, line 15
def self.set_state(route, state, expiry = 1.hour)
  Rails.cache.write(
    route,
    state,
    namespace: CRITICAL_CSS_CACHE_HELPER_NAMESPACE,
    expires_in: expiry
  )
end