aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support
diff options
context:
space:
mode:
authorEmilio Tagua <miloops@gmail.com>2009-05-19 19:37:36 -0300
committerEmilio Tagua <miloops@gmail.com>2009-05-19 19:37:36 -0300
commitaa5512299041efb923cd582fd26009a72b9ec670 (patch)
tree4ba3cd70b4988293b99a89b72f0dbb177426a9f0 /activesupport/lib/active_support
parent1cc44599397e061901cd59233397129625839a60 (diff)
parentd8fffe7b23acce42bc3941d7bba47e07a66aed67 (diff)
downloadrails-aa5512299041efb923cd582fd26009a72b9ec670.tar.gz
rails-aa5512299041efb923cd582fd26009a72b9ec670.tar.bz2
rails-aa5512299041efb923cd582fd26009a72b9ec670.zip
Merge commit 'rails/master'
Diffstat (limited to 'activesupport/lib/active_support')
-rw-r--r--activesupport/lib/active_support/cache/mem_cache_store.rb17
1 files changed, 11 insertions, 6 deletions
diff --git a/activesupport/lib/active_support/cache/mem_cache_store.rb b/activesupport/lib/active_support/cache/mem_cache_store.rb
index 90b7526fe1..ab8eb72096 100644
--- a/activesupport/lib/active_support/cache/mem_cache_store.rb
+++ b/activesupport/lib/active_support/cache/mem_cache_store.rb
@@ -23,7 +23,12 @@ module ActiveSupport
DELETED = "DELETED\r\n"
end
- attr_reader :addresses
+ def self.build_mem_cache(*addresses)
+ addresses = addresses.flatten
+ options = addresses.extract_options!
+ addresses = ["localhost"] if addresses.empty?
+ MemCache.new(addresses, options)
+ end
# Creates a new MemCacheStore object, with the given memcached server
# addresses. Each address is either a host name, or a host-with-port string
@@ -34,11 +39,11 @@ module ActiveSupport
# If no addresses are specified, then MemCacheStore will connect to
# localhost port 11211 (the default memcached port).
def initialize(*addresses)
- addresses = addresses.flatten
- options = addresses.extract_options!
- addresses = ["localhost"] if addresses.empty?
- @addresses = addresses
- @data = MemCache.new(addresses, options)
+ if addresses.first.is_a?(MemCache)
+ @data = addresses.first
+ else
+ @data = self.class.build_mem_cache(*addresses)
+ end
extend Strategy::LocalCache
end