mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Raise if MemCacheStore doenst receive a Dalli obj
:mem_cache_store should receive a list of hosts or a dalli client, otherwise raise it. Also adding a changelog.
This commit is contained in:
parent
98458eea42
commit
e7f56a7fe8
3 changed files with 15 additions and 0 deletions
|
@ -1,3 +1,7 @@
|
||||||
|
* MemCacheStore should only accept a Dalli::Client, or create one.
|
||||||
|
|
||||||
|
*arthurnn*
|
||||||
|
|
||||||
* Don't lazy load the `tzinfo` library as it causes problems on Windows.
|
* Don't lazy load the `tzinfo` library as it causes problems on Windows.
|
||||||
|
|
||||||
Fixes #13553
|
Fixes #13553
|
||||||
|
|
|
@ -46,6 +46,9 @@ module ActiveSupport
|
||||||
options = addresses.extract_options!
|
options = addresses.extract_options!
|
||||||
super(options)
|
super(options)
|
||||||
|
|
||||||
|
unless [String, Dalli::Client, NilClass].include?(addresses.first.class)
|
||||||
|
raise ArgumentError, "First argument must be an empty array, an array of hosts or a Dalli::Client instance."
|
||||||
|
end
|
||||||
if addresses.first.is_a?(Dalli::Client)
|
if addresses.first.is_a?(Dalli::Client)
|
||||||
@data = addresses.first
|
@data = addresses.first
|
||||||
else
|
else
|
||||||
|
|
|
@ -110,6 +110,14 @@ class CacheStoreSettingTest < ActiveSupport::TestCase
|
||||||
assert_kind_of(ActiveSupport::Cache::MemCacheStore, store)
|
assert_kind_of(ActiveSupport::Cache::MemCacheStore, store)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_mem_cache_fragment_cache_store_with_not_dalli_client
|
||||||
|
Dalli::Client.expects(:new).never
|
||||||
|
memcache = Object.new
|
||||||
|
assert_raises(ArgumentError) do
|
||||||
|
ActiveSupport::Cache.lookup_store :mem_cache_store, memcache
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def test_mem_cache_fragment_cache_store_with_multiple_servers
|
def test_mem_cache_fragment_cache_store_with_multiple_servers
|
||||||
Dalli::Client.expects(:new).with(%w[localhost 192.168.1.1], {})
|
Dalli::Client.expects(:new).with(%w[localhost 192.168.1.1], {})
|
||||||
store = ActiveSupport::Cache.lookup_store :mem_cache_store, "localhost", '192.168.1.1'
|
store = ActiveSupport::Cache.lookup_store :mem_cache_store, "localhost", '192.168.1.1'
|
||||||
|
|
Loading…
Reference in a new issue