This commit is contained in:
Arthur Neves 2016-03-09 09:23:45 -05:00
Родитель 52f0e841a0
Коммит 8a271ceb32
2 изменённых файлов: 30 добавлений и 31 удалений

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

@ -120,6 +120,7 @@ rb_connection_initialize(VALUE self, VALUE rb_servers)
{ {
memcached_ctx *ctx = get_ctx(self); memcached_ctx *ctx = get_ctx(self);
int i; int i;
memcached_return_t rc;
for (i = 0; i < RARRAY_LEN(rb_servers); ++i) { for (i = 0; i < RARRAY_LEN(rb_servers); ++i) {
VALUE rb_server = rb_ary_entry(rb_servers, i); VALUE rb_server = rb_ary_entry(rb_servers, i);
@ -133,13 +134,19 @@ rb_connection_initialize(VALUE self, VALUE rb_servers)
VALUE rb_port = rb_ary_entry(rb_server, 2); VALUE rb_port = rb_ary_entry(rb_server, 2);
// TODO: add weight // TODO: add weight
//VALUE rb_weight = rb_ary_entry(rb_server, 3); //VALUE rb_weight = rb_ary_entry(rb_server, 3);
memcached_server_add (ctx->memc, StringValueCStr(rb_hostname), NUM2INT(rb_port)); rc = memcached_server_add (ctx->memc, StringValueCStr(rb_hostname), NUM2INT(rb_port));
handle_memcached_return(rc);
} else if (id_socket == SYM2ID(rb_backend)) { } else if (id_socket == SYM2ID(rb_backend)) {
VALUE rb_fd = rb_ary_entry(rb_server, 1); VALUE rb_fd = rb_ary_entry(rb_server, 1);
memcached_server_add_unix_socket (ctx->memc, StringValueCStr(rb_fd)); rc = memcached_server_add_unix_socket (ctx->memc, StringValueCStr(rb_fd));
handle_memcached_return(rc);
} }
} }
// Verify keys by default
rc = memcached_behavior_set(ctx->memc, MEMCACHED_BEHAVIOR_VERIFY_KEY, true);
handle_memcached_return(rc);
return Qnil; return Qnil;
} }

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

@ -48,15 +48,15 @@ class ClientTest < BaseTest
# Error states # Error states
# def test_key_with_spaces def test_key_with_spaces
# key = "i have a space" key = "i have a space"
# #assert_raises(Memcached::ABadKeyWasProvidedOrCharactersOutOfRange) do assert_raises(Memcached::BadKeyProvided) do
# cache.set key, @value cache.set key, @value
# #end end
# #assert_raises(Memcached::ABadKeyWasProvidedOrCharactersOutOfRange) do assert_raises(Memcached::BadKeyProvided) do
# #cache.get(key) cache.get(key)
# #end end
# end end
# def test_key_with_null # def test_key_with_null
# key = "with\000null" # key = "with\000null"
@ -70,19 +70,18 @@ class ClientTest < BaseTest
# cache.get_multi([key]) # cache.get_multi([key])
# end # end
# def test_key_with_invalid_control_characters def test_key_with_invalid_control_characters
# key = "ch\303\242teau" key = "ch\303\242teau"
## assert_raises(Memcached::ABadKeyWasProvidedOrCharactersOutOfRange) do assert_raises(Memcached::BadKeyProvided) do
# cache.set key, @value cache.set key, @value
## end end
## assert_raises(Memcached::ABadKeyWasProvidedOrCharactersOutOfRange) do assert_raises(Memcached::BadKeyProvided) do
# cache.get(key) cache.get(key)
## end end
# assert_raises(Memcached::BadKeyProvided) do
## assert_raises(Memcached::ABadKeyWasProvidedOrCharactersOutOfRange) do cache.get_multi([key])
# cache.get_multi([key]) end
## end end
# end
def test_key_too_long def test_key_too_long
key = "x"*251 key = "x"*251
@ -108,13 +107,6 @@ class ClientTest < BaseTest
# end # end
# end # end
# #
# def test_key_error_message
# key = "i have a space"
# cache.get key
## rescue Memcached::ABadKeyWasProvidedOrCharactersOutOfRange => e
## assert_match /#{key}/, e.message
# end
def test_server_error_message def test_server_error_message
err = assert_raises(Memcached::E2big) do err = assert_raises(Memcached::E2big) do
cache.set key, "I'm big" * 1000000 cache.set key, "I'm big" * 1000000