mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Support options passed to ActiveSupport::Cache :mem_cache_store [#14 state:resolved]
Signed-off-by: Joshua Peek <josh@joshpeek.com>
This commit is contained in:
parent
9e53b63601
commit
9e1d506a8c
2 changed files with 15 additions and 1 deletions
|
@ -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)
|
||||
|
|
|
@ -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")
|
||||
|
|
Loading…
Reference in a new issue