Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #427 from jjb/allow-nil-server-config

Accommodate nil server setting via ActiveSupport
  • Loading branch information...
commit 8ffda360b0c12f16a2095ccbb212da40d1b82799 2 parents baecc30 + 15bd7c8
@mperham authored
View
2  lib/active_support/cache/dalli_store.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
View
12 test/test_active_support.rb
@@ -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
Please sign in to comment.
Something went wrong with that request. Please try again.