Class: ActiveSupport::Cache::SmartMemCache

Inherits:
MemCacheStore
  • Object
show all
Defined in:
lib/active_support/cache/smart_mem_cache.rb

Instance Method Summary collapse

Constructor Details

#initialize(*addresses, **args) ⇒ SmartMemCache

known options:

ActiveSupport::Cache - universal options
:coder, :compress{true}, :compress_threshold{1024}, :compressor{Zlib},
:expires_in{0}, :namespace{nil}, :race_condition_ttl{0}, :serializer{Marshal},
:skip_nil{false}, :raw{false}, :max_key_size{250}
ActiveSupport::Cache::Store
pool: {:size{5}, :timeout{5}}
ActiveSupport::Cache::MemCacheStore
:cache_nils
Dalli::Client
:failover{true}, :serializer{Marshal}, :compressor{Zlib}, :cache_nils{false}
:namespace{nil}, :expires_in{0}, :compress{false} (separate from AS::C's same options above)
:threadsafe{true} (using ConnPool turns this off automatically)


29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/active_support/cache/smart_mem_cache.rb', line 29

def initialize(*addresses, **args)
  args.reverse_merge!(
    namespace:          ENV['MEMCACHE_NAMESPACE'],
    expires_in:         1.day,
    race_condition_ttl: 5.seconds,
    failover:           true,
  )
  args[:pool] ||= {}
  args[:pool][:size] ||= Integer(ENV.fetch('RAILS_MAX_THREADS'){ 5 })
  addresses.push Array(args.delete(:url)) if addresses.empty? && args.key?(:url)
  super(*addresses, args)
end