Sha256: 176967d981bb32b67e9c2cd3c7c2db82e70a3f1c19a67d2701934ba23c7209d2
Contents?: true
Size: 991 Bytes
Versions: 1
Compression:
Stored size: 991 Bytes
Contents
module CachedResource # The Config class is a singleton that contains # global configuration options for CacheResource class Config include Singleton # set default cache time to live to 1 week DEFAULT_CACHE_TIME_TO_LIVE = 604800 # prefix for log messages LOGGER_PREFIX = "[cached_resource]" attr_accessor :cache_enabled, :cache_time_to_live, :logger, :cache # initialize the config with caching enabled and # a default cache expiry of 7 days. Also initializes # the logging and caching mechanisms, setting them to # the Rails logger and cache if available. If unavailable, # sets them to active support equivalents def initialize @cache_enabled = true @cache_time_to_live = DEFAULT_CACHE_TIME_TO_LIVE @cache = defined?(Rails.cache) && Rails.cache || ActiveSupport::Cache::MemoryStore.new @logger = defined?(Rails.logger) && Rails.logger || ActiveSupport::BufferedLogger.new(StringIO.new) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
cached_resource-1.0.1 | lib/cached_resource/config.rb |