Enforce correct server_add_with_weight.

This commit is contained in:
Evan Weaver 2009-08-07 09:38:58 -07:00
Родитель 689f541a42
Коммит 4af2d8c05f
2 изменённых файлов: 3 добавлений и 9 удалений

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

@ -422,15 +422,15 @@ Please note that when pipelining is enabled, setter and deleter methods do not r
# Socket
if server.is_a?(String) and File.socket?(server)
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
elsif server.is_a?(String) and server =~ /^[\w\d\.-]+(:\d{1,5}){0,2}$/
host, port, weight = server.split(":")
args = [@struct, host, port.to_i, (weight || options[:default_weight]).to_i]
if options[:udp] #
Lib.memcached_server_add_udp_with_weight(*args)
check_return_code(Lib.memcached_server_add_udp_with_weight(*args))
else
Lib.memcached_server_add_with_weight(*args)
check_return_code(Lib.memcached_server_add_with_weight(*args))
end
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)."

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

@ -220,12 +220,6 @@ class MemcachedTest < Test::Unit::TestCase
assert_equal @value, result
end
def test_udp_get
@udp_cache.set key, @value
result = @udp_cache.get key
assert_equal @value, result
end
def test_get_nil
@cache.set key, nil, 0
result = @cache.get key