This commit is contained in:
Arthur Neves 2016-03-13 23:25:54 -04:00
Родитель 38e8854700
Коммит eda665cfe4
2 изменённых файлов: 27 добавлений и 10 удалений

Просмотреть файл

@ -144,6 +144,21 @@ But it was #{servers.inspect}.
end end
def normalize_behaviors(options) def normalize_behaviors(options)
# UDP requires noreply
options[:noreply] = true if options[:use_udp]
# Buffering requires non-blocking
# FIXME This should all be wrapped up in a single :pipeline option.
options[:no_block] = true if options[:buffer_requests]
# Disallow weights without ketama
options.delete(:ketama_weighted) if options[:distribution] != :consistent_ketama
# Disallow :sort_hosts with consistent hashing
if options[:sort_hosts] && options[:distribution] == :consistent
raise ArgumentError, ":sort_hosts defeats :consistent hashing"
end
if timeout = options.delete(:timeout) if timeout = options.delete(:timeout)
options[:rcv_timeout] ||= timeout options[:rcv_timeout] ||= timeout
options[:snd_timeout] ||= timeout options[:snd_timeout] ||= timeout

Просмотреть файл

@ -88,11 +88,18 @@ class ClientInitializeTest < BaseTest
assert_raises(ArgumentError) { Memcached::Client.new "local host:43043:1" } assert_raises(ArgumentError) { Memcached::Client.new "local host:43043:1" }
end end
# def test_initialize_with_invalid_options def test_initialize_with_sort_host_and_consistent_distribution
# assert_raise(ArgumentError) do assert_raises(ArgumentError) do
# Memcached.new @servers, :sort_hosts => true, :distribution => :consistent Memcached::Client.new @servers, :sort_hosts => true, :distribution => :consistent
# end end
# end end
def test_initialize_with_invalid_options
assert_raises(ArgumentError) do
client = Memcached::Client.new @servers, foo: true
client.connection
end
end
# def test_initialize_with_invalid_prefix_key # def test_initialize_with_invalid_prefix_key
# assert_raises(ArgumentError) do # assert_raises(ArgumentError) do
@ -100,11 +107,6 @@ class ClientInitializeTest < BaseTest
# client.connection # client.connection
# end # end
# end # end
# def test_initialize_without_prefix_key
# cache = Memcached.new @servers
# assert_equal 3, cache.send(:server_structs).size
# end
# #
# def test_set_prefix_key # def test_set_prefix_key
# cache = Memcached.new @servers, :prefix_key => "foo" # cache = Memcached.new @servers, :prefix_key => "foo"