This commit is contained in:
Evan Weaver 2011-02-22 16:24:26 -08:00
Родитель 6ea7af86e1
Коммит 97dedf4f8c
8 изменённых файлов: 40 добавлений и 52 удалений

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

@ -5,6 +5,7 @@ Manifest
README
Rakefile
TODO
ext/extconf-make.rb
ext/extconf.rb
ext/libmemcached-0.32.tar.gz
ext/libmemcached-2.patch
@ -21,10 +22,8 @@ lib/memcached/auth.rb
lib/memcached/behaviors.rb
lib/memcached/exceptions.rb
lib/memcached/experimental.rb
lib/memcached/integer.rb
lib/memcached/memcached.rb
lib/memcached/rails.rb
memcached.gemspec
test/profile/benchmark.rb
test/profile/profile.rb
test/profile/valgrind.rb

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

@ -90,13 +90,10 @@ end
check_libmemcached
if ENV['SWIG']
if (`swig -version`=~ /2.0.1/)
run("swig #{$defines} #{$includes} -ruby -autorename rlibmemcached.i", "Running SWIG.")
run("sed -i '' 's/STR2CSTR/StringValuePtr/' rlibmemcached_wrap.c", "Patching SWIG output for Ruby 1.9.")
run("sed -i '' 's/\"swig_runtime_data\"/\"SwigRuntimeData\"/' rlibmemcached_wrap.c", "Patching SWIG output for Ruby 1.9.")
else
raise "Swig 2.0.1 not found. Newer versions may not work."
end
puts "WARNING: Swig 2.0.2 not found. Other versions may not work." if (`swig -version`!~ /2.0.2/)
run("swig #{$defines} #{$includes} -ruby -autorename rlibmemcached.i", "Running SWIG.")
run("sed -i '' 's/STR2CSTR/StringValuePtr/' rlibmemcached_wrap.c", "Patching SWIG output for Ruby 1.9.")
run("sed -i '' 's/\"swig_runtime_data\"/\"SwigRuntimeData\"/' rlibmemcached_wrap.c", "Patching SWIG output for Ruby 1.9.")
end
$CFLAGS << " -Os"

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

