module RailsWebCache

Constants

VERSION

Public Class Methods

cache() click to toggle source
# File lib/rails_web_cache.rb, line 12
def cache
  @cache ||= driver(Rails.cache)
end

Private Class Methods

driver(cache) click to toggle source
# File lib/rails_web_cache.rb, line 18
def driver(cache)
  if redis_cache_store?(cache)
    RedisCacheStore.new(cache)
  elsif memory_store?(cache)
    MemoryStore.new(cache)
  elsif file_store?(cache)
    FileStore.new(cache)
  else
    raise ArgumentError, "RailsWebCache doesn't support #{cache.class}"
  end
end
file_store?(driver) click to toggle source
# File lib/rails_web_cache.rb, line 41
def file_store?(driver)
  !!defined?(::ActiveSupport::Cache::FileStore) &&
    driver.is_a?(::ActiveSupport::Cache::FileStore)
end
memory_store?(driver) click to toggle source
# File lib/rails_web_cache.rb, line 36
def memory_store?(driver)
  !!defined?(::ActiveSupport::Cache::MemoryStore) &&
    driver.is_a?(::ActiveSupport::Cache::MemoryStore)
end
redis_cache_store?(driver) click to toggle source
# File lib/rails_web_cache.rb, line 30
def redis_cache_store?(driver)
  !!defined?(::Redis) &&
    !!defined?(::ActiveSupport::Cache::RedisCacheStore) &&
    driver.is_a?(::ActiveSupport::Cache::RedisCacheStore)
end