зеркало из https://github.com/github/memcached.git
initial commit of changes to eweaver's memcached gem. Possibly some junk here.
Signed-off-by: Evan <evan+fauna@cloudbur.st>
This commit is contained in:
Родитель
e157b74c54
Коммит
b84b454dc7
|
@ -7,7 +7,9 @@ if ENV['SWIG']
|
|||
puts "running SWIG"
|
||||
cmd = "swig #{INCLUDES} -ruby -autorename rlibmemcached.i"
|
||||
puts cmd
|
||||
$stdout.write `#{cmd}`
|
||||
res = `#{cmd}`
|
||||
raise "SWIG fail!" if res.match(/rlibmemcached.i:\d+: Error:/)
|
||||
$stdout.write res
|
||||
end
|
||||
|
||||
$CFLAGS << INCLUDES
|
||||
|
@ -32,6 +34,7 @@ find_library(*['memcached', 'memcached_server_add_with_weight', dir_config('libm
|
|||
raise "shared library 'libmemcached' not found"
|
||||
|
||||
[
|
||||
'libmemcached/visibility.h',
|
||||
'libmemcached/memcached.h',
|
||||
'libmemcached/memcached_constants.h',
|
||||
'libmemcached/memcached_storage.h',
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
%module rlibmemcached
|
||||
%{
|
||||
#include <libmemcached/visibility.h>
|
||||
#include <libmemcached/memcached.h>
|
||||
%}
|
||||
|
||||
|
@ -10,6 +11,7 @@
|
|||
%warnfilter(SWIGWARN_RUBY_WRONG_NAME) memcached_result_st;
|
||||
|
||||
%include "typemaps.i"
|
||||
%include "libmemcached/visibility.h"
|
||||
|
||||
// Register libmemcached's struct free function to prevent memory leaks
|
||||
%freefunc memcached_st "memcached_free";
|
||||
|
@ -22,6 +24,17 @@
|
|||
%apply unsigned long long { uint64_t data, uint64_t cas };
|
||||
|
||||
// Array of strings map for multiget
|
||||
%typemap(in) (const char **keys, size_t *key_length, size_t number_of_keys) {
|
||||
int i;
|
||||
Check_Type($input, T_ARRAY);
|
||||
$3 = (unsigned int) RARRAY_LEN($input);
|
||||
$2 = (size_t *) malloc(($3+1)*sizeof(size_t));
|
||||
$1 = (char **) malloc(($3+1)*sizeof(char *));
|
||||
for(i = 0; i < $3; i ++) {
|
||||
$2[i] = RSTRING_LEN(RARRAY_PTR($input)[i]);
|
||||
$1[i] = StringValuePtr(RARRAY_PTR($input)[i]);
|
||||
}
|
||||
}
|
||||
%typemap(in) (char **keys, size_t *key_length, unsigned int number_of_keys) {
|
||||
int i;
|
||||
Check_Type($input, T_ARRAY);
|
||||
|
@ -33,7 +46,7 @@
|
|||
$1[i] = StringValuePtr(RARRAY_PTR($input)[i]);
|
||||
}
|
||||
}
|
||||
%typemap(freearg) (char **keys, size_t *key_length, unsigned int number_of_keys) {
|
||||
%typemap(freearg) (char **keys, size_t *key_length, size_t number_of_keys) {
|
||||
free($1);
|
||||
free($2);
|
||||
}
|
||||
|
@ -108,8 +121,10 @@
|
|||
|
||||
//// SWIG includes, for functions, constants, and structs
|
||||
|
||||
%include "libmemcached/visibility.h"
|
||||
%include "libmemcached/memcached.h"
|
||||
%include "libmemcached/memcached_constants.h"
|
||||
%include "libmemcached/memcached_error.h"
|
||||
%include "libmemcached/memcached_get.h"
|
||||
%include "libmemcached/memcached_storage.h"
|
||||
%include "libmemcached/memcached_result.h"
|
||||
|
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -803,7 +803,7 @@ class MemcachedTest < Test::Unit::TestCase
|
|||
# Hit first server
|
||||
key1 = 'test_missing_server6'
|
||||
cache.set(key1, @value)
|
||||
cache.get(key1) == @value
|
||||
assert_equal cache.get(key1), @value
|
||||
|
||||
# Hit second server
|
||||
key2 = 'test_missing_server'
|
||||
|
|
Загрузка…
Ссылка в новой задаче