@ -1,6 +1,6 @@
/* ----------------------------------------------------------------------------
* This file was automatically generated by SWIG (http://www.swig.org).
* Version 2.0.1
* Version 2.0.2
*
* This file is not intended to be easily readable and contains a number of
* coding conventions designed to improve portability and efficiency. Do not make
@ -1819,11 +1819,10 @@ int SWIG_Ruby_arity( VALUE proc, int minimal )
#define SWIGTYPE_p_p_char swig_types[27]
#define SWIGTYPE_p_sasl_callback_t swig_types[28]
#define SWIGTYPE_p_size_t swig_types[29]
#define SWIGTYPE_p_time_t swig_types[30]
#define SWIGTYPE_p_uint32_t swig_types[31]
#define SWIGTYPE_p_uint64_t swig_types[32]
static swig_type_info *swig_types[34];
static swig_module_info swig_module = {swig_types, 33, 0, 0, 0, 0};
#define SWIGTYPE_p_uint32_t swig_types[30]
#define SWIGTYPE_p_uint64_t swig_types[31]
static swig_type_info *swig_types[33];
static swig_module_info swig_module = {swig_types, 32, 0, 0, 0, 0};
#define SWIG_TypeQuery(name) SWIG_TypeQueryModule(&swig_module, &swig_module, name)
#define SWIG_MangledTypeQuery(name) SWIG_MangledTypeQueryModule(&swig_module, &swig_module, name)
@ -1838,7 +1837,7 @@ static VALUE mRlibmemcached;
#define SWIG_RUBY_THREAD_END_BLOCK
#define SWIGVERSION 0x020001
#define SWIGVERSION 0x020002
#define SWIG_VERSION SWIGVERSION
@ -1942,7 +1941,7 @@ SWIG_ruby_failed(void)
}
/*@SWIG:/opt/local/share/swig/2.0.1/ruby/rubyprimtypes.swg,19,%ruby_aux_method@*/
/*@SWIG:/opt/local/share/swig/2.0.2/ruby/rubyprimtypes.swg,19,%ruby_aux_method@*/
SWIGINTERN VALUE SWIG_AUX_NUM2DBL(VALUE *args)
{
VALUE obj = args[0];
@ -2036,7 +2035,7 @@ SWIG_AsCharArray(VALUE obj, char *val, size_t size)
}
/*@SWIG:/opt/local/share/swig/2.0.1/ruby/rubyprimtypes.swg,19,%ruby_aux_method@*/
/*@SWIG:/opt/local/share/swig/2.0.2/ruby/rubyprimtypes.swg,19,%ruby_aux_method@*/
SWIGINTERN VALUE SWIG_AUX_NUM2ULONG(VALUE *args)
{
VALUE obj = args[0];
@ -2095,7 +2094,7 @@ SWIG_From_unsigned_SS_short (unsigned short value)
}
/*@SWIG:/opt/local/share/swig/2.0.1/ruby/rubyprimtypes.swg,19,%ruby_aux_method@*/
/*@SWIG:/opt/local/share/swig/2.0.2/ruby/rubyprimtypes.swg,19,%ruby_aux_method@*/
SWIGINTERN VALUE SWIG_AUX_NUM2LONG(VALUE *args)
{
VALUE obj = args[0];
@ -2217,7 +2216,7 @@ SWIG_AsVal_unsigned_SS_int (VALUE obj, unsigned int *val)
}
/*@SWIG:/opt/local/share/swig/2.0.1/ruby/rubyprimtypes.swg,19,%ruby_aux_method@*/
/*@SWIG:/opt/local/share/swig/2.0.2/ruby/rubyprimtypes.swg,19,%ruby_aux_method@*/
SWIGINTERN VALUE SWIG_AUX_NUM2ULL(VALUE *args)
{
VALUE obj = args[0];
@ -12866,7 +12865,6 @@ static swig_type_info _swigt__p_memcached_trigger_key = {"_p_memcached_trigger_k
static swig_type_info _swigt__p_p_char = {"_p_p_char", "char **", 0, 0, (void*)0, 0};
static swig_type_info _swigt__p_sasl_callback_t = {"_p_sasl_callback_t", "sasl_callback_t *", 0, 0, (void*)0, 0};
static swig_type_info _swigt__p_size_t = {"_p_size_t", "size_t *", 0, 0, (void*)0, 0};
static swig_type_info _swigt__p_time_t = {"_p_time_t", "time_t *", 0, 0, (void*)0, 0};
static swig_type_info _swigt__p_uint32_t = {"_p_uint32_t", "uint32_t *", 0, 0, (void*)0, 0};
static swig_type_info _swigt__p_uint64_t = {"_p_uint64_t", "uint64_t *", 0, 0, (void*)0, 0};
@ -12901,7 +12899,6 @@ static swig_type_info *swig_type_initial[] = {
&_swigt__p_p_char,
&_swigt__p_sasl_callback_t,
&_swigt__p_size_t,
&_swigt__p_time_t,
&_swigt__p_uint32_t,
&_swigt__p_uint64_t,
};
@ -12936,7 +12933,6 @@ static swig_cast_info _swigc__p_memcached_trigger_key[] = { {&_swigt__p_memcach
static swig_cast_info _swigc__p_p_char[] = { {&_swigt__p_p_char, 0, 0, 0},{0, 0, 0, 0}};
static swig_cast_info _swigc__p_sasl_callback_t[] = { {&_swigt__p_sasl_callback_t, 0, 0, 0},{0, 0, 0, 0}};
static swig_cast_info _swigc__p_size_t[] = { {&_swigt__p_size_t, 0, 0, 0},{0, 0, 0, 0}};
static swig_cast_info _swigc__p_time_t[] = { {&_swigt__p_time_t, 0, 0, 0},{0, 0, 0, 0}};
static swig_cast_info _swigc__p_uint32_t[] = { {&_swigt__p_uint32_t, 0, 0, 0},{0, 0, 0, 0}};
static swig_cast_info _swigc__p_uint64_t[] = { {&_swigt__p_uint64_t, 0, 0, 0},{0, 0, 0, 0}};
@ -12971,7 +12967,6 @@ static swig_cast_info *swig_cast_initial[] = {
_swigc__p_p_char,
_swigc__p_sasl_callback_t,
_swigc__p_size_t,
_swigc__p_time_t,
_swigc__p_uint32_t,
_swigc__p_uint64_t,
};

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

@ -120,7 +120,7 @@ Please note that when <tt>:no_block => true</tt>, update methods do not raise on
end
instance_eval { send(:extend, Experimental) } if options[:experimental_features]
options[:binary_protocol] = true if options[:credentials] != nil
# Force :buffer_requests to use :no_block
@ -303,7 +303,7 @@ Please note that when <tt>:no_block => true</tt>, update methods do not raise on
# Set a key/value pair. Accepts a String <tt>key</tt> and an arbitrary Ruby object. Overwrites any existing value on the server.
#
# Accepts an optional <tt>ttl</tt> value to specify the maximum lifetime of the key on the server. <tt>ttl</tt> can be either an integer number of seconds, or a Time elapsed time object. <tt>0</tt> means no ttl. Note that there is no guarantee that the key will persist as long as the <tt>ttl</tt>, but it will not persist longer.
# Accepts an optional <tt>ttl</tt> value to specify the maximum lifetime of the key on the server, in seconds. <tt>ttl</tt> must be a <tt>FixNum</tt>. <tt>0</tt> means no ttl. Note that there is no guarantee that the key will persist as long as the <tt>ttl</tt>, but it will not persist longer.
#
# Also accepts a <tt>marshal</tt> value, which defaults to <tt>true</tt>. Set <tt>marshal</tt> to <tt>false</tt> if you want the <tt>value</tt> to be set directly.
#
@ -319,7 +319,7 @@ Please note that when <tt>:no_block => true</tt>, update methods do not raise on
retry if e.instance_of?(ClientError) && !tries
raise unless tries < options[:exception_retry_limit] && should_retry(e)
tries += 1
retry
retry
end
end
@ -335,7 +335,7 @@ Please note that when <tt>:no_block => true</tt>, update methods do not raise on
tries ||= 0
raise unless tries < options[:exception_retry_limit] && should_retry(e)
tries += 1
retry
retry
end
end
@ -352,7 +352,7 @@ Please note that when <tt>:no_block => true</tt>, update methods do not raise on
tries ||= 0
raise unless tries < options[:exception_retry_limit] && should_retry(e)
tries += 1
retry
retry
end
# Decrement a key's value. The parameters and exception behavior are the same as <tt>increment</tt>.
@ -364,7 +364,7 @@ Please note that when <tt>:no_block => true</tt>, update methods do not raise on
tries ||= 0
raise unless tries < options[:exception_retry_limit] && should_retry(e)
tries += 1
retry
retry
end
#:stopdoc:
@ -384,7 +384,7 @@ Please note that when <tt>:no_block => true</tt>, update methods do not raise on
tries ||= 0
raise unless tries < options[:exception_retry_limit] && should_retry(e)
tries += 1
retry
retry
end
end
@ -401,7 +401,7 @@ Please note that when <tt>:no_block => true</tt>, update methods do not raise on
tries ||= 0
raise unless tries < options[:exception_retry_limit] && should_retry(e)
tries += 1
retry
retry
end
# Prepends a string to a key's value. The parameters and exception behavior are the same as <tt>append</tt>.
@ -415,7 +415,7 @@ Please note that when <tt>:no_block => true</tt>, update methods do not raise on
tries ||= 0
raise unless tries < options[:exception_retry_limit] && should_retry(e)
tries += 1
retry
retry
end
# Reads a key's value from the server and yields it to a block. Replaces the key's value with the result of the block as long as the key hasn't been updated in the meantime, otherwise raises <b>Memcached::NotStored</b>. Accepts a String <tt>key</tt> and a block.
@ -434,9 +434,9 @@ Please note that when <tt>:no_block => true</tt>, update methods do not raise on
tries_for_get ||= 0
raise unless tries_for_get < options[:exception_retry_limit] && should_retry(e)
tries_for_get += 1
retry
retry
end
cas = @struct.result.cas
value = Marshal.load(value) if marshal
@ -452,7 +452,7 @@ Please note that when <tt>:no_block => true</tt>, update methods do not raise on
tries_for_cas ||= 0
raise unless tries_for_cas < options[:exception_retry_limit] && should_retry(e)
tries_for_cas += 1
retry
retry
end
end
@ -470,7 +470,7 @@ Please note that when <tt>:no_block => true</tt>, update methods do not raise on
tries ||= 0
raise unless tries < options[:exception_retry_limit] && should_retry(e)
tries += 1
retry
retry
end
# Flushes all key/value pairs from all the servers.
@ -482,7 +482,7 @@ Please note that when <tt>:no_block => true</tt>, update methods do not raise on
tries ||= 0
raise unless tries < options[:exception_retry_limit] && should_retry(e)
tries += 1
retry
retry
end
### Getters

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

@ -1,26 +1,26 @@
unless defined? UNIX_SOCKET_NAME
HERE = File.dirname(__FILE__)
UNIX_SOCKET_NAME = File.join(ENV['TMPDIR']||'/tmp','memcached')
# Kill memcached
system("killall -9 memcached")
# Start memcached
verbosity = (ENV['DEBUG'] ? "-vv" : "")
log = "/tmp/memcached.log"
system ">#{log}"
# TCP memcached
(43042..43046).each do |port|
cmd = "memcached #{verbosity} -U 0 -p #{port} >> #{log} 2>&1 &"
raise "'#{cmd}' failed to start" unless system(cmd)
end
end
# UDP memcached
(43052..43053).each do |port|
cmd = "memcached #{verbosity} -U #{port} -p 0 >> #{log} 2>&1 &"
raise "'#{cmd}' failed to start" unless system(cmd)
end
end
# Domain socket memcached
(0..1).each do |i|
cmd = "memcached -M -s #{UNIX_SOCKET_NAME}#{i} #{verbosity} >> #{log} 2>&1 &"

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

@ -3,11 +3,13 @@ $LOAD_PATH << "#{File.dirname(__FILE__)}/../lib"
require 'rubygems'
require 'mocha'
require 'socket'
require 'benchmark'
if ENV['DEBUG']
require 'ruby-debug'
require 'ruby-debug'
end
require 'memcached'
require 'test/unit'
require 'ostruct'
@ -16,3 +18,4 @@ UNIX_SOCKET_NAME = File.join(ENV['TMPDIR']||'/tmp','memcached') unless defined?
class GenericClass
end

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

@ -1,8 +1,5 @@
require File.expand_path("#{File.dirname(__FILE__)}/../test_helper")
require 'socket'
require 'mocha'
require 'benchmark'
class MemcachedExperimentalTest < Test::Unit::TestCase

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

@ -1,8 +1,5 @@
require File.expand_path("#{File.dirname(__FILE__)}/../test_helper")
require 'socket'
require 'mocha'
require 'benchmark'
class MemcachedTest < Test::Unit::TestCase