зеркало из https://github.com/github/memcached.git
at least set doesnt seg fault anymore
This commit is contained in:
Родитель
e02d1d3066
Коммит
92286126de
|
@ -5,6 +5,7 @@ if `which swig` !~ /no swig/
|
|||
end
|
||||
|
||||
require 'mkmf'
|
||||
$CFLAGS << " -ggdb -DHAVE_DEBUG"
|
||||
dir_config 'libmemcached'
|
||||
# find_header 'libmemcached/memcached.h'
|
||||
find_library 'memcached', 'memcached_server_add'
|
||||
|
|
|
@ -11,19 +11,31 @@
|
|||
|
||||
%include "typemaps.i"
|
||||
|
||||
%apply int {
|
||||
uint8_t,
|
||||
uint16_t,
|
||||
uint32_t,
|
||||
uint64_t,
|
||||
memcached_return
|
||||
};
|
||||
//%apply unsigned int {
|
||||
//// uint8_t,
|
||||
//// uint16_t,
|
||||
//// uint32_t
|
||||
//// uint64_t,
|
||||
//// memcached_return
|
||||
//};
|
||||
|
||||
%typemap(in) (char *str, int len) {
|
||||
$1 = STR2CSTR($input);
|
||||
$2 = (int) RSTRING($input)->len;
|
||||
%typemap(in) (uint8_t flags) {
|
||||
$1 = (uint8_t) NUM2UINT($input);
|
||||
};
|
||||
%apply (char* str, int len) {
|
||||
%typemap(in) (uint16_t flags) {
|
||||
$1 = (uint16_t) NUM2UINT($input);
|
||||
};
|
||||
%typemap(in) (uint32_t flags) {
|
||||
$1 = (uint32_t) NUM2ULONG($input);
|
||||
};
|
||||
%typemap(in) (uint64_t flags) {
|
||||
$1 = (uint64_t) NUM2OFFT($input);
|
||||
};
|
||||
%typemap(in) (char *str, size_t len) {
|
||||
$1 = STR2CSTR($input);
|
||||
$2 = (size_t) RSTRING($input)->len;
|
||||
};
|
||||
%apply (char* str, size_t len) {
|
||||
(char* key, size_t key_length),
|
||||
(char* value, size_t value_length)
|
||||
};
|
||||
|
@ -31,13 +43,17 @@
|
|||
//%apply size_t* INPUT {size_t* key_length}
|
||||
//%apply uint64_t* INOUT {uint64_t* value}
|
||||
//%apply void* OUTPUT {void* data}
|
||||
%apply unsigned int* OUTPUT {memcached_return* error}
|
||||
%apply unsigned int* OUTPUT {uint32_t* flags}
|
||||
%apply size_t* OUTPUT {size_t* value_length}
|
||||
//%apply unsigned int* OUTPUT {memcached_return* error}
|
||||
//%apply unsigned int* OUTPUT {uint32_t* flags}
|
||||
//%apply size_t* OUTPUT {size_t* value_length}
|
||||
//%apply memcached_st* INPUT {memcached_st* in_ptr}
|
||||
//%apply memcached_st* OUTPUT {memcached_st* out_ptr}
|
||||
|
||||
// %include "cpointer.i"
|
||||
%include "cpointer.i"
|
||||
%pointer_functions(memcached_return, memcached_returnp);
|
||||
%pointer_functions(uint32_t, uint32_tp);
|
||||
%pointer_functions(size_t, size_tp);
|
||||
|
||||
//size_t *value_length,
|
||||
// uint32_t *flags,
|
||||
// memcached_return *error
|
||||
|
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -33,9 +33,12 @@ class Memcached
|
|||
)
|
||||
end
|
||||
|
||||
def get(key, raw=false)
|
||||
value_size, flags, return_code = Libmemcached.memcached_get(@struct, key)
|
||||
check_return_code(return_code)
|
||||
def get(key, raw=false, exception=false)
|
||||
# debugger
|
||||
value_size, flags, return_code = Libmemcached.new_size_tp, Libmemcached.new_uint_32_tp, Libmemcached.new_memcached_returnp
|
||||
value = Libmemcached.memcached_get(@struct, key, value_size, flags, return_code)
|
||||
# debugger
|
||||
check_return_code(Libmemcached.memcached_returnp_value(return_code))
|
||||
value = Marshal.load(value) unless raw
|
||||
value
|
||||
end
|
||||
|
|
|
@ -1,10 +1,7 @@
|
|||
|
||||
require "#{File.dirname(__FILE__)}/../test_helper"
|
||||
|
||||
begin
|
||||
require 'ruby-debug'
|
||||
rescue LoadError
|
||||
end
|
||||
require 'ruby-debug' if ENV['DEBUG']
|
||||
|
||||
class ClassTest < Test::Unit::TestCase
|
||||
|
||||
|
@ -54,11 +51,11 @@ class ClassTest < Test::Unit::TestCase
|
|||
end
|
||||
end
|
||||
|
||||
# def test_get
|
||||
# @cache.set 'test_get', @value
|
||||
# result = @cache.get 'test_get'
|
||||
# assert_equal @value, result
|
||||
# end
|
||||
def test_get
|
||||
@cache.set 'test_get', @value
|
||||
result = @cache.get 'test_get'
|
||||
assert_equal @value, result
|
||||
end
|
||||
|
||||
#
|
||||
# def test_get_bad
|
||||
|
|
Загрузка…
Ссылка в новой задаче