зеркало из https://github.com/github/memcached.git
Pipeline deletes and remove dead replication code. Apply prefix_key to binary protocol properly.
This commit is contained in:
Родитель
2ea7e29563
Коммит
a6e1505041
|
@ -1,4 +1,4 @@
|
||||||
v1.1.4. Apply prefix_key to binary protocol properly (tarrall). Add Memcached::Rails#exist? (ssoroka). Clean up duplicated set_prefix_key API.
|
v1.2. Clean up duplicated set_prefix_key API. Pipeline deletes and remove dead replication code. Apply prefix_key to binary protocol properly (tarrall). Add Memcached::Rails#exist? (ssoroka).
|
||||||
|
|
||||||
v1.1.3. Register new objects to fix leaks around memcached_server_st and other rich structs (tobi).
|
v1.1.3. Register new objects to fix leaks around memcached_server_st and other rich structs (tobi).
|
||||||
|
|
||||||
|
|
|
@ -32,7 +32,7 @@ end
|
||||||
def run(cmd, reason)
|
def run(cmd, reason)
|
||||||
puts reason
|
puts reason
|
||||||
puts cmd
|
puts cmd
|
||||||
raise "'#{cmd}' failed" unless system(cmd) or ENV['DEV']
|
raise "'#{cmd}' failed" unless system(cmd)
|
||||||
end
|
end
|
||||||
|
|
||||||
def check_libmemcached
|
def check_libmemcached
|
||||||
|
@ -50,11 +50,6 @@ def check_libmemcached
|
||||||
if File.exist?("lib")
|
if File.exist?("lib")
|
||||||
puts "Libmemcached already configured; run 'rake clean' first if you need to reconfigure."
|
puts "Libmemcached already configured; run 'rake clean' first if you need to reconfigure."
|
||||||
else
|
else
|
||||||
# have_sasl check may fail on OSX, skip it
|
|
||||||
# unless RUBY_PLATFORM =~ /darwin/ or have_library('sasl2')
|
|
||||||
# raise "SASL2 not found. You need the libsasl2-dev library, which should be provided through your system's package manager."
|
|
||||||
# end
|
|
||||||
|
|
||||||
system("rm -rf #{BUNDLE_PATH}") unless ENV['DEBUG'] or ENV['DEV']
|
system("rm -rf #{BUNDLE_PATH}") unless ENV['DEBUG'] or ENV['DEV']
|
||||||
run("#{TAR_CMD} xzf #{BUNDLE} 2>&1", "Building libmemcached.")
|
run("#{TAR_CMD} xzf #{BUNDLE} 2>&1", "Building libmemcached.")
|
||||||
|
|
||||||
|
@ -65,7 +60,7 @@ def check_libmemcached
|
||||||
patch("libmemcached-4", "noop hash")
|
patch("libmemcached-4", "noop hash")
|
||||||
patch("libmemcached-5", "get_len method")
|
patch("libmemcached-5", "get_len method")
|
||||||
patch("libmemcached-6", "failure count bug")
|
patch("libmemcached-6", "failure count bug")
|
||||||
patch("libmemcached-7", "pipelined delete")
|
patch("libmemcached-7", "pipelined delete and unused replica code")
|
||||||
|
|
||||||
run("touch -r #{BUNDLE_PATH}/m4/visibility.m4 #{BUNDLE_PATH}/configure.ac #{BUNDLE_PATH}/m4/pandora_have_sasl.m4", "Touching aclocal.m4 in libmemcached.")
|
run("touch -r #{BUNDLE_PATH}/m4/visibility.m4 #{BUNDLE_PATH}/configure.ac #{BUNDLE_PATH}/m4/pandora_have_sasl.m4", "Touching aclocal.m4 in libmemcached.")
|
||||||
|
|
||||||
|
@ -78,7 +73,7 @@ def check_libmemcached
|
||||||
#Running the make command in another script invoked by another shell command solves the "cd ." issue on FreeBSD 6+
|
#Running the make command in another script invoked by another shell command solves the "cd ." issue on FreeBSD 6+
|
||||||
run("GMAKE_CMD='#{GMAKE_CMD}' CXXFLAGS='#{$CXXFLAGS}' SOURCE_DIR='#{BUNDLE_PATH}' HERE='#{HERE}' ruby ../extconf-make.rb", "Making libmemcached.")
|
run("GMAKE_CMD='#{GMAKE_CMD}' CXXFLAGS='#{$CXXFLAGS}' SOURCE_DIR='#{BUNDLE_PATH}' HERE='#{HERE}' ruby ../extconf-make.rb", "Making libmemcached.")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# Absolutely prevent the linker from picking up any other libmemcached
|
# Absolutely prevent the linker from picking up any other libmemcached
|
||||||
Dir.chdir("#{HERE}/lib") do
|
Dir.chdir("#{HERE}/lib") do
|
||||||
|
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -6466,67 +6466,6 @@ fail:
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
SWIGINTERN VALUE
|
|
||||||
_wrap_MemcachedSt_number_of_replicas_set(int argc, VALUE *argv, VALUE self) {
|
|
||||||
struct memcached_st *arg1 = (struct memcached_st *) 0 ;
|
|
||||||
uint32_t arg2 ;
|
|
||||||
void *argp1 = 0 ;
|
|
||||||
int res1 = 0 ;
|
|
||||||
void *argp2 ;
|
|
||||||
int res2 = 0 ;
|
|
||||||
|
|
||||||
if ((argc < 1) || (argc > 1)) {
|
|
||||||
rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail;
|
|
||||||
}
|
|
||||||
res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_memcached_st, 0 | 0 );
|
|
||||||
if (!SWIG_IsOK(res1)) {
|
|
||||||
SWIG_exception_fail(SWIG_ArgError(res1), Ruby_Format_TypeError( "", "struct memcached_st *","number_of_replicas", 1, self ));
|
|
||||||
}
|
|
||||||
arg1 = (struct memcached_st *)(argp1);
|
|
||||||
{
|
|
||||||
res2 = SWIG_ConvertPtr(argv[0], &argp2, SWIGTYPE_p_uint32_t, 0 );
|
|
||||||
if (!SWIG_IsOK(res2)) {
|
|
||||||
SWIG_exception_fail(SWIG_ArgError(res2), Ruby_Format_TypeError( "", "uint32_t","number_of_replicas", 2, argv[0] ));
|
|
||||||
}
|
|
||||||
if (!argp2) {
|
|
||||||
SWIG_exception_fail(SWIG_ValueError, Ruby_Format_TypeError("invalid null reference ", "uint32_t","number_of_replicas", 2, argv[0]));
|
|
||||||
} else {
|
|
||||||
arg2 = *((uint32_t *)(argp2));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (arg1) (arg1)->number_of_replicas = arg2;
|
|
||||||
return Qnil;
|
|
||||||
fail:
|
|
||||||
return Qnil;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
SWIGINTERN VALUE
|
|
||||||
_wrap_MemcachedSt_number_of_replicas_get(int argc, VALUE *argv, VALUE self) {
|
|
||||||
struct memcached_st *arg1 = (struct memcached_st *) 0 ;
|
|
||||||
void *argp1 = 0 ;
|
|
||||||
int res1 = 0 ;
|
|
||||||
uint32_t result;
|
|
||||||
VALUE vresult = Qnil;
|
|
||||||
|
|
||||||
if ((argc < 0) || (argc > 0)) {
|
|
||||||
rb_raise(rb_eArgError, "wrong # of arguments(%d for 0)",argc); SWIG_fail;
|
|
||||||
}
|
|
||||||
res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_memcached_st, 0 | 0 );
|
|
||||||
if (!SWIG_IsOK(res1)) {
|
|
||||||
SWIG_exception_fail(SWIG_ArgError(res1), Ruby_Format_TypeError( "", "struct memcached_st *","number_of_replicas", 1, self ));
|
|
||||||
}
|
|
||||||
arg1 = (struct memcached_st *)(argp1);
|
|
||||||
result = ((arg1)->number_of_replicas);
|
|
||||||
{
|
|
||||||
vresult = UINT2NUM(result);
|
|
||||||
}
|
|
||||||
return vresult;
|
|
||||||
fail:
|
|
||||||
return Qnil;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
SWIGINTERN VALUE
|
SWIGINTERN VALUE
|
||||||
_wrap_MemcachedSt_number_of_live_hosts_set(int argc, VALUE *argv, VALUE self) {
|
_wrap_MemcachedSt_number_of_live_hosts_set(int argc, VALUE *argv, VALUE self) {
|
||||||
struct memcached_st *arg1 = (struct memcached_st *) 0 ;
|
struct memcached_st *arg1 = (struct memcached_st *) 0 ;
|
||||||
|
@ -13350,8 +13289,6 @@ SWIGEXPORT void Init_rlibmemcached(void) {
|
||||||
rb_define_method(SwigClassMemcachedSt.klass, "delete_trigger", _wrap_MemcachedSt_delete_trigger_get, -1);
|
rb_define_method(SwigClassMemcachedSt.klass, "delete_trigger", _wrap_MemcachedSt_delete_trigger_get, -1);
|
||||||
rb_define_method(SwigClassMemcachedSt.klass, "prefix_key=", _wrap_MemcachedSt_prefix_key_set, -1);
|
rb_define_method(SwigClassMemcachedSt.klass, "prefix_key=", _wrap_MemcachedSt_prefix_key_set, -1);
|
||||||
rb_define_method(SwigClassMemcachedSt.klass, "prefix_key", _wrap_MemcachedSt_prefix_key_get, -1);
|
rb_define_method(SwigClassMemcachedSt.klass, "prefix_key", _wrap_MemcachedSt_prefix_key_get, -1);
|
||||||
rb_define_method(SwigClassMemcachedSt.klass, "number_of_replicas=", _wrap_MemcachedSt_number_of_replicas_set, -1);
|
|
||||||
rb_define_method(SwigClassMemcachedSt.klass, "number_of_replicas", _wrap_MemcachedSt_number_of_replicas_get, -1);
|
|
||||||
rb_define_method(SwigClassMemcachedSt.klass, "number_of_live_hosts=", _wrap_MemcachedSt_number_of_live_hosts_set, -1);
|
rb_define_method(SwigClassMemcachedSt.klass, "number_of_live_hosts=", _wrap_MemcachedSt_number_of_live_hosts_set, -1);
|
||||||
rb_define_method(SwigClassMemcachedSt.klass, "number_of_live_hosts", _wrap_MemcachedSt_number_of_live_hosts_get, -1);
|
rb_define_method(SwigClassMemcachedSt.klass, "number_of_live_hosts", _wrap_MemcachedSt_number_of_live_hosts_get, -1);
|
||||||
rb_define_method(SwigClassMemcachedSt.klass, "live_host_indices=", _wrap_MemcachedSt_live_host_indices_set, -1);
|
rb_define_method(SwigClassMemcachedSt.klass, "live_host_indices=", _wrap_MemcachedSt_live_host_indices_set, -1);
|
||||||
|
@ -13498,7 +13435,6 @@ SWIGEXPORT void Init_rlibmemcached(void) {
|
||||||
rb_define_const(mRlibmemcached, "MEMCACHED_BEHAVIOR_NOREPLY", SWIG_From_int((int)(MEMCACHED_BEHAVIOR_NOREPLY)));
|
rb_define_const(mRlibmemcached, "MEMCACHED_BEHAVIOR_NOREPLY", SWIG_From_int((int)(MEMCACHED_BEHAVIOR_NOREPLY)));
|
||||||
rb_define_const(mRlibmemcached, "MEMCACHED_BEHAVIOR_USE_UDP", SWIG_From_int((int)(MEMCACHED_BEHAVIOR_USE_UDP)));
|
rb_define_const(mRlibmemcached, "MEMCACHED_BEHAVIOR_USE_UDP", SWIG_From_int((int)(MEMCACHED_BEHAVIOR_USE_UDP)));
|
||||||
rb_define_const(mRlibmemcached, "MEMCACHED_BEHAVIOR_AUTO_EJECT_HOSTS", SWIG_From_int((int)(MEMCACHED_BEHAVIOR_AUTO_EJECT_HOSTS)));
|
rb_define_const(mRlibmemcached, "MEMCACHED_BEHAVIOR_AUTO_EJECT_HOSTS", SWIG_From_int((int)(MEMCACHED_BEHAVIOR_AUTO_EJECT_HOSTS)));
|
||||||
rb_define_const(mRlibmemcached, "MEMCACHED_BEHAVIOR_NUMBER_OF_REPLICAS", SWIG_From_int((int)(MEMCACHED_BEHAVIOR_NUMBER_OF_REPLICAS)));
|
|
||||||
rb_define_const(mRlibmemcached, "MEMCACHED_CALLBACK_PREFIX_KEY", SWIG_From_int((int)(MEMCACHED_CALLBACK_PREFIX_KEY)));
|
rb_define_const(mRlibmemcached, "MEMCACHED_CALLBACK_PREFIX_KEY", SWIG_From_int((int)(MEMCACHED_CALLBACK_PREFIX_KEY)));
|
||||||
rb_define_const(mRlibmemcached, "MEMCACHED_CALLBACK_USER_DATA", SWIG_From_int((int)(MEMCACHED_CALLBACK_USER_DATA)));
|
rb_define_const(mRlibmemcached, "MEMCACHED_CALLBACK_USER_DATA", SWIG_From_int((int)(MEMCACHED_CALLBACK_USER_DATA)));
|
||||||
rb_define_const(mRlibmemcached, "MEMCACHED_CALLBACK_CLEANUP_FUNCTION", SWIG_From_int((int)(MEMCACHED_CALLBACK_CLEANUP_FUNCTION)));
|
rb_define_const(mRlibmemcached, "MEMCACHED_CALLBACK_CLEANUP_FUNCTION", SWIG_From_int((int)(MEMCACHED_CALLBACK_CLEANUP_FUNCTION)));
|
||||||
|
|
|
@ -70,7 +70,7 @@ Weights only affect Ketama hashing. If you use Ketama hashing and don't specify
|
||||||
Valid option parameters are:
|
Valid option parameters are:
|
||||||
|
|
||||||
<tt>:prefix_key</tt>:: A string to prepend to every key, for namespacing. Max length is 127. Defaults to the empty string.
|
<tt>:prefix_key</tt>:: A string to prepend to every key, for namespacing. Max length is 127. Defaults to the empty string.
|
||||||
<tt>:prefix_delimiter</tt>:: A character to postpend to the prefix key. Defaults to the empty string.
|
<tt>:prefix_delimiter</tt>:: A character to append to the prefix key. Defaults to the empty string.
|
||||||
<tt>:hash</tt>:: The name of a hash function to use. Possible values are: <tt>:crc</tt>, <tt>:default</tt>, <tt>:fnv1_32</tt>, <tt>:fnv1_64</tt>, <tt>:fnv1a_32</tt>, <tt>:fnv1a_64</tt>, <tt>:hsieh</tt>, <tt>:md5</tt>, <tt>:murmur</tt>, and <tt>:none</tt>. <tt>:fnv1_32</tt> is fast and well known, and is the default. Use <tt>:md5</tt> for compatibility with other ketama clients. <tt>:none</tt> is for use when there is a single server, and performs no actual hashing.
|
<tt>:hash</tt>:: The name of a hash function to use. Possible values are: <tt>:crc</tt>, <tt>:default</tt>, <tt>:fnv1_32</tt>, <tt>:fnv1_64</tt>, <tt>:fnv1a_32</tt>, <tt>:fnv1a_64</tt>, <tt>:hsieh</tt>, <tt>:md5</tt>, <tt>:murmur</tt>, and <tt>:none</tt>. <tt>:fnv1_32</tt> is fast and well known, and is the default. Use <tt>:md5</tt> for compatibility with other ketama clients. <tt>:none</tt> is for use when there is a single server, and performs no actual hashing.
|
||||||
<tt>:distribution</tt>:: Either <tt>:modula</tt>, <tt>:consistent_ketama</tt>, <tt>:consistent_wheel</tt>, or <tt>:ketama</tt>. Defaults to <tt>:ketama</tt>.
|
<tt>:distribution</tt>:: Either <tt>:modula</tt>, <tt>:consistent_ketama</tt>, <tt>:consistent_wheel</tt>, or <tt>:ketama</tt>. Defaults to <tt>:ketama</tt>.
|
||||||
<tt>:server_failure_limit</tt>:: How many consecutive failures to allow before marking a host as dead. Has no effect unless <tt>:retry_timeout</tt> is also set.
|
<tt>:server_failure_limit</tt>:: How many consecutive failures to allow before marking a host as dead. Has no effect unless <tt>:retry_timeout</tt> is also set.
|
||||||
|
|
|
@ -13,21 +13,24 @@ class MemcachedTest < Test::Unit::TestCase
|
||||||
@options = {
|
@options = {
|
||||||
:prefix_key => @prefix_key,
|
:prefix_key => @prefix_key,
|
||||||
:hash => :default,
|
:hash => :default,
|
||||||
:distribution => :modula}
|
:distribution => :modula,
|
||||||
|
:show_backtraces => true}
|
||||||
@cache = Memcached.new(@servers, @options)
|
@cache = Memcached.new(@servers, @options)
|
||||||
|
|
||||||
@binary_protocol_options = {
|
@binary_protocol_options = {
|
||||||
:prefix_key => @prefix_key,
|
:prefix_key => @prefix_key,
|
||||||
:hash => :default,
|
:hash => :default,
|
||||||
:distribution => :modula,
|
:distribution => :modula,
|
||||||
:binary_protocol => true}
|
:binary_protocol => true,
|
||||||
|
:show_backtraces => true}
|
||||||
@binary_protocol_cache = Memcached.new(@servers, @binary_protocol_options)
|
@binary_protocol_cache = Memcached.new(@servers, @binary_protocol_options)
|
||||||
|
|
||||||
@udp_options = {
|
@udp_options = {
|
||||||
:prefix_key => @prefix_key,
|
:prefix_key => @prefix_key,
|
||||||
:hash => :default,
|
:hash => :default,
|
||||||
:use_udp => true,
|
:use_udp => true,
|
||||||
:distribution => :modula}
|
:distribution => :modula,
|
||||||
|
:show_backtraces => true}
|
||||||
@udp_cache = Memcached.new(@udp_servers, @udp_options)
|
@udp_cache = Memcached.new(@udp_servers, @udp_options)
|
||||||
|
|
||||||
@noblock_options = {
|
@noblock_options = {
|
||||||
|
@ -36,7 +39,8 @@ class MemcachedTest < Test::Unit::TestCase
|
||||||
:noreply => true,
|
:noreply => true,
|
||||||
:buffer_requests => true,
|
:buffer_requests => true,
|
||||||
:hash => :default,
|
:hash => :default,
|
||||||
:distribution => :modula}
|
:distribution => :modula,
|
||||||
|
:show_backtraces => true}
|
||||||
@noblock_cache = Memcached.new(@servers, @noblock_options)
|
@noblock_cache = Memcached.new(@servers, @noblock_options)
|
||||||
|
|
||||||
@value = OpenStruct.new(:a => 1, :b => 2, :c => GenericClass)
|
@value = OpenStruct.new(:a => 1, :b => 2, :c => GenericClass)
|
||||||
|
@ -512,6 +516,12 @@ class MemcachedTest < Test::Unit::TestCase
|
||||||
assert_raise(Memcached::NotFound) do
|
assert_raise(Memcached::NotFound) do
|
||||||
@cache.get key
|
@cache.get key
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@binary_protocol_cache.set key, @value
|
||||||
|
@binary_protocol_cache.delete key
|
||||||
|
assert_raise(Memcached::NotFound) do
|
||||||
|
@binary_protocol_cache.get key
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_missing_delete
|
def test_missing_delete
|
||||||
|
@ -812,7 +822,7 @@ class MemcachedTest < Test::Unit::TestCase
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# Non-blocking IO
|
# Pipelined, non-blocking IO
|
||||||
|
|
||||||
def test_buffered_requests_return_value
|
def test_buffered_requests_return_value
|
||||||
cache = Memcached.new @servers,
|
cache = Memcached.new @servers,
|
||||||
|
@ -861,9 +871,10 @@ class MemcachedTest < Test::Unit::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_no_block_missing_delete
|
def test_no_block_missing_delete
|
||||||
@noblock_cache.delete key rescue nil
|
@noblock_cache.delete key rescue nil
|
||||||
assert_nothing_raised do
|
assert_nothing_raised do
|
||||||
@noblock_cache.delete key
|
@noblock_cache.delete key
|
||||||
|
@noblock_cache.delete key
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче