зеркало из https://github.com/github/memcached.git
Verify keys by default
This commit is contained in:
Родитель
52f0e841a0
Коммит
8a271ceb32
|
@ -120,6 +120,7 @@ rb_connection_initialize(VALUE self, VALUE rb_servers)
|
|||
{
|
||||
memcached_ctx *ctx = get_ctx(self);
|
||||
int i;
|
||||
memcached_return_t rc;
|
||||
|
||||
for (i = 0; i < RARRAY_LEN(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);
|
||||
// TODO: add weight
|
||||
//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)) {
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
|
@ -48,15 +48,15 @@ class ClientTest < BaseTest
|
|||
|
||||
# Error states
|
||||
|
||||
# def test_key_with_spaces
|
||||
# key = "i have a space"
|
||||
# #assert_raises(Memcached::ABadKeyWasProvidedOrCharactersOutOfRange) do
|
||||
# cache.set key, @value
|
||||
# #end
|
||||
# #assert_raises(Memcached::ABadKeyWasProvidedOrCharactersOutOfRange) do
|
||||
# #cache.get(key)
|
||||
# #end
|
||||
# end
|
||||
def test_key_with_spaces
|
||||
key = "i have a space"
|
||||
assert_raises(Memcached::BadKeyProvided) do
|
||||
cache.set key, @value
|
||||
end
|
||||
assert_raises(Memcached::BadKeyProvided) do
|
||||
cache.get(key)
|
||||
end
|
||||
end
|
||||
|
||||
# def test_key_with_null
|
||||
# key = "with\000null"
|
||||
|
@ -70,19 +70,18 @@ class ClientTest < BaseTest
|
|||
# cache.get_multi([key])
|
||||
# end
|
||||
|
||||
# def test_key_with_invalid_control_characters
|
||||
# key = "ch\303\242teau"
|
||||
## assert_raises(Memcached::ABadKeyWasProvidedOrCharactersOutOfRange) do
|
||||
# cache.set key, @value
|
||||
## end
|
||||
## assert_raises(Memcached::ABadKeyWasProvidedOrCharactersOutOfRange) do
|
||||
# cache.get(key)
|
||||
## end
|
||||
#
|
||||
## assert_raises(Memcached::ABadKeyWasProvidedOrCharactersOutOfRange) do
|
||||
# cache.get_multi([key])
|
||||
## end
|
||||
# end
|
||||
def test_key_with_invalid_control_characters
|
||||
key = "ch\303\242teau"
|
||||
assert_raises(Memcached::BadKeyProvided) do
|
||||
cache.set key, @value
|
||||
end
|
||||
assert_raises(Memcached::BadKeyProvided) do
|
||||
cache.get(key)
|
||||
end
|
||||
assert_raises(Memcached::BadKeyProvided) do
|
||||
cache.get_multi([key])
|
||||
end
|
||||
end
|
||||
|
||||
def test_key_too_long
|
||||
key = "x"*251
|
||||
|
@ -108,13 +107,6 @@ class ClientTest < BaseTest
|
|||
# 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
|
||||
err = assert_raises(Memcached::E2big) do
|
||||
cache.set key, "I'm big" * 1000000
|
||||
|
|
Загрузка…
Ссылка в новой задаче