Method: ActiveSupport::Cache::RedisCache#initialize
- Defined in:
- lib/redis_cache.rb
#initialize(*addresses) ⇒ RedisCache
Creates a new RedisCache object, with the given redis server addresses. Each address is either a host name, or a host-with-port string in the form of “redis://host_name:port”. For example:
ActiveSupport::Cache::RedisCache.new("localhost", "server-downstairs.localnetwork:8229")
If no addresses are specified, then MemCacheStore will connect to localhost port 11211 (the default memcached port).
Instead of addresses one can pass in a MemCache-like object. For example:
require 'redis' # gem install redis;
ActiveSupport::Cache::RedisCache.new(Redis.connect(:url => "redis://localhost:6380/1"))
39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/redis_cache.rb', line 39 def initialize(*addresses) if addresses.empty? @data = Redis.connect elsif addresses.size == 1 @data = Redis.connect :url => "redis://#{addresses.first}" else @data = self.class.build_redis_cache(*addresses) end extend Strategy::LocalCache end |