зеркало из https://github.com/github/memcached.git
Enforce correct server_add_with_weight.
This commit is contained in:
Родитель
689f541a42
Коммит
4af2d8c05f
|
@ -422,15 +422,15 @@ Please note that when pipelining is enabled, setter and deleter methods do not r
|
||||||
# Socket
|
# Socket
|
||||||
if server.is_a?(String) and File.socket?(server)
|
if server.is_a?(String) and File.socket?(server)
|
||||||
args = [@struct, server, options[:default_weight].to_i]
|
args = [@struct, server, options[:default_weight].to_i]
|
||||||
Lib.memcached_server_add_unix_socket_with_weight(*args)
|
check_return_code(Lib.memcached_server_add_unix_socket_with_weight(*args))
|
||||||
# Network
|
# Network
|
||||||
elsif server.is_a?(String) and server =~ /^[\w\d\.-]+(:\d{1,5}){0,2}$/
|
elsif server.is_a?(String) and server =~ /^[\w\d\.-]+(:\d{1,5}){0,2}$/
|
||||||
host, port, weight = server.split(":")
|
host, port, weight = server.split(":")
|
||||||
args = [@struct, host, port.to_i, (weight || options[:default_weight]).to_i]
|
args = [@struct, host, port.to_i, (weight || options[:default_weight]).to_i]
|
||||||
if options[:udp] #
|
if options[:udp] #
|
||||||
Lib.memcached_server_add_udp_with_weight(*args)
|
check_return_code(Lib.memcached_server_add_udp_with_weight(*args))
|
||||||
else
|
else
|
||||||
Lib.memcached_server_add_with_weight(*args)
|
check_return_code(Lib.memcached_server_add_with_weight(*args))
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
raise ArgumentError, "Servers must be either in the format 'host:port[:weight]' (e.g., 'localhost:11211' or 'localhost:11211:10') for a network server, or a valid path to a Unix domain socket (e.g., /var/run/memcached)."
|
raise ArgumentError, "Servers must be either in the format 'host:port[:weight]' (e.g., 'localhost:11211' or 'localhost:11211:10') for a network server, or a valid path to a Unix domain socket (e.g., /var/run/memcached)."
|
||||||
|
|
|
@ -220,12 +220,6 @@ class MemcachedTest < Test::Unit::TestCase
|
||||||
assert_equal @value, result
|
assert_equal @value, result
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_udp_get
|
|
||||||
@udp_cache.set key, @value
|
|
||||||
result = @udp_cache.get key
|
|
||||||
assert_equal @value, result
|
|
||||||
end
|
|
||||||
|
|
||||||
def test_get_nil
|
def test_get_nil
|
||||||
@cache.set key, nil, 0
|
@cache.set key, nil, 0
|
||||||
result = @cache.get key
|
result = @cache.get key
|
||||||
|
|
Загрузка…
Ссылка в новой задаче