aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport
diff options
context:
space:
mode:
authorjweiss <jweiss@blowfish.local>2008-04-17 12:58:31 -0500
committerJoshua Peek <josh@joshpeek.com>2008-04-17 12:58:31 -0500
commit9e1d506a8cfedef2fdd605e4cbf4bf53651ad214 (patch)
treebb68f6da2b3425008fdab9905555dd813d42756a /activesupport
parent9e53b63601ce12fb7e4c8fdb16d5706ea8609d2f (diff)
downloadrails-9e1d506a8cfedef2fdd605e4cbf4bf53651ad214.tar.gz
rails-9e1d506a8cfedef2fdd605e4cbf4bf53651ad214.tar.bz2
rails-9e1d506a8cfedef2fdd605e4cbf4bf53651ad214.zip
Support options passed to ActiveSupport::Cache :mem_cache_store [#14 state:resolved]
Signed-off-by: Joshua Peek <josh@joshpeek.com>
Diffstat (limited to 'activesupport')
-rw-r--r--activesupport/lib/active_support/cache/mem_cache_store.rb3
-rw-r--r--activesupport/test/caching_test.rb13
2 files changed, 15 insertions, 1 deletions
diff --git a/activesupport/lib/active_support/cache/mem_cache_store.rb b/activesupport/lib/active_support/cache/mem_cache_store.rb
index 88e324aa3a..9b787702b2 100644
--- a/activesupport/lib/active_support/cache/mem_cache_store.rb
+++ b/activesupport/lib/active_support/cache/mem_cache_store.rb
@@ -15,9 +15,10 @@ module ActiveSupport
def initialize(*addresses)
addresses = addresses.flatten
+ options = addresses.extract_options!
addresses = ["localhost"] if addresses.empty?
@addresses = addresses
- @data = MemCache.new(addresses)
+ @data = MemCache.new(addresses, options)
end
def read(key, options = nil)
diff --git a/activesupport/test/caching_test.rb b/activesupport/test/caching_test.rb
index a038f29f53..09b56525e0 100644
--- a/activesupport/test/caching_test.rb
+++ b/activesupport/test/caching_test.rb
@@ -18,6 +18,19 @@ class CacheStoreSettingTest < Test::Unit::TestCase
assert_kind_of(ActiveSupport::Cache::MemCacheStore, store)
assert_equal %w(localhost), store.addresses
end
+
+ def test_mem_cache_fragment_cache_store_with_multiple_servers
+ store = ActiveSupport::Cache.lookup_store :mem_cache_store, "localhost", '192.168.1.1'
+ assert_kind_of(ActiveSupport::Cache::MemCacheStore, store)
+ assert_equal %w(localhost 192.168.1.1), store.addresses
+ end
+
+ def test_mem_cache_fragment_cache_store_with_options
+ store = ActiveSupport::Cache.lookup_store :mem_cache_store, "localhost", '192.168.1.1', :namespace => 'foo'
+ assert_kind_of(ActiveSupport::Cache::MemCacheStore, store)
+ assert_equal %w(localhost 192.168.1.1), store.addresses
+ assert_equal 'foo', store.instance_variable_get('@data').instance_variable_get('@namespace')
+ end
def test_object_assigned_fragment_cache_store
store = ActiveSupport::Cache.lookup_store ActiveSupport::Cache::FileStore.new("/path/to/cache/directory")