Permalink
Browse files

Accommodate nil server setting via ActiveSupport

see also #426
  • Loading branch information...
1 parent baecc30 commit 15bd7c8b14ee8c91d08199ac6fca964d13e0671d @jjb jjb committed Jan 14, 2014
Showing with 14 additions and 0 deletions.
  1. +2 −0 lib/active_support/cache/dalli_store.rb
  2. +12 −0 test/test_active_support.rb
@@ -54,6 +54,8 @@ def initialize(*addresses)
pool_options[:timeout] = options[:pool_timeout] if options[:pool_timeout]
@options[:compress] ||= @options[:compression]
+
+ addresses.compact!
servers = if addresses.empty?
nil # use the default from Dalli::Client
else
@@ -371,6 +371,18 @@ def cache_key
@dalli = ActiveSupport::Cache::DalliStore.new('localhost:19122', :expires_in => 1, :namespace => 'foo', :compress => true)
assert_equal 1, @dalli.instance_variable_get(:@data).instance_variable_get(:@options)[:expires_in]
assert_equal 'foo', @dalli.instance_variable_get(:@data).instance_variable_get(:@options)[:namespace]
+ assert_equal ["localhost:19122"], @dalli.instance_variable_get(:@data).instance_variable_get(:@servers)
+ end
+ end
+ end
+
+ it 'handles nil server with additional options' do
+ with_activesupport do
+ memcached do
+ @dalli = ActiveSupport::Cache::DalliStore.new(nil, :expires_in => 1, :namespace => 'foo', :compress => true)
+ assert_equal 1, @dalli.instance_variable_get(:@data).instance_variable_get(:@options)[:expires_in]
+ assert_equal 'foo', @dalli.instance_variable_get(:@data).instance_variable_get(:@options)[:namespace]
+ assert_equal ["127.0.0.1:11211"], @dalli.instance_variable_get(:@data).instance_variable_get(:@servers)
end
end
end

0 comments on commit 15bd7c8

Please sign in to comment.