memcached 1.2.6 → 1.2.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGELOG +2 -0
- data/Manifest +206 -12
- data/Rakefile +32 -1
- data/ext/extconf.rb +10 -35
- data/ext/libmemcached-0.32/AUTHORS +7 -0
- data/ext/libmemcached-0.32/COPYING +32 -0
- data/ext/libmemcached-0.32/ChangeLog +303 -0
- data/ext/libmemcached-0.32/INSTALL +302 -0
- data/ext/libmemcached-0.32/Makefile.am +36 -0
- data/ext/libmemcached-0.32/Makefile.in +828 -0
- data/ext/libmemcached-0.32/NEWS +1 -0
- data/ext/libmemcached-0.32/README +33 -0
- data/ext/libmemcached-0.32/THANKS +14 -0
- data/ext/libmemcached-0.32/TODO +11 -0
- data/ext/libmemcached-0.32/aclocal.m4 +1852 -0
- data/ext/libmemcached-0.32/clients/Makefile.am +73 -0
- data/ext/libmemcached-0.32/clients/Makefile.in +770 -0
- data/ext/libmemcached-0.32/clients/client_options.h +32 -0
- data/ext/libmemcached-0.32/clients/execute.c +64 -0
- data/ext/libmemcached-0.32/clients/execute.h +5 -0
- data/ext/libmemcached-0.32/clients/generator.c +74 -0
- data/ext/libmemcached-0.32/clients/generator.h +20 -0
- data/ext/libmemcached-0.32/clients/memcat.c +178 -0
- data/ext/libmemcached-0.32/clients/memcp.c +251 -0
- data/ext/libmemcached-0.32/clients/memdump.c +170 -0
- data/ext/libmemcached-0.32/clients/memerror.c +80 -0
- data/ext/libmemcached-0.32/clients/memflush.c +143 -0
- data/ext/libmemcached-0.32/clients/memrm.c +160 -0
- data/ext/libmemcached-0.32/clients/memslap.c +441 -0
- data/ext/libmemcached-0.32/clients/memstat.c +326 -0
- data/ext/libmemcached-0.32/clients/utilities.c +207 -0
- data/ext/libmemcached-0.32/clients/utilities.h +41 -0
- data/ext/libmemcached-0.32/config.h.in +252 -0
- data/ext/libmemcached-0.32/config/compile +143 -0
- data/ext/libmemcached-0.32/config/config.guess +1561 -0
- data/ext/libmemcached-0.32/config/config.rpath +666 -0
- data/ext/libmemcached-0.32/config/config.sub +1686 -0
- data/ext/libmemcached-0.32/config/depcomp +630 -0
- data/ext/libmemcached-0.32/config/install-sh +520 -0
- data/ext/libmemcached-0.32/config/ltmain.sh +8406 -0
- data/ext/libmemcached-0.32/config/missing +376 -0
- data/ext/libmemcached-0.32/configure +23048 -0
- data/ext/libmemcached-0.32/configure.ac +122 -0
- data/ext/libmemcached-0.32/docs/Makefile.am +415 -0
- data/ext/libmemcached-0.32/docs/Makefile.in +918 -0
- data/ext/libmemcached-0.32/docs/libmemcached.pod +123 -0
- data/ext/libmemcached-0.32/docs/libmemcached_examples.pod +115 -0
- data/ext/libmemcached-0.32/docs/libmemcachedutil.pod +40 -0
- data/ext/libmemcached-0.32/docs/memcached_analyze.pod +52 -0
- data/ext/libmemcached-0.32/docs/memcached_auto.pod +97 -0
- data/ext/libmemcached-0.32/docs/memcached_behavior.pod +224 -0
- data/ext/libmemcached-0.32/docs/memcached_callback.pod +123 -0
- data/ext/libmemcached-0.32/docs/memcached_create.pod +61 -0
- data/ext/libmemcached-0.32/docs/memcached_delete.pod +54 -0
- data/ext/libmemcached-0.32/docs/memcached_dump.pod +53 -0
- data/ext/libmemcached-0.32/docs/memcached_flush.pod +46 -0
- data/ext/libmemcached-0.32/docs/memcached_flush_buffers.pod +42 -0
- data/ext/libmemcached-0.32/docs/memcached_generate_hash_value.pod +57 -0
- data/ext/libmemcached-0.32/docs/memcached_get.pod +161 -0
- data/ext/libmemcached-0.32/docs/memcached_memory_allocators.pod +73 -0
- data/ext/libmemcached-0.32/docs/memcached_pool.pod +77 -0
- data/ext/libmemcached-0.32/docs/memcached_quit.pod +47 -0
- data/ext/libmemcached-0.32/docs/memcached_sasl.pod +63 -0
- data/ext/libmemcached-0.32/docs/memcached_server_st.pod +75 -0
- data/ext/libmemcached-0.32/docs/memcached_servers.pod +102 -0
- data/ext/libmemcached-0.32/docs/memcached_set.pod +187 -0
- data/ext/libmemcached-0.32/docs/memcached_stats.pod +82 -0
- data/ext/libmemcached-0.32/docs/memcached_strerror.pod +46 -0
- data/ext/libmemcached-0.32/docs/memcached_user_data.pod +49 -0
- data/ext/libmemcached-0.32/docs/memcached_verbosity.pod +41 -0
- data/ext/libmemcached-0.32/docs/memcached_version.pod +56 -0
- data/ext/libmemcached-0.32/docs/memcat.pod +37 -0
- data/ext/libmemcached-0.32/docs/memcp.pod +40 -0
- data/ext/libmemcached-0.32/docs/memdump.pod +31 -0
- data/ext/libmemcached-0.32/docs/memerror.pod +30 -0
- data/ext/libmemcached-0.32/docs/memflush.pod +35 -0
- data/ext/libmemcached-0.32/docs/memrm.pod +34 -0
- data/ext/libmemcached-0.32/docs/memslap.pod +33 -0
- data/ext/libmemcached-0.32/docs/memstat.pod +35 -0
- data/ext/libmemcached-0.32/libmemcached/Makefile.am +107 -0
- data/ext/libmemcached-0.32/libmemcached/Makefile.in +1050 -0
- data/ext/libmemcached-0.32/libmemcached/byteorder.c +31 -0
- data/ext/libmemcached-0.32/libmemcached/common.h +183 -0
- data/ext/libmemcached-0.32/libmemcached/crc.c +86 -0
- data/ext/libmemcached-0.32/libmemcached/hsieh_hash.c +68 -0
- data/ext/libmemcached-0.32/libmemcached/jenkins_hash.c +213 -0
- data/ext/libmemcached-0.32/libmemcached/libmemcached.ver +1 -0
- data/ext/libmemcached-0.32/libmemcached/libmemcached_probes.d +28 -0
- data/ext/libmemcached-0.32/libmemcached/libmemcached_probes.h +78 -0
- data/ext/libmemcached-0.32/libmemcached/md5.c +354 -0
- data/ext/libmemcached-0.32/libmemcached/memcached.c +152 -0
- data/ext/libmemcached-0.32/libmemcached/memcached.h +302 -0
- data/ext/libmemcached-0.32/libmemcached/memcached.hpp +799 -0
- data/ext/libmemcached-0.32/libmemcached/memcached/README.txt +7 -0
- data/ext/libmemcached-0.32/libmemcached/memcached/protocol_binary.h +366 -0
- data/ext/libmemcached-0.32/libmemcached/memcached_allocators.c +72 -0
- data/ext/libmemcached-0.32/libmemcached/memcached_analyze.c +100 -0
- data/ext/libmemcached-0.32/libmemcached/memcached_auto.c +207 -0
- data/ext/libmemcached-0.32/libmemcached/memcached_behavior.c +285 -0
- data/ext/libmemcached-0.32/libmemcached/memcached_callback.c +175 -0
- data/ext/libmemcached-0.32/libmemcached/memcached_configure.h.in +23 -0
- data/ext/libmemcached-0.32/libmemcached/memcached_connect.c +361 -0
- data/ext/libmemcached-0.32/libmemcached/memcached_constants.h +145 -0
- data/ext/libmemcached-0.32/libmemcached/memcached_delete.c +0 -0
- data/ext/libmemcached-0.32/libmemcached/memcached_do.c +34 -0
- data/ext/libmemcached-0.32/libmemcached/memcached_dump.c +79 -0
- data/ext/libmemcached-0.32/libmemcached/memcached_fetch.c +102 -0
- data/ext/libmemcached-0.32/libmemcached/memcached_flush.c +89 -0
- data/ext/libmemcached-0.32/libmemcached/memcached_flush_buffers.c +22 -0
- data/ext/libmemcached-0.32/libmemcached/memcached_get.c +495 -0
- data/ext/libmemcached-0.32/libmemcached/memcached_get.h +87 -0
- data/ext/libmemcached-0.32/libmemcached/memcached_hash.c +252 -0
- data/ext/libmemcached-0.32/libmemcached/memcached_hosts.c +510 -0
- data/ext/libmemcached-0.32/libmemcached/memcached_internal.h +31 -0
- data/ext/libmemcached-0.32/libmemcached/memcached_io.c +547 -0
- data/ext/libmemcached-0.32/libmemcached/memcached_io.h +59 -0
- data/ext/libmemcached-0.32/libmemcached/memcached_key.c +28 -0
- data/ext/libmemcached-0.32/libmemcached/memcached_parse.c +74 -0
- data/ext/libmemcached-0.32/libmemcached/memcached_pool.h +38 -0
- data/ext/libmemcached-0.32/libmemcached/memcached_purge.c +76 -0
- data/ext/libmemcached-0.32/libmemcached/memcached_quit.c +75 -0
- data/ext/libmemcached-0.32/libmemcached/memcached_response.c +528 -0
- data/ext/libmemcached-0.32/libmemcached/memcached_result.c +57 -0
- data/ext/libmemcached-0.32/libmemcached/memcached_result.h +59 -0
- data/ext/libmemcached-0.32/libmemcached/memcached_sasl.c +225 -0
- data/ext/libmemcached-0.32/libmemcached/memcached_sasl.h +44 -0
- data/ext/libmemcached-0.32/libmemcached/memcached_server.c +159 -0
- data/ext/libmemcached-0.32/libmemcached/memcached_server.h +93 -0
- data/ext/libmemcached-0.32/libmemcached/memcached_stats.c +454 -0
- data/ext/libmemcached-0.32/libmemcached/memcached_storage.c +514 -0
- data/ext/libmemcached-0.32/libmemcached/memcached_storage.h +107 -0
- data/ext/libmemcached-0.32/libmemcached/memcached_strerror.c +92 -0
- data/ext/libmemcached-0.32/libmemcached/memcached_string.c +138 -0
- data/ext/libmemcached-0.32/libmemcached/memcached_string.h +53 -0
- data/ext/libmemcached-0.32/libmemcached/memcached_types.h +44 -0
- data/ext/libmemcached-0.32/libmemcached/memcached_util.h +15 -0
- data/ext/libmemcached-0.32/libmemcached/memcached_verbosity.c +36 -0
- data/ext/libmemcached-0.32/libmemcached/memcached_version.c +112 -0
- data/ext/libmemcached-0.32/libmemcached/memcached_watchpoint.h +38 -0
- data/ext/libmemcached-0.32/libmemcached/murmur_hash.c +76 -0
- data/ext/libmemcached-0.32/libmemcached/visibility.h +51 -0
- data/ext/libmemcached-0.32/libmemcachedutil/Makefile.am +11 -0
- data/ext/libmemcached-0.32/libmemcachedutil/Makefile.in +602 -0
- data/ext/libmemcached-0.32/libmemcachedutil/libmemcachedutil.ver +1 -0
- data/ext/libmemcached-0.32/libmemcachedutil/memcached_pool.c +170 -0
- data/ext/libmemcached-0.32/m4/ac_cxx_compile_stdcxx_0x.m4 +103 -0
- data/ext/libmemcached-0.32/m4/ac_cxx_header_stdcxx_98.m4 +67 -0
- data/ext/libmemcached-0.32/m4/acx_pthread.m4 +276 -0
- data/ext/libmemcached-0.32/m4/byteorder.m4 +40 -0
- data/ext/libmemcached-0.32/m4/deprecated.m4 +17 -0
- data/ext/libmemcached-0.32/m4/enable_utillib.m4 +16 -0
- data/ext/libmemcached-0.32/m4/extensions.m4 +94 -0
- data/ext/libmemcached-0.32/m4/hsieh.m4 +18 -0
- data/ext/libmemcached-0.32/m4/lib-prefix.m4 +221 -0
- data/ext/libmemcached-0.32/m4/libtool.m4 +7360 -0
- data/ext/libmemcached-0.32/m4/ltoptions.m4 +368 -0
- data/ext/libmemcached-0.32/m4/ltsugar.m4 +123 -0
- data/ext/libmemcached-0.32/m4/ltversion.m4 +23 -0
- data/ext/libmemcached-0.32/m4/lt~obsolete.m4 +92 -0
- data/ext/libmemcached-0.32/m4/memcached.m4 +30 -0
- data/ext/libmemcached-0.32/m4/pandora_64bit.m4 +55 -0
- data/ext/libmemcached-0.32/m4/pandora_canonical.m4 +151 -0
- data/ext/libmemcached-0.32/m4/pandora_check_compiler_version.m4 +37 -0
- data/ext/libmemcached-0.32/m4/pandora_check_cxx_standard.m4 +16 -0
- data/ext/libmemcached-0.32/m4/pandora_enable_dtrace.m4 +41 -0
- data/ext/libmemcached-0.32/m4/pandora_ensure_gcc_version.m4 +36 -0
- data/ext/libmemcached-0.32/m4/pandora_have_better_malloc.m4 +54 -0
- data/ext/libmemcached-0.32/m4/pandora_have_sasl.m4 +133 -0
- data/ext/libmemcached-0.32/m4/pandora_header_assert.m4 +23 -0
- data/ext/libmemcached-0.32/m4/pandora_libtool.m4 +15 -0
- data/ext/libmemcached-0.32/m4/pandora_optimize.m4 +79 -0
- data/ext/libmemcached-0.32/m4/pandora_shared_ptr.m4 +56 -0
- data/ext/libmemcached-0.32/m4/pandora_vc_build.m4 +32 -0
- data/ext/libmemcached-0.32/m4/pandora_warnings.m4 +262 -0
- data/ext/libmemcached-0.32/m4/pod2man.m4 +7 -0
- data/ext/libmemcached-0.32/m4/protocol_binary.m4 +23 -0
- data/ext/libmemcached-0.32/m4/setsockopt.m4 +57 -0
- data/ext/libmemcached-0.32/m4/visibility.m4 +52 -0
- data/ext/libmemcached-0.32/support/Makefile.am +4 -0
- data/ext/libmemcached-0.32/support/Makefile.in +485 -0
- data/ext/libmemcached-0.32/support/libmemcached-fc.spec.in +105 -0
- data/ext/libmemcached-0.32/support/libmemcached.pc.in +10 -0
- data/ext/libmemcached-0.32/support/libmemcached.spec +105 -0
- data/ext/libmemcached-0.32/support/libmemcached.spec.in +105 -0
- data/ext/libmemcached-0.32/support/set_benchmark.sh +5 -0
- data/ext/libmemcached-0.32/tests/Makefile.am +105 -0
- data/ext/libmemcached-0.32/tests/Makefile.in +748 -0
- data/ext/libmemcached-0.32/tests/atomsmasher.c +245 -0
- data/ext/libmemcached-0.32/tests/function.c +4781 -0
- data/ext/libmemcached-0.32/tests/ketama_test_cases.h +108 -0
- data/ext/libmemcached-0.32/tests/output.cmp +7 -0
- data/ext/libmemcached-0.32/tests/output.res +7 -0
- data/ext/libmemcached-0.32/tests/output2.res +46 -0
- data/ext/libmemcached-0.32/tests/plus.cpp +293 -0
- data/ext/libmemcached-0.32/tests/r/memcat.res +19 -0
- data/ext/libmemcached-0.32/tests/r/memcp.res +27 -0
- data/ext/libmemcached-0.32/tests/r/memrm.res +19 -0
- data/ext/libmemcached-0.32/tests/r/memslap.res +33 -0
- data/ext/libmemcached-0.32/tests/r/memstat.res +33 -0
- data/ext/libmemcached-0.32/tests/server.c +118 -0
- data/ext/libmemcached-0.32/tests/server.h +25 -0
- data/ext/libmemcached-0.32/tests/start.c +16 -0
- data/ext/libmemcached-0.32/tests/t/memcat.test +4 -0
- data/ext/libmemcached-0.32/tests/t/memcp.test +3 -0
- data/ext/libmemcached-0.32/tests/t/memrm.test +3 -0
- data/ext/libmemcached-0.32/tests/t/memslap.test +5 -0
- data/ext/libmemcached-0.32/tests/t/memstat.test +3 -0
- data/ext/libmemcached-0.32/tests/test.c +137 -0
- data/ext/libmemcached-0.32/tests/test.h +46 -0
- data/ext/libmemcached-0.32/tests/udp.c +76 -0
- data/memcached.gemspec +4 -4
- data/test/unit/memcached_test.rb +30 -0
- metadata +213 -16
- data/ext/libmemcached-0.32.tar.gz +0 -0
- data/ext/libmemcached-1.patch +0 -270
- data/ext/libmemcached-10.patch +0 -12
- data/ext/libmemcached-2.patch +0 -116
- data/ext/libmemcached-3.patch +0 -8
- data/ext/libmemcached-4.patch +0 -40
- data/ext/libmemcached-5.patch +0 -832
- data/ext/libmemcached-6.patch +0 -20
- data/ext/libmemcached-7.patch +0 -2989
- data/ext/libmemcached-8.patch +0 -137
- data/ext/libmemcached-9.patch +0 -13
- data/ext/sasl.patch +0 -29283
data/ext/libmemcached-6.patch
DELETED
@@ -1,20 +0,0 @@
|
|
1
|
-
diff --git a/libmemcached-0.32/libmemcached/memcached_quit.c b/libmemcached-0.32/libmemcached/memcached_quit.c
|
2
|
-
index 9a200a1..80a03bc 100644
|
3
|
-
--- a/libmemcached-0.32/libmemcached/memcached_quit.c
|
4
|
-
+++ b/libmemcached-0.32/libmemcached/memcached_quit.c
|
5
|
-
@@ -49,7 +49,14 @@ void memcached_quit_server(memcached_server_st *ptr, uint8_t io_death)
|
6
|
-
memcached_server_response_reset(ptr);
|
7
|
-
}
|
8
|
-
|
9
|
-
- ptr->server_failure_counter++;
|
10
|
-
+ if (io_death)
|
11
|
-
+ {
|
12
|
-
+ ptr->server_failure_counter++;
|
13
|
-
+ }
|
14
|
-
+ else
|
15
|
-
+ {
|
16
|
-
+ ptr->server_failure_counter = 0;
|
17
|
-
+ }
|
18
|
-
}
|
19
|
-
|
20
|
-
void memcached_quit(memcached_st *ptr)
|
data/ext/libmemcached-7.patch
DELETED
@@ -1,2989 +0,0 @@
|
|
1
|
-
diff -ur a/libmemcached-0.32/docs/libmemcached.pod b/libmemcached-0.32/docs/libmemcached.pod
|
2
|
-
--- a/libmemcached-0.32/docs/libmemcached.pod 2009-06-14 08:18:14.000000000 -0700
|
3
|
-
+++ b/libmemcached-0.32/docs/libmemcached.pod 2011-03-02 21:44:44.000000000 -0800
|
4
|
-
@@ -35,7 +35,7 @@
|
5
|
-
Nearly all functions return a C<memcached_return> value.
|
6
|
-
This value can be translated to a printable string with memcached_strerror(3).
|
7
|
-
|
8
|
-
-Partitioning based on keys is supported in the library. Using the key partioning
|
9
|
-
+Partitioning based on keys is supported in the library. Using the key partioning
|
10
|
-
functions it is possible to group sets of object onto servers.
|
11
|
-
|
12
|
-
C<memcached_st> structures are thread-safe, but each thread must
|
13
|
-
@@ -44,13 +44,13 @@
|
14
|
-
used in this library.
|
15
|
-
|
16
|
-
If you are working with GNU autotools you will want to add the following to
|
17
|
-
-your configure.ac to properly include libmemcached in your application.
|
18
|
-
+your configure.ac to properly include libmemcached in your application.
|
19
|
-
|
20
|
-
PKG_CHECK_MODULES(DEPS, libmemcached >= 0.8.0)
|
21
|
-
AC_SUBST(DEPS_CFLAGS)
|
22
|
-
AC_SUBST(DEPS_LIBS)
|
23
|
-
|
24
|
-
-Some features of the library must be enabled through memcached_behavior_set().
|
25
|
-
+Some features of the library must be enabled through memcached_behavior_set().
|
26
|
-
|
27
|
-
Hope you enjoy it!
|
28
|
-
|
29
|
-
@@ -73,10 +73,6 @@
|
30
|
-
|
31
|
-
Default size of key (which includes the null pointer).
|
32
|
-
|
33
|
-
-=item MEMCACHED_STRIDE
|
34
|
-
-
|
35
|
-
-This is the "stride" used in the consistent hash used between replicas.
|
36
|
-
-
|
37
|
-
=item MEMCACHED_MAX_HOST_LENGTH
|
38
|
-
|
39
|
-
Maximum allowed size of the hostname.
|
40
|
-
@@ -87,15 +83,15 @@
|
41
|
-
|
42
|
-
=item MEMCACHED_MAJOR_VERSION
|
43
|
-
|
44
|
-
-Major version value. Such as 1.23.4, would be 1
|
45
|
-
+Major version value. Such as 1.23.4, would be 1
|
46
|
-
|
47
|
-
=item MEMCACHED_MINOR_VERSION
|
48
|
-
|
49
|
-
-Major version value. Such as 1.23.4, would be 23
|
50
|
-
+Major version value. Such as 1.23.4, would be 23
|
51
|
-
|
52
|
-
=item MEMCACHED_MICRO_VERSION
|
53
|
-
|
54
|
-
-Major version value. Such as 1.23.4, would be 4
|
55
|
-
+Major version value. Such as 1.23.4, would be 4
|
56
|
-
|
57
|
-
|
58
|
-
=back
|
59
|
-
diff -ur a/libmemcached-0.32/docs/memcached_behavior.pod b/libmemcached-0.32/docs/memcached_behavior.pod
|
60
|
-
--- a/libmemcached-0.32/docs/memcached_behavior.pod 2009-06-27 10:46:16.000000000 -0700
|
61
|
-
+++ b/libmemcached-0.32/docs/memcached_behavior.pod 2011-03-02 21:45:30.000000000 -0800
|
62
|
-
@@ -32,7 +32,7 @@
|
63
|
-
|
64
|
-
memcached_behavior_set() changes the value of a particular option of the
|
65
|
-
client. It takes both a flag (listed below) and a value. For simple on or
|
66
|
-
-off options you just need to pass in a value of 1. Calls to
|
67
|
-
+off options you just need to pass in a value of 1. Calls to
|
68
|
-
memcached_behavior_set() will flush and reset all connections.
|
69
|
-
|
70
|
-
=over 4
|
71
|
-
@@ -40,7 +40,7 @@
|
72
|
-
=item MEMCACHED_BEHAVIOR_USE_UDP
|
73
|
-
|
74
|
-
Causes libmemcached(3) to use the UDP transport when communicating
|
75
|
-
-with a memcached server. Not all I/O operations are supported
|
76
|
-
+with a memcached server. Not all I/O operations are supported
|
77
|
-
when this behavior is enababled. The following operations will return
|
78
|
-
C<MEMCACHED_NOT_SUPPORTED> when executed with the MEMCACHED_BEHAVIOR_USE_UDP
|
79
|
-
enabled: memcached_version(), memcached_stat(), memcached_get(),
|
80
|
-
@@ -50,7 +50,7 @@
|
81
|
-
All other operations are supported but are executed in a 'fire-and-forget'
|
82
|
-
mode, in which once the client has executed the operation, no attempt
|
83
|
-
will be made to ensure the operation has been received and acted on by the
|
84
|
-
-server.
|
85
|
-
+server.
|
86
|
-
|
87
|
-
libmemcached(3) does not allow TCP and UDP servers to be shared within
|
88
|
-
the same libmemached(3) client 'instance'. An attempt to add a TCP server
|
89
|
-
@@ -82,19 +82,19 @@
|
90
|
-
=item MEMCACHED_BEHAVIOR_HASH
|
91
|
-
|
92
|
-
Makes the default hashing algorithm for keys use MD5. The value can be set
|
93
|
-
-to either MEMCACHED_HASH_DEFAULT, MEMCACHED_HASH_MD5, MEMCACHED_HASH_CRC, MEMCACHED_HASH_FNV1_64, MEMCACHED_HASH_FNV1A_64, MEMCACHED_HASH_FNV1_32, MEMCACHED_HASH_FNV1A_32, MEMCACHED_HASH_JENKINS, MEMCACHED_HASH_HSIEH, and MEMCACHED_HASH_MURMUR.
|
94
|
-
+to either MEMCACHED_HASH_DEFAULT, MEMCACHED_HASH_MD5, MEMCACHED_HASH_CRC, MEMCACHED_HASH_FNV1_64, MEMCACHED_HASH_FNV1A_64, MEMCACHED_HASH_FNV1_32, MEMCACHED_HASH_FNV1A_32, MEMCACHED_HASH_JENKINS, MEMCACHED_HASH_HSIEH, and MEMCACHED_HASH_MURMUR.
|
95
|
-
Each hash has it's advantages and it's weaknesses. If you dont know or dont care, just go with the default.
|
96
|
-
-Support for MEMCACHED_HASH_HSIEH is a compile time option that is disabled by default. To enable support for this hashing algorithm, configure and build libmemcached with the --enable-hash_hsieh.
|
97
|
-
+Support for MEMCACHED_HASH_HSIEH is a compile time option that is disabled by default. To enable support for this hashing algorithm, configure and build libmemcached with the --enable-hash_hsieh.
|
98
|
-
|
99
|
-
=item MEMCACHED_BEHAVIOR_DISTRIBUTION
|
100
|
-
|
101
|
-
Using this you can enable different means of distributing values to servers.
|
102
|
-
The default method is MEMCACHED_DISTRIBUTION_MODULA. You can enable
|
103
|
-
-consistent hashing by setting MEMCACHED_DISTRIBUTION_CONSISTENT.
|
104
|
-
-Consistent hashing delivers better distribution and allows servers to be
|
105
|
-
+consistent hashing by setting MEMCACHED_DISTRIBUTION_CONSISTENT.
|
106
|
-
+Consistent hashing delivers better distribution and allows servers to be
|
107
|
-
added to the cluster with minimal cache losses. Currently
|
108
|
-
MEMCACHED_DISTRIBUTION_CONSISTENT is an alias for the value
|
109
|
-
-MEMCACHED_DISTRIBUTION_CONSISTENT_KETAMA.
|
110
|
-
+MEMCACHED_DISTRIBUTION_CONSISTENT_KETAMA.
|
111
|
-
|
112
|
-
=item MEMCACHED_BEHAVIOR_CACHE_LOOKUPS
|
113
|
-
|
114
|
-
@@ -117,7 +117,7 @@
|
115
|
-
=item MEMCACHED_BEHAVIOR_KETAMA_HASH
|
116
|
-
|
117
|
-
Sets the hashing algorithm for host mapping on continuum. The value can be set
|
118
|
-
-to either MEMCACHED_HASH_DEFAULT, MEMCACHED_HASH_MD5, MEMCACHED_HASH_CRC, MEMCACHED_HASH_FNV1_64, MEMCACHED_HASH_FNV1A_64, MEMCACHED_HASH_FNV1_32, and MEMCACHED_HASH_FNV1A_32.
|
119
|
-
+to either MEMCACHED_HASH_DEFAULT, MEMCACHED_HASH_MD5, MEMCACHED_HASH_CRC, MEMCACHED_HASH_FNV1_64, MEMCACHED_HASH_FNV1A_64, MEMCACHED_HASH_FNV1_32, and MEMCACHED_HASH_FNV1A_32.
|
120
|
-
|
121
|
-
=item MEMCACHED_BEHAVIOR_POLL_TIMEOUT
|
122
|
-
|
123
|
-
@@ -136,16 +136,16 @@
|
124
|
-
Enabling buffered IO causes commands to "buffer" instead of being sent. Any
|
125
|
-
action that gets data causes this buffer to be be sent to the remote
|
126
|
-
connection. Quiting the connection or closing down the connection will also
|
127
|
-
-cause the buffered data to be pushed to the remote connection.
|
128
|
-
+cause the buffered data to be pushed to the remote connection.
|
129
|
-
|
130
|
-
=item MEMCACHED_BEHAVIOR_VERIFY_KEY
|
131
|
-
|
132
|
-
-Enabling this will cause libmemcached(3) to test all keys to verify that they
|
133
|
-
+Enabling this will cause libmemcached(3) to test all keys to verify that they
|
134
|
-
are valid keys.
|
135
|
-
|
136
|
-
=item MEMCACHED_BEHAVIOR_SORT_HOSTS
|
137
|
-
|
138
|
-
-Enabling this will cause hosts that are added to be placed in the host list in
|
139
|
-
+Enabling this will cause hosts that are added to be placed in the host list in
|
140
|
-
sorted order. This will defeat consisten hashing.
|
141
|
-
|
142
|
-
=item MEMCACHED_BEHAVIOR_CONNECT_TIMEOUT
|
143
|
-
@@ -165,7 +165,7 @@
|
144
|
-
|
145
|
-
=item MEMCACHED_BEHAVIOR_IO_MSG_WATERMARK
|
146
|
-
|
147
|
-
-Set this value to tune the number of messages that may be sent before
|
148
|
-
+Set this value to tune the number of messages that may be sent before
|
149
|
-
libmemcached should start to automatically drain the input queue. Setting
|
150
|
-
this value to high, may cause libmemcached to deadlock (trying to send data,
|
151
|
-
but the send will block because the input buffer in the kernel is full).
|
152
|
-
@@ -175,7 +175,7 @@
|
153
|
-
Set this value to tune the number of bytes that may be sent before
|
154
|
-
libmemcached should start to automatically drain the input queue (need
|
155
|
-
at least 10 IO requests sent without reading the input buffer). Setting
|
156
|
-
-this value to high, may cause libmemcached to deadlock (trying to send
|
157
|
-
+this value to high, may cause libmemcached to deadlock (trying to send
|
158
|
-
data, but the send will block because the input buffer in the kernel is full).
|
159
|
-
|
160
|
-
=item MEMCACHED_BEHAVIOR_IO_KEY_PREFETCH
|
161
|
-
@@ -192,15 +192,7 @@
|
162
|
-
=item MEMCACHED_BEHAVIOR_NOREPLY
|
163
|
-
|
164
|
-
Set this value to specify that you really don't care about the result
|
165
|
-
-from your storage commands (set, add, replace, append, prepend).
|
166
|
-
-
|
167
|
-
-=item MEMCACHED_BEHAVIOR_NUMBER_OF_REPLICAS
|
168
|
-
-
|
169
|
-
-If you just want "a poor mans HA", you may specify the numbers of
|
170
|
-
-replicas libmemcached should store of each item (on different servers).
|
171
|
-
-This replication does not dedicate certain memcached servers to store the
|
172
|
-
-replicas in, but instead it will store the replicas together with all of the
|
173
|
-
-other objects (on the 'n' next servers specified in your server list).
|
174
|
-
+from your storage commands (set, add, replace, append, prepend).
|
175
|
-
|
176
|
-
=back
|
177
|
-
|
178
|
-
@@ -213,7 +205,7 @@
|
179
|
-
=head1 NOTES
|
180
|
-
|
181
|
-
memcached_behavior_set() in version .17 was changed from taking a pointer
|
182
|
-
-to data value, to taking a uin64_t.
|
183
|
-
+to data value, to taking a uin64_t.
|
184
|
-
|
185
|
-
=head1 HOME
|
186
|
-
|
187
|
-
diff -ur a/libmemcached-0.32/libmemcached/memcached.c b/libmemcached-0.32/libmemcached/memcached.c
|
188
|
-
--- a/libmemcached-0.32/libmemcached/memcached.c 2011-03-02 20:23:03.000000000 -0800
|
189
|
-
+++ b/libmemcached-0.32/libmemcached/memcached.c 2011-03-02 21:44:27.000000000 -0800
|
190
|
-
@@ -108,7 +108,6 @@
|
191
|
-
new_clone->io_msg_watermark= source->io_msg_watermark;
|
192
|
-
new_clone->io_bytes_watermark= source->io_bytes_watermark;
|
193
|
-
new_clone->io_key_prefetch= source->io_key_prefetch;
|
194
|
-
- new_clone->number_of_replicas= source->number_of_replicas;
|
195
|
-
|
196
|
-
if (source->hosts)
|
197
|
-
rc= memcached_server_push(new_clone, source->hosts);
|
198
|
-
diff -ur a/libmemcached-0.32/libmemcached/memcached.h b/libmemcached-0.32/libmemcached/memcached.h
|
199
|
-
--- a/libmemcached-0.32/libmemcached/memcached.h 2011-03-02 20:23:03.000000000 -0800
|
200
|
-
+++ b/libmemcached-0.32/libmemcached/memcached.h 2011-03-02 21:44:17.000000000 -0800
|
201
|
-
@@ -112,7 +112,6 @@
|
202
|
-
memcached_trigger_key get_key_failure;
|
203
|
-
memcached_trigger_delete_key delete_trigger;
|
204
|
-
char prefix_key[MEMCACHED_PREFIX_KEY_MAX_SIZE];
|
205
|
-
- uint32_t number_of_replicas;
|
206
|
-
uint32_t number_of_live_hosts;
|
207
|
-
uint32_t *live_host_indices;
|
208
|
-
uint32_t live_host_indices_size;
|
209
|
-
diff -ur a/libmemcached-0.32/libmemcached/memcached_behavior.c b/libmemcached-0.32/libmemcached/memcached_behavior.c
|
210
|
-
--- a/libmemcached-0.32/libmemcached/memcached_behavior.c 2009-09-15 13:32:40.000000000 -0700
|
211
|
-
+++ b/libmemcached-0.32/libmemcached/memcached_behavior.c 2011-03-02 21:44:58.000000000 -0800
|
212
|
-
@@ -1,10 +1,10 @@
|
213
|
-
-#include "common.h"
|
214
|
-
+#include "common.h"
|
215
|
-
#include <time.h>
|
216
|
-
#include <sys/types.h>
|
217
|
-
#include <sys/socket.h>
|
218
|
-
#include <netinet/tcp.h>
|
219
|
-
|
220
|
-
-/*
|
221
|
-
+/*
|
222
|
-
This function is used to modify the behavior of running client.
|
223
|
-
|
224
|
-
We quit all connections so we can reset the sockets.
|
225
|
-
@@ -18,15 +18,12 @@
|
226
|
-
ptr->flags&= ~temp_flag;
|
227
|
-
}
|
228
|
-
|
229
|
-
-memcached_return memcached_behavior_set(memcached_st *ptr,
|
230
|
-
- memcached_behavior flag,
|
231
|
-
+memcached_return memcached_behavior_set(memcached_st *ptr,
|
232
|
-
+ memcached_behavior flag,
|
233
|
-
uint64_t data)
|
234
|
-
{
|
235
|
-
switch (flag)
|
236
|
-
{
|
237
|
-
- case MEMCACHED_BEHAVIOR_NUMBER_OF_REPLICAS:
|
238
|
-
- ptr->number_of_replicas= (uint32_t)data;
|
239
|
-
- break;
|
240
|
-
case MEMCACHED_BEHAVIOR_IO_MSG_WATERMARK:
|
241
|
-
ptr->io_msg_watermark= (uint32_t) data;
|
242
|
-
break;
|
243
|
-
@@ -38,18 +35,18 @@
|
244
|
-
break;
|
245
|
-
case MEMCACHED_BEHAVIOR_SND_TIMEOUT:
|
246
|
-
ptr->snd_timeout= (int32_t)data;
|
247
|
-
- break;
|
248
|
-
+ break;
|
249
|
-
case MEMCACHED_BEHAVIOR_RCV_TIMEOUT:
|
250
|
-
ptr->rcv_timeout= (int32_t)data;
|
251
|
-
- break;
|
252
|
-
+ break;
|
253
|
-
case MEMCACHED_BEHAVIOR_SERVER_FAILURE_LIMIT:
|
254
|
-
ptr->server_failure_limit= (uint32_t)data;
|
255
|
-
- break;
|
256
|
-
+ break;
|
257
|
-
case MEMCACHED_BEHAVIOR_BINARY_PROTOCOL:
|
258
|
-
if (data)
|
259
|
-
set_behavior_flag(ptr, MEM_VERIFY_KEY, 0);
|
260
|
-
set_behavior_flag(ptr, MEM_BINARY_PROTOCOL, data);
|
261
|
-
- break;
|
262
|
-
+ break;
|
263
|
-
case MEMCACHED_BEHAVIOR_SUPPORT_CAS:
|
264
|
-
set_behavior_flag(ptr, MEM_SUPPORT_CAS, data);
|
265
|
-
break;
|
266
|
-
@@ -169,15 +166,13 @@
|
267
|
-
return MEMCACHED_SUCCESS;
|
268
|
-
}
|
269
|
-
|
270
|
-
-uint64_t memcached_behavior_get(memcached_st *ptr,
|
271
|
-
+uint64_t memcached_behavior_get(memcached_st *ptr,
|
272
|
-
memcached_behavior flag)
|
273
|
-
{
|
274
|
-
memcached_flags temp_flag= MEM_NO_BLOCK;
|
275
|
-
|
276
|
-
switch (flag)
|
277
|
-
{
|
278
|
-
- case MEMCACHED_BEHAVIOR_NUMBER_OF_REPLICAS:
|
279
|
-
- return ptr->number_of_replicas;
|
280
|
-
case MEMCACHED_BEHAVIOR_IO_MSG_WATERMARK:
|
281
|
-
return ptr->io_msg_watermark;
|
282
|
-
case MEMCACHED_BEHAVIOR_IO_BYTES_WATERMARK:
|
283
|
-
@@ -186,7 +181,7 @@
|
284
|
-
return ptr->io_key_prefetch;
|
285
|
-
case MEMCACHED_BEHAVIOR_BINARY_PROTOCOL:
|
286
|
-
temp_flag= MEM_BINARY_PROTOCOL;
|
287
|
-
- break;
|
288
|
-
+ break;
|
289
|
-
case MEMCACHED_BEHAVIOR_SUPPORT_CAS:
|
290
|
-
temp_flag= MEM_SUPPORT_CAS;
|
291
|
-
break;
|
292
|
-
@@ -244,7 +239,7 @@
|
293
|
-
if ((memcached_connect(&ptr->hosts[0])) != MEMCACHED_SUCCESS)
|
294
|
-
return 0;
|
295
|
-
|
296
|
-
- if (getsockopt(ptr->hosts[0].fd, SOL_SOCKET,
|
297
|
-
+ if (getsockopt(ptr->hosts[0].fd, SOL_SOCKET,
|
298
|
-
SO_SNDBUF, &sock_size, &sock_length))
|
299
|
-
return 0; /* Zero means error */
|
300
|
-
|
301
|
-
@@ -260,7 +255,7 @@
|
302
|
-
if ((memcached_connect(&ptr->hosts[0])) != MEMCACHED_SUCCESS)
|
303
|
-
return 0;
|
304
|
-
|
305
|
-
- if (getsockopt(ptr->hosts[0].fd, SOL_SOCKET,
|
306
|
-
+ if (getsockopt(ptr->hosts[0].fd, SOL_SOCKET,
|
307
|
-
SO_RCVBUF, &sock_size, &sock_length))
|
308
|
-
return 0; /* Zero means error */
|
309
|
-
|
310
|
-
diff -ur a/libmemcached-0.32/libmemcached/memcached_constants.h b/libmemcached-0.32/libmemcached/memcached_constants.h
|
311
|
-
--- a/libmemcached-0.32/libmemcached/memcached_constants.h 2011-03-02 20:23:03.000000000 -0800
|
312
|
-
+++ b/libmemcached-0.32/libmemcached/memcached_constants.h 2011-03-02 21:45:46.000000000 -0800
|
313
|
-
@@ -104,8 +104,7 @@
|
314
|
-
MEMCACHED_BEHAVIOR_HASH_WITH_PREFIX_KEY,
|
315
|
-
MEMCACHED_BEHAVIOR_NOREPLY,
|
316
|
-
MEMCACHED_BEHAVIOR_USE_UDP,
|
317
|
-
- MEMCACHED_BEHAVIOR_AUTO_EJECT_HOSTS,
|
318
|
-
- MEMCACHED_BEHAVIOR_NUMBER_OF_REPLICAS
|
319
|
-
+ MEMCACHED_BEHAVIOR_AUTO_EJECT_HOSTS
|
320
|
-
} memcached_behavior;
|
321
|
-
|
322
|
-
typedef enum {
|
323
|
-
diff -ur a/libmemcached-0.32/libmemcached/memcached_delete.c b/libmemcached-0.32/libmemcached/memcached_delete.c
|
324
|
-
--- a/libmemcached-0.32/libmemcached/memcached_delete.c 2009-07-29 22:47:46.000000000 -0700
|
325
|
-
+++ b/libmemcached-0.32/libmemcached/memcached_delete.c 2011-03-02 20:21:55.000000000 -0800
|
326
|
-
@@ -1,153 +0,0 @@
|
327
|
-
-#include "common.h"
|
328
|
-
-#include "memcached/protocol_binary.h"
|
329
|
-
-
|
330
|
-
-memcached_return memcached_delete(memcached_st *ptr, const char *key, size_t key_length,
|
331
|
-
- time_t expiration)
|
332
|
-
-{
|
333
|
-
- return memcached_delete_by_key(ptr, key, key_length,
|
334
|
-
- key, key_length, expiration);
|
335
|
-
-}
|
336
|
-
-
|
337
|
-
-static inline memcached_return binary_delete(memcached_st *ptr,
|
338
|
-
- unsigned int server_key,
|
339
|
-
- const char *key,
|
340
|
-
- size_t key_length,
|
341
|
-
- uint8_t flush);
|
342
|
-
-
|
343
|
-
-memcached_return memcached_delete_by_key(memcached_st *ptr,
|
344
|
-
- const char *master_key, size_t master_key_length,
|
345
|
-
- const char *key, size_t key_length,
|
346
|
-
- time_t expiration)
|
347
|
-
-{
|
348
|
-
- uint8_t to_write;
|
349
|
-
- size_t send_length;
|
350
|
-
- memcached_return rc;
|
351
|
-
- char buffer[MEMCACHED_DEFAULT_COMMAND_SIZE];
|
352
|
-
- unsigned int server_key;
|
353
|
-
-
|
354
|
-
- LIBMEMCACHED_MEMCACHED_DELETE_START();
|
355
|
-
-
|
356
|
-
- rc= memcached_validate_key_length(key_length,
|
357
|
-
- ptr->flags & MEM_BINARY_PROTOCOL);
|
358
|
-
- unlikely (rc != MEMCACHED_SUCCESS)
|
359
|
-
- return rc;
|
360
|
-
-
|
361
|
-
- unlikely (ptr->hosts == NULL || ptr->number_of_hosts == 0)
|
362
|
-
- return MEMCACHED_NO_SERVERS;
|
363
|
-
-
|
364
|
-
- server_key= memcached_generate_hash(ptr, master_key, master_key_length);
|
365
|
-
- to_write= (uint8_t) (ptr->flags & MEM_BUFFER_REQUESTS) ? 0 : 1;
|
366
|
-
- bool no_reply= (ptr->flags & MEM_NOREPLY);
|
367
|
-
-
|
368
|
-
- if (ptr->flags & MEM_BINARY_PROTOCOL)
|
369
|
-
- rc= binary_delete(ptr, server_key, key, key_length, to_write);
|
370
|
-
- else
|
371
|
-
- {
|
372
|
-
- if (expiration)
|
373
|
-
- send_length= (size_t) snprintf(buffer, MEMCACHED_DEFAULT_COMMAND_SIZE,
|
374
|
-
- "delete %s%.*s %u%s\r\n",
|
375
|
-
- ptr->prefix_key,
|
376
|
-
- (int) key_length, key,
|
377
|
-
- (uint32_t)expiration, no_reply ? " noreply" :"" );
|
378
|
-
- else
|
379
|
-
- send_length= (size_t) snprintf(buffer, MEMCACHED_DEFAULT_COMMAND_SIZE,
|
380
|
-
- "delete %s%.*s%s\r\n",
|
381
|
-
- ptr->prefix_key,
|
382
|
-
- (int)key_length, key, no_reply ? " noreply" :"");
|
383
|
-
-
|
384
|
-
- if (send_length >= MEMCACHED_DEFAULT_COMMAND_SIZE)
|
385
|
-
- {
|
386
|
-
- rc= MEMCACHED_WRITE_FAILURE;
|
387
|
-
- goto error;
|
388
|
-
- }
|
389
|
-
-
|
390
|
-
- if (ptr->flags & MEM_USE_UDP && !to_write)
|
391
|
-
- {
|
392
|
-
- if (send_length > MAX_UDP_DATAGRAM_LENGTH - UDP_DATAGRAM_HEADER_LENGTH)
|
393
|
-
- return MEMCACHED_WRITE_FAILURE;
|
394
|
-
- if (send_length + ptr->hosts[server_key].write_buffer_offset > MAX_UDP_DATAGRAM_LENGTH)
|
395
|
-
- memcached_io_write(&ptr->hosts[server_key], NULL, 0, 1);
|
396
|
-
- }
|
397
|
-
-
|
398
|
-
- rc= memcached_do(&ptr->hosts[server_key], buffer, send_length, to_write);
|
399
|
-
- }
|
400
|
-
-
|
401
|
-
- if (rc != MEMCACHED_SUCCESS)
|
402
|
-
- goto error;
|
403
|
-
-
|
404
|
-
- if ((ptr->flags & MEM_BUFFER_REQUESTS))
|
405
|
-
- rc= MEMCACHED_BUFFERED;
|
406
|
-
- else if (!no_reply)
|
407
|
-
- {
|
408
|
-
- rc= memcached_response(&ptr->hosts[server_key], buffer, MEMCACHED_DEFAULT_COMMAND_SIZE, NULL);
|
409
|
-
- if (rc == MEMCACHED_DELETED)
|
410
|
-
- rc= MEMCACHED_SUCCESS;
|
411
|
-
- }
|
412
|
-
-
|
413
|
-
- if (rc == MEMCACHED_SUCCESS && ptr->delete_trigger)
|
414
|
-
- ptr->delete_trigger(ptr, key, key_length);
|
415
|
-
-
|
416
|
-
-error:
|
417
|
-
- LIBMEMCACHED_MEMCACHED_DELETE_END();
|
418
|
-
- return rc;
|
419
|
-
-}
|
420
|
-
-
|
421
|
-
-static inline memcached_return binary_delete(memcached_st *ptr,
|
422
|
-
- unsigned int server_key,
|
423
|
-
- const char *key,
|
424
|
-
- size_t key_length,
|
425
|
-
- uint8_t flush)
|
426
|
-
-{
|
427
|
-
- protocol_binary_request_delete request= {.bytes= {0}};
|
428
|
-
-
|
429
|
-
- request.message.header.request.magic= PROTOCOL_BINARY_REQ;
|
430
|
-
- if (ptr->flags & MEM_NOREPLY)
|
431
|
-
- request.message.header.request.opcode= PROTOCOL_BINARY_CMD_DELETEQ;
|
432
|
-
- else
|
433
|
-
- request.message.header.request.opcode= PROTOCOL_BINARY_CMD_DELETE;
|
434
|
-
- request.message.header.request.keylen= htons((uint16_t)key_length);
|
435
|
-
- request.message.header.request.datatype= PROTOCOL_BINARY_RAW_BYTES;
|
436
|
-
- request.message.header.request.bodylen= htonl((uint32_t) key_length);
|
437
|
-
-
|
438
|
-
- if (ptr->flags & MEM_USE_UDP && !flush)
|
439
|
-
- {
|
440
|
-
- size_t cmd_size= sizeof(request.bytes) + key_length;
|
441
|
-
- if (cmd_size > MAX_UDP_DATAGRAM_LENGTH - UDP_DATAGRAM_HEADER_LENGTH)
|
442
|
-
- return MEMCACHED_WRITE_FAILURE;
|
443
|
-
- if (cmd_size + ptr->hosts[server_key].write_buffer_offset > MAX_UDP_DATAGRAM_LENGTH)
|
444
|
-
- memcached_io_write(&ptr->hosts[server_key], NULL, 0, 1);
|
445
|
-
- }
|
446
|
-
-
|
447
|
-
- memcached_return rc= MEMCACHED_SUCCESS;
|
448
|
-
-
|
449
|
-
- if ((memcached_do(&ptr->hosts[server_key], request.bytes,
|
450
|
-
- sizeof(request.bytes), 0) != MEMCACHED_SUCCESS) ||
|
451
|
-
- (memcached_io_write(&ptr->hosts[server_key], key,
|
452
|
-
- key_length, (char) flush) == -1))
|
453
|
-
- {
|
454
|
-
- memcached_io_reset(&ptr->hosts[server_key]);
|
455
|
-
- rc= MEMCACHED_WRITE_FAILURE;
|
456
|
-
- }
|
457
|
-
-
|
458
|
-
- unlikely (ptr->number_of_replicas > 0)
|
459
|
-
- {
|
460
|
-
- request.message.header.request.opcode= PROTOCOL_BINARY_CMD_DELETEQ;
|
461
|
-
-
|
462
|
-
- for (uint32_t x= 0; x < ptr->number_of_replicas; ++x)
|
463
|
-
- {
|
464
|
-
- ++server_key;
|
465
|
-
- if (server_key == ptr->number_of_hosts)
|
466
|
-
- server_key= 0;
|
467
|
-
-
|
468
|
-
- memcached_server_st* server= &ptr->hosts[server_key];
|
469
|
-
- if ((memcached_do(server, (const char*)request.bytes,
|
470
|
-
- sizeof(request.bytes), 0) != MEMCACHED_SUCCESS) ||
|
471
|
-
- (memcached_io_write(server, key, key_length, (char) flush) == -1))
|
472
|
-
- memcached_io_reset(server);
|
473
|
-
- else
|
474
|
-
- memcached_server_response_decrement(server);
|
475
|
-
- }
|
476
|
-
- }
|
477
|
-
-
|
478
|
-
- return rc;
|
479
|
-
-}
|
480
|
-
diff -ur a/libmemcached-0.32/libmemcached/memcached_get.c b/libmemcached-0.32/libmemcached/memcached_get.c
|
481
|
-
--- a/libmemcached-0.32/libmemcached/memcached_get.c 2011-03-02 20:23:03.000000000 -0800
|
482
|
-
+++ b/libmemcached-0.32/libmemcached/memcached_get.c 2011-03-02 22:32:11.000000000 -0800
|
483
|
-
@@ -1,12 +1,12 @@
|
484
|
-
#include "common.h"
|
485
|
-
#include "memcached_io.h"
|
486
|
-
|
487
|
-
-/*
|
488
|
-
+/*
|
489
|
-
What happens if no servers exist?
|
490
|
-
*/
|
491
|
-
-char *memcached_get(memcached_st *ptr, const char *key,
|
492
|
-
- size_t key_length,
|
493
|
-
- size_t *value_length,
|
494
|
-
+char *memcached_get(memcached_st *ptr, const char *key,
|
495
|
-
+ size_t key_length,
|
496
|
-
+ size_t *value_length,
|
497
|
-
uint32_t *flags,
|
498
|
-
memcached_return *error)
|
499
|
-
{
|
500
|
-
@@ -15,25 +15,25 @@
|
501
|
-
flags, error);
|
502
|
-
}
|
503
|
-
|
504
|
-
-char *memcached_get_len(memcached_st *ptr,
|
505
|
-
+char *memcached_get_len(memcached_st *ptr,
|
506
|
-
const char *key, size_t key_length,
|
507
|
-
uint32_t user_spec_len,
|
508
|
-
- size_t *value_length,
|
509
|
-
+ size_t *value_length,
|
510
|
-
uint32_t *flags,
|
511
|
-
memcached_return *error)
|
512
|
-
{
|
513
|
-
return memcached_get_by_key(ptr, NULL, 0, key, key_length,
|
514
|
-
- user_spec_len, value_length,
|
515
|
-
+ user_spec_len, value_length,
|
516
|
-
flags, error);
|
517
|
-
|
518
|
-
}
|
519
|
-
|
520
|
-
-char *memcached_get_by_key(memcached_st *ptr,
|
521
|
-
- const char *master_key,
|
522
|
-
- size_t master_key_length,
|
523
|
-
+char *memcached_get_by_key(memcached_st *ptr,
|
524
|
-
+ const char *master_key,
|
525
|
-
+ size_t master_key_length,
|
526
|
-
const char *key, size_t key_length,
|
527
|
-
uint32_t user_spec_len,
|
528
|
-
- size_t *value_length,
|
529
|
-
+ size_t *value_length,
|
530
|
-
uint32_t *flags,
|
531
|
-
memcached_return *error)
|
532
|
-
{
|
533
|
-
@@ -49,13 +49,13 @@
|
534
|
-
}
|
535
|
-
|
536
|
-
/* Request the key */
|
537
|
-
- *error= memcached_mget_by_key(ptr,
|
538
|
-
- master_key,
|
539
|
-
- master_key_length,
|
540
|
-
+ *error= memcached_mget_by_key(ptr,
|
541
|
-
+ master_key,
|
542
|
-
+ master_key_length,
|
543
|
-
(const char **)&key, &key_length, 1,
|
544
|
-
user_spec_len);
|
545
|
-
|
546
|
-
- value= memcached_fetch(ptr, NULL, NULL,
|
547
|
-
+ value= memcached_fetch(ptr, NULL, NULL,
|
548
|
-
value_length, flags, error);
|
549
|
-
/* This is for historical reasons */
|
550
|
-
if (*error == MEMCACHED_END)
|
551
|
-
@@ -69,7 +69,7 @@
|
552
|
-
|
553
|
-
memcached_result_reset(&ptr->result);
|
554
|
-
rc= ptr->get_key_failure(ptr, key, key_length, &ptr->result);
|
555
|
-
-
|
556
|
-
+
|
557
|
-
/* On all failure drop to returning NULL */
|
558
|
-
if (rc == MEMCACHED_SUCCESS || rc == MEMCACHED_BUFFERED)
|
559
|
-
{
|
560
|
-
@@ -80,7 +80,7 @@
|
561
|
-
if (latch == 0)
|
562
|
-
memcached_behavior_set(ptr, MEMCACHED_BEHAVIOR_BUFFER_REQUESTS, 1);
|
563
|
-
|
564
|
-
- rc= memcached_set(ptr, key, key_length,
|
565
|
-
+ rc= memcached_set(ptr, key, key_length,
|
566
|
-
memcached_result_value(&ptr->result),
|
567
|
-
memcached_result_length(&ptr->result),
|
568
|
-
0, memcached_result_flags(&ptr->result));
|
569
|
-
@@ -90,7 +90,7 @@
|
570
|
-
}
|
571
|
-
else
|
572
|
-
{
|
573
|
-
- rc= memcached_set(ptr, key, key_length,
|
574
|
-
+ rc= memcached_set(ptr, key, key_length,
|
575
|
-
memcached_result_value(&ptr->result),
|
576
|
-
memcached_result_length(&ptr->result),
|
577
|
-
0, memcached_result_flags(&ptr->result));
|
578
|
-
@@ -109,24 +109,24 @@
|
579
|
-
return NULL;
|
580
|
-
}
|
581
|
-
|
582
|
-
- (void)memcached_fetch(ptr, NULL, NULL,
|
583
|
-
- &dummy_length, &dummy_flags,
|
584
|
-
+ (void)memcached_fetch(ptr, NULL, NULL,
|
585
|
-
+ &dummy_length, &dummy_flags,
|
586
|
-
&dummy_error);
|
587
|
-
WATCHPOINT_ASSERT(dummy_length == 0);
|
588
|
-
|
589
|
-
return value;
|
590
|
-
}
|
591
|
-
|
592
|
-
-memcached_return memcached_mget(memcached_st *ptr,
|
593
|
-
- const char **keys, size_t *key_length,
|
594
|
-
+memcached_return memcached_mget(memcached_st *ptr,
|
595
|
-
+ const char **keys, size_t *key_length,
|
596
|
-
size_t number_of_keys)
|
597
|
-
{
|
598
|
-
return memcached_mget_by_key(ptr, NULL, 0, keys, key_length, number_of_keys,
|
599
|
-
GET_LEN_ARG_UNSPECIFIED);
|
600
|
-
}
|
601
|
-
|
602
|
-
-memcached_return memcached_mget_len(memcached_st *ptr,
|
603
|
-
- const char **keys, size_t *key_length,
|
604
|
-
+memcached_return memcached_mget_len(memcached_st *ptr,
|
605
|
-
+ const char **keys, size_t *key_length,
|
606
|
-
size_t number_of_keys, uint32_t user_spec_len)
|
607
|
-
{
|
608
|
-
return memcached_mget_by_key(ptr, NULL, 0, keys, key_length, number_of_keys,
|
609
|
-
@@ -145,11 +145,11 @@
|
610
|
-
return (user_spec_len > 0 && user_spec_len < GET_LEN_ARG_UNSPECIFIED);
|
611
|
-
}
|
612
|
-
|
613
|
-
-memcached_return memcached_mget_by_key(memcached_st *ptr,
|
614
|
-
- const char *master_key,
|
615
|
-
+memcached_return memcached_mget_by_key(memcached_st *ptr,
|
616
|
-
+ const char *master_key,
|
617
|
-
size_t master_key_length,
|
618
|
-
- const char **keys,
|
619
|
-
- size_t *key_length,
|
620
|
-
+ const char **keys,
|
621
|
-
+ size_t *key_length,
|
622
|
-
size_t number_of_keys,
|
623
|
-
uint32_t user_spec_len)
|
624
|
-
{
|
625
|
-
@@ -193,7 +193,7 @@
|
626
|
-
return MEMCACHED_FAILURE;
|
627
|
-
}
|
628
|
-
|
629
|
-
- /*
|
630
|
-
+ /*
|
631
|
-
Here is where we pay for the non-block API. We need to remove any data sitting
|
632
|
-
in the queue before we start our get.
|
633
|
-
|
634
|
-
@@ -212,13 +212,13 @@
|
635
|
-
(void)memcached_response(&ptr->hosts[x], buffer, MEMCACHED_DEFAULT_COMMAND_SIZE, &ptr->result);
|
636
|
-
}
|
637
|
-
}
|
638
|
-
-
|
639
|
-
+
|
640
|
-
if (ptr->flags & MEM_BINARY_PROTOCOL)
|
641
|
-
- return binary_mget_by_key(ptr, master_server_key, is_master_key_set, keys,
|
642
|
-
+ return binary_mget_by_key(ptr, master_server_key, is_master_key_set, keys,
|
643
|
-
key_length, number_of_keys);
|
644
|
-
|
645
|
-
if (length_specified) {
|
646
|
-
- if (use_cas)
|
647
|
-
+ if (use_cas)
|
648
|
-
{
|
649
|
-
get_command= "gets_len ";
|
650
|
-
get_command_length= 9;
|
651
|
-
@@ -227,7 +227,7 @@
|
652
|
-
get_command_length= 8;
|
653
|
-
}
|
654
|
-
} else {
|
655
|
-
- if (use_cas)
|
656
|
-
+ if (use_cas)
|
657
|
-
{
|
658
|
-
get_command= "gets ";
|
659
|
-
get_command_length= 5;
|
660
|
-
@@ -237,7 +237,7 @@
|
661
|
-
}
|
662
|
-
}
|
663
|
-
|
664
|
-
- /*
|
665
|
-
+ /*
|
666
|
-
If a server fails we warn about errors and start all over with sending keys
|
667
|
-
to the server.
|
668
|
-
*/
|
669
|
-
@@ -302,7 +302,7 @@
|
670
|
-
rc= MEMCACHED_SOME_ERRORS;
|
671
|
-
continue;
|
672
|
-
}
|
673
|
-
-
|
674
|
-
+
|
675
|
-
ptr->last_server_key = server_key;
|
676
|
-
}
|
677
|
-
|
678
|
-
@@ -329,7 +329,7 @@
|
679
|
-
char *memcached_get_from_last(memcached_st *ptr,
|
680
|
-
const char *key,
|
681
|
-
size_t key_length,
|
682
|
-
- size_t *value_length,
|
683
|
-
+ size_t *value_length,
|
684
|
-
uint32_t *flags,
|
685
|
-
memcached_return *error)
|
686
|
-
{
|
687
|
-
@@ -384,8 +384,8 @@
|
688
|
-
uint32_t dummy_flags;
|
689
|
-
memcached_return dummy_error;
|
690
|
-
|
691
|
-
- (void)memcached_fetch(ptr, NULL, NULL,
|
692
|
-
- &dummy_length, &dummy_flags,
|
693
|
-
+ (void)memcached_fetch(ptr, NULL, NULL,
|
694
|
-
+ &dummy_length, &dummy_flags,
|
695
|
-
&dummy_error);
|
696
|
-
WATCHPOINT_ASSERT(dummy_length == 0);
|
697
|
-
}
|
698
|
-
@@ -393,10 +393,10 @@
|
699
|
-
return value;
|
700
|
-
}
|
701
|
-
|
702
|
-
-static memcached_return simple_binary_mget(memcached_st *ptr,
|
703
|
-
+static memcached_return binary_mget_by_key(memcached_st *ptr,
|
704
|
-
unsigned int master_server_key,
|
705
|
-
bool is_master_key_set,
|
706
|
-
- const char **keys, size_t *key_length,
|
707
|
-
+ const char **keys, size_t *key_length,
|
708
|
-
size_t number_of_keys)
|
709
|
-
{
|
710
|
-
memcached_return rc= MEMCACHED_NOTFOUND;
|
711
|
-
@@ -404,11 +404,11 @@
|
712
|
-
|
713
|
-
int flush= number_of_keys == 1;
|
714
|
-
|
715
|
-
- /*
|
716
|
-
+ /*
|
717
|
-
If a server fails we warn about errors and start all over with sending keys
|
718
|
-
to the server.
|
719
|
-
*/
|
720
|
-
- for (x= 0; x < number_of_keys; x++)
|
721
|
-
+ for (x= 0; x < number_of_keys; x++)
|
722
|
-
{
|
723
|
-
unsigned int server_key;
|
724
|
-
|
725
|
-
@@ -417,13 +417,13 @@
|
726
|
-
else
|
727
|
-
server_key= memcached_generate_hash(ptr, keys[x], key_length[x]);
|
728
|
-
|
729
|
-
- if (memcached_server_response_count(&ptr->hosts[server_key]) == 0)
|
730
|
-
+ if (memcached_server_response_count(&ptr->hosts[server_key]) == 0)
|
731
|
-
{
|
732
|
-
rc= memcached_connect(&ptr->hosts[server_key]);
|
733
|
-
- if (rc != MEMCACHED_SUCCESS)
|
734
|
-
+ if (rc != MEMCACHED_SUCCESS)
|
735
|
-
continue;
|
736
|
-
}
|
737
|
-
-
|
738
|
-
+
|
739
|
-
protocol_binary_request_getk request= {.bytes= {0}};
|
740
|
-
request.message.header.request.magic= PROTOCOL_BINARY_REQ;
|
741
|
-
if (number_of_keys == 1)
|
742
|
-
@@ -432,7 +432,7 @@
|
743
|
-
request.message.header.request.opcode= PROTOCOL_BINARY_CMD_GETKQ;
|
744
|
-
|
745
|
-
memcached_return vk;
|
746
|
-
- vk= memcached_validate_key_length(key_length[x],
|
747
|
-
+ vk= memcached_validate_key_length(ptr->prefix_key_length + key_length[x],
|
748
|
-
ptr->flags & MEM_BINARY_PROTOCOL);
|
749
|
-
unlikely (vk != MEMCACHED_SUCCESS)
|
750
|
-
{
|
751
|
-
@@ -441,26 +441,28 @@
|
752
|
-
return vk;
|
753
|
-
}
|
754
|
-
|
755
|
-
- request.message.header.request.keylen= htons((uint16_t)key_length[x]);
|
756
|
-
+ request.message.header.request.keylen= htons((uint16_t)(ptr->prefix_key_length + key_length[x]));
|
757
|
-
request.message.header.request.datatype= PROTOCOL_BINARY_RAW_BYTES;
|
758
|
-
- request.message.header.request.bodylen= htonl((uint32_t) key_length[x]);
|
759
|
-
-
|
760
|
-
+ request.message.header.request.bodylen= htonl((uint32_t) (ptr->prefix_key_length + key_length[x]));
|
761
|
-
+
|
762
|
-
if ((memcached_io_write(&ptr->hosts[server_key], request.bytes,
|
763
|
-
sizeof(request.bytes), 0) == -1) ||
|
764
|
-
- (memcached_io_write(&ptr->hosts[server_key], keys[x],
|
765
|
-
- key_length[x], (char) flush) == -1))
|
766
|
-
+ (memcached_io_write(&ptr->hosts[server_key], ptr->prefix_key,
|
767
|
-
+ ptr->prefix_key_length, 0) == -1) ||
|
768
|
-
+ (memcached_io_write(&ptr->hosts[server_key], keys[x],
|
769
|
-
+ key_length[x], (char) flush) == -1))
|
770
|
-
{
|
771
|
-
memcached_server_response_reset(&ptr->hosts[server_key]);
|
772
|
-
rc= MEMCACHED_SOME_ERRORS;
|
773
|
-
continue;
|
774
|
-
}
|
775
|
-
- memcached_server_response_increment(&ptr->hosts[server_key]);
|
776
|
-
+ memcached_server_response_increment(&ptr->hosts[server_key]);
|
777
|
-
if ((x > 0 && x == ptr->io_key_prefetch) &&
|
778
|
-
memcached_flush_buffers(ptr) != MEMCACHED_SUCCESS)
|
779
|
-
rc= MEMCACHED_SOME_ERRORS;
|
780
|
-
}
|
781
|
-
|
782
|
-
- if (number_of_keys > 1)
|
783
|
-
+ if (number_of_keys > 1)
|
784
|
-
{
|
785
|
-
/*
|
786
|
-
* Send a noop command to flush the buffers
|
787
|
-
@@ -469,173 +471,28 @@
|
788
|
-
request.message.header.request.magic= PROTOCOL_BINARY_REQ;
|
789
|
-
request.message.header.request.opcode= PROTOCOL_BINARY_CMD_NOOP;
|
790
|
-
request.message.header.request.datatype= PROTOCOL_BINARY_RAW_BYTES;
|
791
|
-
-
|
792
|
-
+
|
793
|
-
for (x= 0; x < ptr->number_of_hosts; x++)
|
794
|
-
- if (memcached_server_response_count(&ptr->hosts[x]))
|
795
|
-
+ if (memcached_server_response_count(&ptr->hosts[x]))
|
796
|
-
{
|
797
|
-
- if (memcached_io_write(&ptr->hosts[x], NULL, 0, 1) == -1)
|
798
|
-
+ if (memcached_io_write(&ptr->hosts[x], NULL, 0, 1) == -1)
|
799
|
-
{
|
800
|
-
memcached_server_response_reset(&ptr->hosts[x]);
|
801
|
-
memcached_io_reset(&ptr->hosts[x]);
|
802
|
-
rc= MEMCACHED_SOME_ERRORS;
|
803
|
-
}
|
804
|
-
|
805
|
-
- if (memcached_io_write(&ptr->hosts[x], request.bytes,
|
806
|
-
- sizeof(request.bytes), 1) == -1)
|
807
|
-
+ if (memcached_io_write(&ptr->hosts[x], request.bytes,
|
808
|
-
+ sizeof(request.bytes), 1) == -1)
|
809
|
-
{
|
810
|
-
memcached_server_response_reset(&ptr->hosts[x]);
|
811
|
-
memcached_io_reset(&ptr->hosts[x]);
|
812
|
-
rc= MEMCACHED_SOME_ERRORS;
|
813
|
-
}
|
814
|
-
- memcached_server_response_increment(&ptr->hosts[x]);
|
815
|
-
- }
|
816
|
-
- }
|
817
|
-
-
|
818
|
-
-
|
819
|
-
- return rc;
|
820
|
-
-}
|
821
|
-
-
|
822
|
-
-static memcached_return replication_binary_mget(memcached_st *ptr,
|
823
|
-
- uint32_t* hash, bool* dead_servers,
|
824
|
-
- const char **keys, size_t *key_length,
|
825
|
-
- size_t number_of_keys)
|
826
|
-
-{
|
827
|
-
- memcached_return rc= MEMCACHED_NOTFOUND;
|
828
|
-
- uint32_t x;
|
829
|
-
-
|
830
|
-
- int flush= number_of_keys == 1;
|
831
|
-
-
|
832
|
-
- for (uint32_t replica= 0; replica <= ptr->number_of_replicas; ++replica)
|
833
|
-
- {
|
834
|
-
- bool success= true;
|
835
|
-
-
|
836
|
-
- for (x= 0; x < number_of_keys; ++x)
|
837
|
-
- {
|
838
|
-
- if (hash[x] == ptr->number_of_hosts)
|
839
|
-
- continue; /* Already successfully sent */
|
840
|
-
-
|
841
|
-
- uint32_t server= hash[x] + replica;
|
842
|
-
- while (server >= ptr->number_of_hosts)
|
843
|
-
- server -= ptr->number_of_hosts;
|
844
|
-
-
|
845
|
-
- if (dead_servers[server])
|
846
|
-
- continue;
|
847
|
-
-
|
848
|
-
- if (memcached_server_response_count(&ptr->hosts[server]) == 0)
|
849
|
-
- {
|
850
|
-
- rc= memcached_connect(&ptr->hosts[server]);
|
851
|
-
- if (rc != MEMCACHED_SUCCESS)
|
852
|
-
- {
|
853
|
-
- memcached_io_reset(&ptr->hosts[server]);
|
854
|
-
- dead_servers[server]= true;
|
855
|
-
- success= false;
|
856
|
-
- continue;
|
857
|
-
- }
|
858
|
-
+ memcached_server_response_increment(&ptr->hosts[x]);
|
859
|
-
}
|
860
|
-
-
|
861
|
-
- protocol_binary_request_getk request= {.bytes= {0}};
|
862
|
-
- request.message.header.request.magic= PROTOCOL_BINARY_REQ;
|
863
|
-
- if (number_of_keys == 1)
|
864
|
-
- request.message.header.request.opcode= PROTOCOL_BINARY_CMD_GETK;
|
865
|
-
- else
|
866
|
-
- request.message.header.request.opcode= PROTOCOL_BINARY_CMD_GETKQ;
|
867
|
-
-
|
868
|
-
- request.message.header.request.keylen= htons((uint16_t)key_length[x]);
|
869
|
-
- request.message.header.request.datatype= PROTOCOL_BINARY_RAW_BYTES;
|
870
|
-
- request.message.header.request.bodylen= htonl((uint32_t) key_length[x]);
|
871
|
-
-
|
872
|
-
- if ((memcached_io_write(&ptr->hosts[server], request.bytes,
|
873
|
-
- sizeof(request.bytes), 0) == -1) ||
|
874
|
-
- (memcached_io_write(&ptr->hosts[server], keys[x],
|
875
|
-
- key_length[x], (char) flush) == -1))
|
876
|
-
- {
|
877
|
-
- memcached_io_reset(&ptr->hosts[server]);
|
878
|
-
- dead_servers[server]= true;
|
879
|
-
- success= false;
|
880
|
-
- continue;
|
881
|
-
- }
|
882
|
-
- memcached_server_response_increment(&ptr->hosts[server]);
|
883
|
-
- }
|
884
|
-
-
|
885
|
-
- if (number_of_keys > 1)
|
886
|
-
- {
|
887
|
-
- /*
|
888
|
-
- * Send a noop command to flush the buffers
|
889
|
-
- */
|
890
|
-
- protocol_binary_request_noop request= {.bytes= {0}};
|
891
|
-
- request.message.header.request.magic= PROTOCOL_BINARY_REQ;
|
892
|
-
- request.message.header.request.opcode= PROTOCOL_BINARY_CMD_NOOP;
|
893
|
-
- request.message.header.request.datatype= PROTOCOL_BINARY_RAW_BYTES;
|
894
|
-
-
|
895
|
-
- for (x= 0; x < ptr->number_of_hosts; x++)
|
896
|
-
- if (memcached_server_response_count(&ptr->hosts[x]))
|
897
|
-
- {
|
898
|
-
- if (memcached_io_write(&ptr->hosts[x], request.bytes,
|
899
|
-
- sizeof(request.bytes), 1) == -1)
|
900
|
-
- {
|
901
|
-
- memcached_io_reset(&ptr->hosts[x]);
|
902
|
-
- dead_servers[x]= true;
|
903
|
-
- success= false;
|
904
|
-
- }
|
905
|
-
- memcached_server_response_increment(&ptr->hosts[x]);
|
906
|
-
-
|
907
|
-
- /* mark all of the messages bound for this server as sent! */
|
908
|
-
- for (x= 0; x < number_of_keys; ++x)
|
909
|
-
- if (hash[x] == x)
|
910
|
-
- hash[x]= ptr->number_of_hosts;
|
911
|
-
- }
|
912
|
-
}
|
913
|
-
|
914
|
-
- if (success)
|
915
|
-
- break;
|
916
|
-
- }
|
917
|
-
-
|
918
|
-
- return rc;
|
919
|
-
-}
|
920
|
-
-
|
921
|
-
-static memcached_return binary_mget_by_key(memcached_st *ptr,
|
922
|
-
- unsigned int master_server_key,
|
923
|
-
- bool is_master_key_set,
|
924
|
-
- const char **keys, size_t *key_length,
|
925
|
-
- size_t number_of_keys)
|
926
|
-
-{
|
927
|
-
- memcached_return rc;
|
928
|
-
-
|
929
|
-
- if (ptr->number_of_replicas == 0)
|
930
|
-
- {
|
931
|
-
- rc= simple_binary_mget(ptr, master_server_key, is_master_key_set,
|
932
|
-
- keys, key_length, number_of_keys);
|
933
|
-
- }
|
934
|
-
- else
|
935
|
-
- {
|
936
|
-
- uint32_t* hash;
|
937
|
-
- bool* dead_servers;
|
938
|
-
-
|
939
|
-
- hash= ptr->call_malloc(ptr, sizeof(uint32_t) * number_of_keys);
|
940
|
-
- dead_servers= ptr->call_calloc(ptr, ptr->number_of_hosts, sizeof(bool));
|
941
|
-
-
|
942
|
-
- if (hash == NULL || dead_servers == NULL)
|
943
|
-
- {
|
944
|
-
- ptr->call_free(ptr, hash);
|
945
|
-
- ptr->call_free(ptr, dead_servers);
|
946
|
-
- return MEMCACHED_MEMORY_ALLOCATION_FAILURE;
|
947
|
-
- }
|
948
|
-
-
|
949
|
-
- if (is_master_key_set)
|
950
|
-
- for (unsigned int x= 0; x < number_of_keys; x++)
|
951
|
-
- hash[x]= master_server_key;
|
952
|
-
- else
|
953
|
-
- for (unsigned int x= 0; x < number_of_keys; x++)
|
954
|
-
- hash[x]= memcached_generate_hash(ptr, keys[x], key_length[x]);
|
955
|
-
-
|
956
|
-
- rc= replication_binary_mget(ptr, hash, dead_servers, keys,
|
957
|
-
- key_length, number_of_keys);
|
958
|
-
-
|
959
|
-
- ptr->call_free(ptr, hash);
|
960
|
-
- ptr->call_free(ptr, dead_servers);
|
961
|
-
-
|
962
|
-
- return MEMCACHED_SUCCESS;
|
963
|
-
- }
|
964
|
-
|
965
|
-
return rc;
|
966
|
-
}
|
967
|
-
diff -ur a/libmemcached-0.32/libmemcached/memcached_hash.c b/libmemcached-0.32/libmemcached/memcached_hash.c
|
968
|
-
--- a/libmemcached-0.32/libmemcached/memcached_hash.c 2011-03-02 20:23:03.000000000 -0800
|
969
|
-
+++ b/libmemcached-0.32/libmemcached/memcached_hash.c 2011-03-02 21:44:00.000000000 -0800
|
970
|
-
@@ -32,13 +32,13 @@
|
971
|
-
hash= 1;
|
972
|
-
break;
|
973
|
-
/* FNV hash'es lifted from Dustin Sallings work */
|
974
|
-
- case MEMCACHED_HASH_FNV1_64:
|
975
|
-
+ case MEMCACHED_HASH_FNV1_64:
|
976
|
-
{
|
977
|
-
/* Thanks to pierre@demartines.com for the pointer */
|
978
|
-
uint64_t temp_hash;
|
979
|
-
|
980
|
-
temp_hash= FNV_64_INIT;
|
981
|
-
- for (x= 0; x < key_length; x++)
|
982
|
-
+ for (x= 0; x < key_length; x++)
|
983
|
-
{
|
984
|
-
temp_hash *= FNV_64_PRIME;
|
985
|
-
temp_hash ^= (uint64_t)key[x];
|
986
|
-
@@ -46,10 +46,10 @@
|
987
|
-
hash= (uint32_t)temp_hash;
|
988
|
-
}
|
989
|
-
break;
|
990
|
-
- case MEMCACHED_HASH_FNV1A_64:
|
991
|
-
+ case MEMCACHED_HASH_FNV1A_64:
|
992
|
-
{
|
993
|
-
hash= (uint32_t) FNV_64_INIT;
|
994
|
-
- for (x= 0; x < key_length; x++)
|
995
|
-
+ for (x= 0; x < key_length; x++)
|
996
|
-
{
|
997
|
-
uint32_t val= (uint32_t)key[x];
|
998
|
-
hash ^= val;
|
999
|
-
@@ -57,10 +57,10 @@
|
1000
|
-
}
|
1001
|
-
}
|
1002
|
-
break;
|
1003
|
-
- case MEMCACHED_HASH_FNV1_32:
|
1004
|
-
+ case MEMCACHED_HASH_FNV1_32:
|
1005
|
-
{
|
1006
|
-
hash= FNV_32_INIT;
|
1007
|
-
- for (x= 0; x < key_length; x++)
|
1008
|
-
+ for (x= 0; x < key_length; x++)
|
1009
|
-
{
|
1010
|
-
uint32_t val= (uint32_t)key[x];
|
1011
|
-
hash *= FNV_32_PRIME;
|
1012
|
-
@@ -68,10 +68,10 @@
|
1013
|
-
}
|
1014
|
-
}
|
1015
|
-
break;
|
1016
|
-
- case MEMCACHED_HASH_FNV1A_32:
|
1017
|
-
+ case MEMCACHED_HASH_FNV1A_32:
|
1018
|
-
{
|
1019
|
-
hash= FNV_32_INIT;
|
1020
|
-
- for (x= 0; x < key_length; x++)
|
1021
|
-
+ for (x= 0; x < key_length; x++)
|
1022
|
-
{
|
1023
|
-
uint32_t val= (uint32_t)key[x];
|
1024
|
-
hash ^= val;
|
1025
|
-
@@ -127,7 +127,7 @@
|
1026
|
-
|
1027
|
-
static uint32_t dispatch_host(memcached_st *ptr, uint32_t hash)
|
1028
|
-
{
|
1029
|
-
- switch (ptr->distribution)
|
1030
|
-
+ switch (ptr->distribution)
|
1031
|
-
{
|
1032
|
-
case MEMCACHED_DISTRIBUTION_CONSISTENT:
|
1033
|
-
case MEMCACHED_DISTRIBUTION_CONSISTENT_KETAMA:
|
1034
|
-
@@ -151,8 +151,8 @@
|
1035
|
-
if (right == end)
|
1036
|
-
right= begin;
|
1037
|
-
return right->index;
|
1038
|
-
- }
|
1039
|
-
- case MEMCACHED_DISTRIBUTION_MODULA:
|
1040
|
-
+ }
|
1041
|
-
+ case MEMCACHED_DISTRIBUTION_MODULA:
|
1042
|
-
return memcached_live_host_index(ptr, hash);
|
1043
|
-
case MEMCACHED_DISTRIBUTION_RANDOM:
|
1044
|
-
return memcached_live_host_index(ptr, (uint32_t) random());
|
1045
|
-
@@ -164,8 +164,8 @@
|
1046
|
-
/* NOTREACHED */
|
1047
|
-
}
|
1048
|
-
|
1049
|
-
-/*
|
1050
|
-
- One day make this public, and have it return the actual memcached_server_st
|
1051
|
-
+/*
|
1052
|
-
+ One day make this public, and have it return the actual memcached_server_st
|
1053
|
-
to the calling application.
|
1054
|
-
*/
|
1055
|
-
uint32_t memcached_generate_hash(memcached_st *ptr, const char *key, size_t key_length)
|
1056
|
-
@@ -225,7 +225,7 @@
|
1057
|
-
const char *ptr= key;
|
1058
|
-
uint32_t value= 0;
|
1059
|
-
|
1060
|
-
- while (key_length--)
|
1061
|
-
+ while (key_length--)
|
1062
|
-
{
|
1063
|
-
uint32_t val= (uint32_t) *ptr++;
|
1064
|
-
value += val;
|
1065
|
-
@@ -234,7 +234,7 @@
|
1066
|
-
}
|
1067
|
-
value += (value << 3);
|
1068
|
-
value ^= (value >> 11);
|
1069
|
-
- value += (value << 15);
|
1070
|
-
+ value += (value << 15);
|
1071
|
-
|
1072
|
-
return value == 0 ? 1 : (uint32_t) value;
|
1073
|
-
}
|
1074
|
-
diff -ur a/libmemcached-0.32/libmemcached/memcached_storage.c b/libmemcached-0.32/libmemcached/memcached_storage.c
|
1075
|
-
--- a/libmemcached-0.32/libmemcached/memcached_storage.c 2011-03-02 20:23:03.000000000 -0800
|
1076
|
-
+++ b/libmemcached-0.32/libmemcached/memcached_storage.c 2011-03-02 22:09:56.000000000 -0800
|
1077
|
-
@@ -16,6 +16,7 @@
|
1078
|
-
PREPEND_OP,
|
1079
|
-
APPEND_OP,
|
1080
|
-
CAS_OP,
|
1081
|
-
+ DELETE_OP,
|
1082
|
-
} memcached_storage_action;
|
1083
|
-
|
1084
|
-
/* Inline this */
|
1085
|
-
@@ -25,6 +26,8 @@
|
1086
|
-
{
|
1087
|
-
case SET_OP:
|
1088
|
-
return "set ";
|
1089
|
-
+ case DELETE_OP:
|
1090
|
-
+ return "delete ";
|
1091
|
-
case REPLACE_OP:
|
1092
|
-
return "replace ";
|
1093
|
-
case ADD_OP:
|
1094
|
-
@@ -43,21 +46,21 @@
|
1095
|
-
}
|
1096
|
-
|
1097
|
-
static memcached_return memcached_send_binary(memcached_st *ptr,
|
1098
|
-
- const char *master_key,
|
1099
|
-
+ const char *master_key,
|
1100
|
-
size_t master_key_length,
|
1101
|
-
- const char *key,
|
1102
|
-
- size_t key_length,
|
1103
|
-
- const char *value,
|
1104
|
-
- size_t value_length,
|
1105
|
-
+ const char *key,
|
1106
|
-
+ size_t key_length,
|
1107
|
-
+ const char *value,
|
1108
|
-
+ size_t value_length,
|
1109
|
-
time_t expiration,
|
1110
|
-
uint32_t flags,
|
1111
|
-
uint64_t cas,
|
1112
|
-
memcached_storage_action verb);
|
1113
|
-
|
1114
|
-
-static inline memcached_return memcached_send(memcached_st *ptr,
|
1115
|
-
- const char *master_key, size_t master_key_length,
|
1116
|
-
- const char *key, size_t key_length,
|
1117
|
-
- const char *value, size_t value_length,
|
1118
|
-
+static inline memcached_return memcached_send(memcached_st *ptr,
|
1119
|
-
+ const char *master_key, size_t master_key_length,
|
1120
|
-
+ const char *key, size_t key_length,
|
1121
|
-
+ const char *value, size_t value_length,
|
1122
|
-
time_t expiration,
|
1123
|
-
uint32_t flags,
|
1124
|
-
uint64_t cas,
|
1125
|
-
@@ -75,7 +78,7 @@
|
1126
|
-
rc= memcached_validate_key_length(key_length, ptr->flags & MEM_BINARY_PROTOCOL);
|
1127
|
-
unlikely (rc != MEMCACHED_SUCCESS)
|
1128
|
-
return rc;
|
1129
|
-
-
|
1130
|
-
+
|
1131
|
-
unlikely (ptr->number_of_hosts == 0)
|
1132
|
-
return MEMCACHED_NO_SERVERS;
|
1133
|
-
|
1134
|
-
@@ -91,12 +94,12 @@
|
1135
|
-
server_key= memcached_generate_hash(ptr, master_key, master_key_length);
|
1136
|
-
|
1137
|
-
if (cas)
|
1138
|
-
- write_length= (size_t) snprintf(buffer, MEMCACHED_DEFAULT_COMMAND_SIZE,
|
1139
|
-
- "%s %s%.*s %u %llu %zu %llu%s\r\n",
|
1140
|
-
+ write_length= (size_t) snprintf(buffer, MEMCACHED_DEFAULT_COMMAND_SIZE,
|
1141
|
-
+ "%s %s%.*s %u %llu %zu %llu%s\r\n",
|
1142
|
-
storage_op_string(verb),
|
1143
|
-
ptr->prefix_key,
|
1144
|
-
- (int)key_length, key, flags,
|
1145
|
-
- (unsigned long long)expiration, value_length,
|
1146
|
-
+ (int)key_length, key, flags,
|
1147
|
-
+ (unsigned long long)expiration, value_length,
|
1148
|
-
(unsigned long long)cas,
|
1149
|
-
(ptr->flags & MEM_NOREPLY) ? " noreply" : "");
|
1150
|
-
else
|
1151
|
-
@@ -111,18 +114,23 @@
|
1152
|
-
buffer_ptr= memcpy(buffer_ptr + strlen(command) , ptr->prefix_key, strlen(ptr->prefix_key));
|
1153
|
-
|
1154
|
-
/* Copy in the key, adjust point if a key prefix was used. */
|
1155
|
-
- buffer_ptr= memcpy(buffer_ptr + (ptr->prefix_key ? strlen(ptr->prefix_key) : 0),
|
1156
|
-
+ buffer_ptr= memcpy(buffer_ptr + (ptr->prefix_key ? strlen(ptr->prefix_key) : 0),
|
1157
|
-
key, key_length);
|
1158
|
-
buffer_ptr+= key_length;
|
1159
|
-
- buffer_ptr[0]= ' ';
|
1160
|
-
+ buffer_ptr[0]= ' ';
|
1161
|
-
buffer_ptr++;
|
1162
|
-
-
|
1163
|
-
write_length= (size_t)(buffer_ptr - buffer);
|
1164
|
-
- write_length+= (size_t) snprintf(buffer_ptr, MEMCACHED_DEFAULT_COMMAND_SIZE,
|
1165
|
-
- "%u %llu %zu%s\r\n",
|
1166
|
-
- flags,
|
1167
|
-
- (unsigned long long)expiration, value_length,
|
1168
|
-
- (ptr->flags & MEM_NOREPLY) ? " noreply" : "");
|
1169
|
-
+
|
1170
|
-
+ if (verb == DELETE_OP) {
|
1171
|
-
+ if (ptr->flags & MEM_NOREPLY)
|
1172
|
-
+ write_length+= (size_t) snprintf(buffer_ptr, MEMCACHED_DEFAULT_COMMAND_SIZE, "noreply");
|
1173
|
-
+ } else {
|
1174
|
-
+ write_length+= (size_t) snprintf(buffer_ptr, MEMCACHED_DEFAULT_COMMAND_SIZE,
|
1175
|
-
+ "%u %llu %zu%s\r\n",
|
1176
|
-
+ flags,
|
1177
|
-
+ (unsigned long long)expiration, value_length,
|
1178
|
-
+ (ptr->flags & MEM_NOREPLY) ? " noreply" : "");
|
1179
|
-
+ }
|
1180
|
-
}
|
1181
|
-
|
1182
|
-
if (ptr->flags & MEM_USE_UDP && ptr->flags & MEM_BUFFER_REQUESTS)
|
1183
|
-
@@ -147,7 +155,7 @@
|
1184
|
-
return MEMCACHED_WRITE_FAILURE;
|
1185
|
-
|
1186
|
-
if ((ptr->flags & MEM_BUFFER_REQUESTS) &&
|
1187
|
-
- (verb == SET_OP || verb == PREPEND_OP || verb == APPEND_OP))
|
1188
|
-
+ (verb == SET_OP || verb == PREPEND_OP || verb == APPEND_OP || verb == DELETE_OP))
|
1189
|
-
to_write= 0;
|
1190
|
-
else
|
1191
|
-
to_write= 1;
|
1192
|
-
@@ -162,183 +170,210 @@
|
1193
|
-
return MEMCACHED_BUFFERED;
|
1194
|
-
|
1195
|
-
rc= memcached_response(&ptr->hosts[server_key], buffer, MEMCACHED_DEFAULT_COMMAND_SIZE, NULL);
|
1196
|
-
- if (rc == MEMCACHED_STORED)
|
1197
|
-
- return MEMCACHED_SUCCESS;
|
1198
|
-
+ if (rc == MEMCACHED_STORED || rc == MEMCACHED_DELETED)
|
1199
|
-
+ return MEMCACHED_SUCCESS;
|
1200
|
-
+
|
1201
|
-
return rc;
|
1202
|
-
}
|
1203
|
-
|
1204
|
-
|
1205
|
-
-memcached_return memcached_set(memcached_st *ptr, const char *key, size_t key_length,
|
1206
|
-
- const char *value, size_t value_length,
|
1207
|
-
+memcached_return memcached_set(memcached_st *ptr, const char *key, size_t key_length,
|
1208
|
-
+ const char *value, size_t value_length,
|
1209
|
-
time_t expiration,
|
1210
|
-
uint32_t flags)
|
1211
|
-
{
|
1212
|
-
memcached_return rc;
|
1213
|
-
LIBMEMCACHED_MEMCACHED_SET_START();
|
1214
|
-
- rc= memcached_send(ptr, key, key_length,
|
1215
|
-
+ rc= memcached_send(ptr, key, key_length,
|
1216
|
-
key, key_length, value, value_length,
|
1217
|
-
expiration, flags, 0, SET_OP);
|
1218
|
-
LIBMEMCACHED_MEMCACHED_SET_END();
|
1219
|
-
return rc;
|
1220
|
-
}
|
1221
|
-
|
1222
|
-
-memcached_return memcached_add(memcached_st *ptr,
|
1223
|
-
+memcached_return memcached_delete(memcached_st *ptr, const char *key, size_t key_length,
|
1224
|
-
+ time_t expiration)
|
1225
|
-
+{
|
1226
|
-
+ memcached_return rc;
|
1227
|
-
+ LIBMEMCACHED_MEMCACHED_DELETE_START();
|
1228
|
-
+ rc= memcached_send(ptr, key, key_length,
|
1229
|
-
+ key, key_length, "", 0,
|
1230
|
-
+ expiration, 0, 0, DELETE_OP);
|
1231
|
-
+ LIBMEMCACHED_MEMCACHED_DELETE_END();
|
1232
|
-
+ return rc;
|
1233
|
-
+}
|
1234
|
-
+
|
1235
|
-
+memcached_return memcached_delete_by_key(memcached_st *ptr,
|
1236
|
-
+ const char *master_key, size_t master_key_length,
|
1237
|
-
+ const char *key, size_t key_length,
|
1238
|
-
+ time_t expiration)
|
1239
|
-
+{
|
1240
|
-
+ memcached_return rc;
|
1241
|
-
+ LIBMEMCACHED_MEMCACHED_DELETE_START();
|
1242
|
-
+ rc= memcached_send(ptr, master_key, master_key_length,
|
1243
|
-
+ key, key_length, "", 0,
|
1244
|
-
+ expiration, 0, 0, DELETE_OP);
|
1245
|
-
+ LIBMEMCACHED_MEMCACHED_DELETE_END();
|
1246
|
-
+ return rc;
|
1247
|
-
+}
|
1248
|
-
+
|
1249
|
-
+memcached_return memcached_add(memcached_st *ptr,
|
1250
|
-
const char *key, size_t key_length,
|
1251
|
-
- const char *value, size_t value_length,
|
1252
|
-
+ const char *value, size_t value_length,
|
1253
|
-
time_t expiration,
|
1254
|
-
uint32_t flags)
|
1255
|
-
{
|
1256
|
-
memcached_return rc;
|
1257
|
-
LIBMEMCACHED_MEMCACHED_ADD_START();
|
1258
|
-
- rc= memcached_send(ptr, key, key_length,
|
1259
|
-
+ rc= memcached_send(ptr, key, key_length,
|
1260
|
-
key, key_length, value, value_length,
|
1261
|
-
expiration, flags, 0, ADD_OP);
|
1262
|
-
LIBMEMCACHED_MEMCACHED_ADD_END();
|
1263
|
-
return rc;
|
1264
|
-
}
|
1265
|
-
|
1266
|
-
-memcached_return memcached_replace(memcached_st *ptr,
|
1267
|
-
+memcached_return memcached_replace(memcached_st *ptr,
|
1268
|
-
const char *key, size_t key_length,
|
1269
|
-
- const char *value, size_t value_length,
|
1270
|
-
+ const char *value, size_t value_length,
|
1271
|
-
time_t expiration,
|
1272
|
-
uint32_t flags)
|
1273
|
-
{
|
1274
|
-
memcached_return rc;
|
1275
|
-
LIBMEMCACHED_MEMCACHED_REPLACE_START();
|
1276
|
-
- rc= memcached_send(ptr, key, key_length,
|
1277
|
-
+ rc= memcached_send(ptr, key, key_length,
|
1278
|
-
key, key_length, value, value_length,
|
1279
|
-
expiration, flags, 0, REPLACE_OP);
|
1280
|
-
LIBMEMCACHED_MEMCACHED_REPLACE_END();
|
1281
|
-
return rc;
|
1282
|
-
}
|
1283
|
-
|
1284
|
-
-memcached_return memcached_prepend(memcached_st *ptr,
|
1285
|
-
+memcached_return memcached_prepend(memcached_st *ptr,
|
1286
|
-
const char *key, size_t key_length,
|
1287
|
-
- const char *value, size_t value_length,
|
1288
|
-
+ const char *value, size_t value_length,
|
1289
|
-
time_t expiration,
|
1290
|
-
uint32_t flags)
|
1291
|
-
{
|
1292
|
-
memcached_return rc;
|
1293
|
-
- rc= memcached_send(ptr, key, key_length,
|
1294
|
-
+ rc= memcached_send(ptr, key, key_length,
|
1295
|
-
key, key_length, value, value_length,
|
1296
|
-
expiration, flags, 0, PREPEND_OP);
|
1297
|
-
return rc;
|
1298
|
-
}
|
1299
|
-
|
1300
|
-
-memcached_return memcached_append(memcached_st *ptr,
|
1301
|
-
+memcached_return memcached_append(memcached_st *ptr,
|
1302
|
-
const char *key, size_t key_length,
|
1303
|
-
- const char *value, size_t value_length,
|
1304
|
-
+ const char *value, size_t value_length,
|
1305
|
-
time_t expiration,
|
1306
|
-
uint32_t flags)
|
1307
|
-
{
|
1308
|
-
memcached_return rc;
|
1309
|
-
- rc= memcached_send(ptr, key, key_length,
|
1310
|
-
+ rc= memcached_send(ptr, key, key_length,
|
1311
|
-
key, key_length, value, value_length,
|
1312
|
-
expiration, flags, 0, APPEND_OP);
|
1313
|
-
return rc;
|
1314
|
-
}
|
1315
|
-
|
1316
|
-
-memcached_return memcached_cas(memcached_st *ptr,
|
1317
|
-
+memcached_return memcached_cas(memcached_st *ptr,
|
1318
|
-
const char *key, size_t key_length,
|
1319
|
-
- const char *value, size_t value_length,
|
1320
|
-
+ const char *value, size_t value_length,
|
1321
|
-
time_t expiration,
|
1322
|
-
uint32_t flags,
|
1323
|
-
uint64_t cas)
|
1324
|
-
{
|
1325
|
-
memcached_return rc;
|
1326
|
-
- rc= memcached_send(ptr, key, key_length,
|
1327
|
-
+ rc= memcached_send(ptr, key, key_length,
|
1328
|
-
key, key_length, value, value_length,
|
1329
|
-
expiration, flags, cas, CAS_OP);
|
1330
|
-
return rc;
|
1331
|
-
}
|
1332
|
-
|
1333
|
-
-memcached_return memcached_set_by_key(memcached_st *ptr,
|
1334
|
-
- const char *master_key __attribute__((unused)),
|
1335
|
-
- size_t master_key_length __attribute__((unused)),
|
1336
|
-
- const char *key, size_t key_length,
|
1337
|
-
- const char *value, size_t value_length,
|
1338
|
-
+memcached_return memcached_set_by_key(memcached_st *ptr,
|
1339
|
-
+ const char *master_key __attribute__((unused)),
|
1340
|
-
+ size_t master_key_length __attribute__((unused)),
|
1341
|
-
+ const char *key, size_t key_length,
|
1342
|
-
+ const char *value, size_t value_length,
|
1343
|
-
time_t expiration,
|
1344
|
-
uint32_t flags)
|
1345
|
-
{
|
1346
|
-
memcached_return rc;
|
1347
|
-
LIBMEMCACHED_MEMCACHED_SET_START();
|
1348
|
-
- rc= memcached_send(ptr, master_key, master_key_length,
|
1349
|
-
+ rc= memcached_send(ptr, master_key, master_key_length,
|
1350
|
-
key, key_length, value, value_length,
|
1351
|
-
expiration, flags, 0, SET_OP);
|
1352
|
-
LIBMEMCACHED_MEMCACHED_SET_END();
|
1353
|
-
return rc;
|
1354
|
-
}
|
1355
|
-
|
1356
|
-
-memcached_return memcached_add_by_key(memcached_st *ptr,
|
1357
|
-
+memcached_return memcached_add_by_key(memcached_st *ptr,
|
1358
|
-
const char *master_key, size_t master_key_length,
|
1359
|
-
const char *key, size_t key_length,
|
1360
|
-
- const char *value, size_t value_length,
|
1361
|
-
+ const char *value, size_t value_length,
|
1362
|
-
time_t expiration,
|
1363
|
-
uint32_t flags)
|
1364
|
-
{
|
1365
|
-
memcached_return rc;
|
1366
|
-
LIBMEMCACHED_MEMCACHED_ADD_START();
|
1367
|
-
- rc= memcached_send(ptr, master_key, master_key_length,
|
1368
|
-
+ rc= memcached_send(ptr, master_key, master_key_length,
|
1369
|
-
key, key_length, value, value_length,
|
1370
|
-
expiration, flags, 0, ADD_OP);
|
1371
|
-
LIBMEMCACHED_MEMCACHED_ADD_END();
|
1372
|
-
return rc;
|
1373
|
-
}
|
1374
|
-
|
1375
|
-
-memcached_return memcached_replace_by_key(memcached_st *ptr,
|
1376
|
-
+memcached_return memcached_replace_by_key(memcached_st *ptr,
|
1377
|
-
const char *master_key, size_t master_key_length,
|
1378
|
-
const char *key, size_t key_length,
|
1379
|
-
- const char *value, size_t value_length,
|
1380
|
-
+ const char *value, size_t value_length,
|
1381
|
-
time_t expiration,
|
1382
|
-
uint32_t flags)
|
1383
|
-
{
|
1384
|
-
memcached_return rc;
|
1385
|
-
LIBMEMCACHED_MEMCACHED_REPLACE_START();
|
1386
|
-
- rc= memcached_send(ptr, master_key, master_key_length,
|
1387
|
-
+ rc= memcached_send(ptr, master_key, master_key_length,
|
1388
|
-
key, key_length, value, value_length,
|
1389
|
-
expiration, flags, 0, REPLACE_OP);
|
1390
|
-
LIBMEMCACHED_MEMCACHED_REPLACE_END();
|
1391
|
-
return rc;
|
1392
|
-
}
|
1393
|
-
|
1394
|
-
-memcached_return memcached_prepend_by_key(memcached_st *ptr,
|
1395
|
-
+memcached_return memcached_prepend_by_key(memcached_st *ptr,
|
1396
|
-
const char *master_key, size_t master_key_length,
|
1397
|
-
const char *key, size_t key_length,
|
1398
|
-
- const char *value, size_t value_length,
|
1399
|
-
+ const char *value, size_t value_length,
|
1400
|
-
time_t expiration,
|
1401
|
-
uint32_t flags)
|
1402
|
-
{
|
1403
|
-
memcached_return rc;
|
1404
|
-
- rc= memcached_send(ptr, master_key, master_key_length,
|
1405
|
-
+ rc= memcached_send(ptr, master_key, master_key_length,
|
1406
|
-
key, key_length, value, value_length,
|
1407
|
-
expiration, flags, 0, PREPEND_OP);
|
1408
|
-
return rc;
|
1409
|
-
}
|
1410
|
-
|
1411
|
-
-memcached_return memcached_append_by_key(memcached_st *ptr,
|
1412
|
-
+memcached_return memcached_append_by_key(memcached_st *ptr,
|
1413
|
-
const char *master_key, size_t master_key_length,
|
1414
|
-
const char *key, size_t key_length,
|
1415
|
-
- const char *value, size_t value_length,
|
1416
|
-
+ const char *value, size_t value_length,
|
1417
|
-
time_t expiration,
|
1418
|
-
uint32_t flags)
|
1419
|
-
{
|
1420
|
-
memcached_return rc;
|
1421
|
-
- rc= memcached_send(ptr, master_key, master_key_length,
|
1422
|
-
+ rc= memcached_send(ptr, master_key, master_key_length,
|
1423
|
-
key, key_length, value, value_length,
|
1424
|
-
expiration, flags, 0, APPEND_OP);
|
1425
|
-
return rc;
|
1426
|
-
}
|
1427
|
-
|
1428
|
-
-memcached_return memcached_cas_by_key(memcached_st *ptr,
|
1429
|
-
+memcached_return memcached_cas_by_key(memcached_st *ptr,
|
1430
|
-
const char *master_key, size_t master_key_length,
|
1431
|
-
const char *key, size_t key_length,
|
1432
|
-
- const char *value, size_t value_length,
|
1433
|
-
+ const char *value, size_t value_length,
|
1434
|
-
time_t expiration,
|
1435
|
-
uint32_t flags,
|
1436
|
-
uint64_t cas)
|
1437
|
-
{
|
1438
|
-
memcached_return rc;
|
1439
|
-
- rc= memcached_send(ptr, master_key, master_key_length,
|
1440
|
-
+ rc= memcached_send(ptr, master_key, master_key_length,
|
1441
|
-
key, key_length, value, value_length,
|
1442
|
-
expiration, flags, cas, CAS_OP);
|
1443
|
-
return rc;
|
1444
|
-
@@ -356,6 +391,9 @@
|
1445
|
-
case SET_OP:
|
1446
|
-
ret=PROTOCOL_BINARY_CMD_SETQ;
|
1447
|
-
break;
|
1448
|
-
+ case DELETE_OP:
|
1449
|
-
+ ret=PROTOCOL_BINARY_CMD_DELETEQ;
|
1450
|
-
+ break;
|
1451
|
-
case ADD_OP:
|
1452
|
-
ret=PROTOCOL_BINARY_CMD_ADDQ;
|
1453
|
-
break;
|
1454
|
-
@@ -379,6 +417,9 @@
|
1455
|
-
case SET_OP:
|
1456
|
-
ret=PROTOCOL_BINARY_CMD_SET;
|
1457
|
-
break;
|
1458
|
-
+ case DELETE_OP:
|
1459
|
-
+ ret=PROTOCOL_BINARY_CMD_DELETE;
|
1460
|
-
+ break;
|
1461
|
-
case ADD_OP:
|
1462
|
-
ret=PROTOCOL_BINARY_CMD_ADD;
|
1463
|
-
break;
|
1464
|
-
@@ -403,12 +444,12 @@
|
1465
|
-
|
1466
|
-
|
1467
|
-
static memcached_return memcached_send_binary(memcached_st *ptr,
|
1468
|
-
- const char *master_key,
|
1469
|
-
+ const char *master_key,
|
1470
|
-
size_t master_key_length,
|
1471
|
-
const char *key,
|
1472
|
-
- size_t key_length,
|
1473
|
-
- const char *value,
|
1474
|
-
- size_t value_length,
|
1475
|
-
+ size_t key_length,
|
1476
|
-
+ const char *value,
|
1477
|
-
+ size_t value_length,
|
1478
|
-
time_t expiration,
|
1479
|
-
uint32_t flags,
|
1480
|
-
uint64_t cas,
|
1481
|
-
@@ -417,77 +458,57 @@
|
1482
|
-
uint8_t flush;
|
1483
|
-
protocol_binary_request_set request= {.bytes= {0}};
|
1484
|
-
size_t send_length= sizeof(request.bytes);
|
1485
|
-
- uint32_t server_key= memcached_generate_hash(ptr, master_key,
|
1486
|
-
+ uint32_t server_key= memcached_generate_hash(ptr, master_key,
|
1487
|
-
master_key_length);
|
1488
|
-
memcached_server_st *server= &ptr->hosts[server_key];
|
1489
|
-
bool noreply= server->root->flags & MEM_NOREPLY;
|
1490
|
-
|
1491
|
-
request.message.header.request.magic= PROTOCOL_BINARY_REQ;
|
1492
|
-
request.message.header.request.opcode= get_com_code(verb, noreply);
|
1493
|
-
- request.message.header.request.keylen= htons((uint16_t)key_length);
|
1494
|
-
+ request.message.header.request.keylen= htons((uint16_t)(ptr->prefix_key_length + key_length));
|
1495
|
-
request.message.header.request.datatype= PROTOCOL_BINARY_RAW_BYTES;
|
1496
|
-
- if (verb == APPEND_OP || verb == PREPEND_OP)
|
1497
|
-
- send_length -= 8; /* append & prepend does not contain extras! */
|
1498
|
-
- else
|
1499
|
-
+ if (verb == APPEND_OP || verb == PREPEND_OP || verb == DELETE_OP)
|
1500
|
-
+ send_length -= 8; /* append, delete, and prepend do not contain extras! */
|
1501
|
-
+ else
|
1502
|
-
{
|
1503
|
-
request.message.header.request.extlen= 8;
|
1504
|
-
- request.message.body.flags= htonl(flags);
|
1505
|
-
+ request.message.body.flags= htonl(flags);
|
1506
|
-
request.message.body.expiration= htonl((uint32_t)expiration);
|
1507
|
-
}
|
1508
|
-
-
|
1509
|
-
- request.message.header.request.bodylen= htonl((uint32_t) (key_length + value_length +
|
1510
|
-
+
|
1511
|
-
+ request.message.header.request.bodylen= htonl((uint32_t) (ptr->prefix_key_length + key_length + value_length +
|
1512
|
-
request.message.header.request.extlen));
|
1513
|
-
-
|
1514
|
-
+
|
1515
|
-
if (cas)
|
1516
|
-
request.message.header.request.cas= htonll(cas);
|
1517
|
-
-
|
1518
|
-
+
|
1519
|
-
flush= (uint8_t) (((server->root->flags & MEM_BUFFER_REQUESTS) && verb == SET_OP) ? 0 : 1);
|
1520
|
-
|
1521
|
-
if ((server->root->flags & MEM_USE_UDP) && !flush)
|
1522
|
-
{
|
1523
|
-
- size_t cmd_size= send_length + key_length + value_length;
|
1524
|
-
+ size_t cmd_size= send_length + ptr->prefix_key_length + key_length + value_length;
|
1525
|
-
if (cmd_size > MAX_UDP_DATAGRAM_LENGTH - UDP_DATAGRAM_HEADER_LENGTH)
|
1526
|
-
return MEMCACHED_WRITE_FAILURE;
|
1527
|
-
if (cmd_size + server->write_buffer_offset > MAX_UDP_DATAGRAM_LENGTH)
|
1528
|
-
memcached_io_write(server,NULL,0, 1);
|
1529
|
-
}
|
1530
|
-
-
|
1531
|
-
+
|
1532
|
-
/* write the header */
|
1533
|
-
if ((memcached_do(server, (const char*)request.bytes, send_length, 0) != MEMCACHED_SUCCESS) ||
|
1534
|
-
+ (memcached_io_write(server, ptr->prefix_key, ptr->prefix_key_length, 0) == -1) ||
|
1535
|
-
(memcached_io_write(server, key, key_length, 0) == -1) ||
|
1536
|
-
- (memcached_io_write(server, value, value_length, (char) flush) == -1))
|
1537
|
-
+ (memcached_io_write(server, value, value_length, (char) flush) == -1))
|
1538
|
-
{
|
1539
|
-
memcached_io_reset(server);
|
1540
|
-
return MEMCACHED_WRITE_FAILURE;
|
1541
|
-
}
|
1542
|
-
|
1543
|
-
- unlikely (verb == SET_OP && ptr->number_of_replicas > 0)
|
1544
|
-
- {
|
1545
|
-
- request.message.header.request.opcode= PROTOCOL_BINARY_CMD_SETQ;
|
1546
|
-
-
|
1547
|
-
- for (uint32_t x= 0; x < ptr->number_of_replicas; x++)
|
1548
|
-
- {
|
1549
|
-
- ++server_key;
|
1550
|
-
- if (server_key == ptr->number_of_hosts)
|
1551
|
-
- server_key= 0;
|
1552
|
-
-
|
1553
|
-
- memcached_server_st *srv= &ptr->hosts[server_key];
|
1554
|
-
- if ((memcached_do(srv, (const char*)request.bytes,
|
1555
|
-
- send_length, 0) != MEMCACHED_SUCCESS) ||
|
1556
|
-
- (memcached_io_write(srv, key, key_length, 0) == -1) ||
|
1557
|
-
- (memcached_io_write(srv, value, value_length, (char) flush) == -1))
|
1558
|
-
- memcached_io_reset(srv);
|
1559
|
-
- else
|
1560
|
-
- memcached_server_response_decrement(srv);
|
1561
|
-
- }
|
1562
|
-
- }
|
1563
|
-
-
|
1564
|
-
if (flush == 0)
|
1565
|
-
return MEMCACHED_BUFFERED;
|
1566
|
-
|
1567
|
-
if (noreply)
|
1568
|
-
return MEMCACHED_SUCCESS;
|
1569
|
-
|
1570
|
-
- return memcached_response(server, NULL, 0, NULL);
|
1571
|
-
+ return memcached_response(server, NULL, 0, NULL);
|
1572
|
-
}
|
1573
|
-
|
1574
|
-
diff -ur a/libmemcached-0.32/tests/function.c b/libmemcached-0.32/tests/function.c
|
1575
|
-
--- a/libmemcached-0.32/tests/function.c 2011-03-02 20:23:03.000000000 -0800
|
1576
|
-
+++ b/libmemcached-0.32/tests/function.c 2011-03-02 21:47:27.000000000 -0800
|
1577
|
-
@@ -270,7 +270,7 @@
|
1578
|
-
assert(memcached_set_user_data(memc, foo) == NULL);
|
1579
|
-
assert(memcached_get_user_data(memc) == foo);
|
1580
|
-
assert(memcached_set_user_data(memc, NULL) == foo);
|
1581
|
-
-
|
1582
|
-
+
|
1583
|
-
return TEST_SUCCESS;
|
1584
|
-
}
|
1585
|
-
|
1586
|
-
@@ -287,10 +287,10 @@
|
1587
|
-
static test_return error_test(memcached_st *memc)
|
1588
|
-
{
|
1589
|
-
memcached_return rc;
|
1590
|
-
- uint32_t values[] = { 851992627U, 2337886783U, 3196981036U, 4001849190U, 982370485U, 1263635348U, 4242906218U, 3829656100U, 1891735253U,
|
1591
|
-
- 334139633U, 2257084983U, 3088286104U, 13199785U, 2542027183U, 1097051614U, 199566778U, 2748246961U, 2465192557U,
|
1592
|
-
- 1664094137U, 2405439045U, 1842224848U, 692413798U, 3479807801U, 919913813U, 4269430871U, 610793021U, 527273862U,
|
1593
|
-
- 1437122909U, 2300930706U, 2943759320U, 674306647U, 2400528935U, 54481931U, 4186304426U, 1741088401U, 2979625118U,
|
1594
|
-
+ uint32_t values[] = { 851992627U, 2337886783U, 3196981036U, 4001849190U, 982370485U, 1263635348U, 4242906218U, 3829656100U, 1891735253U,
|
1595
|
-
+ 334139633U, 2257084983U, 3088286104U, 13199785U, 2542027183U, 1097051614U, 199566778U, 2748246961U, 2465192557U,
|
1596
|
-
+ 1664094137U, 2405439045U, 1842224848U, 692413798U, 3479807801U, 919913813U, 4269430871U, 610793021U, 527273862U,
|
1597
|
-
+ 1437122909U, 2300930706U, 2943759320U, 674306647U, 2400528935U, 54481931U, 4186304426U, 1741088401U, 2979625118U,
|
1598
|
-
4159057246U, 1769812374U, 2302537950U, 1110330676U};
|
1599
|
-
|
1600
|
-
// You have updated the memcache_error messages but not updated docs/tests.
|
1601
|
-
@@ -311,7 +311,7 @@
|
1602
|
-
const char *key= "foo";
|
1603
|
-
const char *value= "when we sanitize";
|
1604
|
-
|
1605
|
-
- rc= memcached_set(memc, key, strlen(key),
|
1606
|
-
+ rc= memcached_set(memc, key, strlen(key),
|
1607
|
-
value, strlen(value),
|
1608
|
-
(time_t)0, (uint32_t)0);
|
1609
|
-
assert(rc == MEMCACHED_SUCCESS || rc == MEMCACHED_BUFFERED);
|
1610
|
-
@@ -331,17 +331,17 @@
|
1611
|
-
rc= memcached_flush(memc, 0);
|
1612
|
-
assert(rc == MEMCACHED_SUCCESS);
|
1613
|
-
|
1614
|
-
- rc= memcached_set(memc, key, strlen(key),
|
1615
|
-
+ rc= memcached_set(memc, key, strlen(key),
|
1616
|
-
in_value, strlen(in_value),
|
1617
|
-
(time_t)0, (uint32_t)0);
|
1618
|
-
assert(rc == MEMCACHED_SUCCESS);
|
1619
|
-
|
1620
|
-
- rc= memcached_append(memc, key, strlen(key),
|
1621
|
-
+ rc= memcached_append(memc, key, strlen(key),
|
1622
|
-
" the", strlen(" the"),
|
1623
|
-
(time_t)0, (uint32_t)0);
|
1624
|
-
assert(rc == MEMCACHED_SUCCESS);
|
1625
|
-
|
1626
|
-
- rc= memcached_append(memc, key, strlen(key),
|
1627
|
-
+ rc= memcached_append(memc, key, strlen(key),
|
1628
|
-
" people", strlen(" people"),
|
1629
|
-
(time_t)0, (uint32_t)0);
|
1630
|
-
assert(rc == MEMCACHED_SUCCESS);
|
1631
|
-
@@ -370,16 +370,16 @@
|
1632
|
-
rc= memcached_flush(memc, 0);
|
1633
|
-
assert(rc == MEMCACHED_SUCCESS);
|
1634
|
-
|
1635
|
-
- rc= memcached_set(memc,
|
1636
|
-
- key, strlen(key),
|
1637
|
-
+ rc= memcached_set(memc,
|
1638
|
-
+ key, strlen(key),
|
1639
|
-
NULL, 0,
|
1640
|
-
(time_t)0, (uint32_t)0);
|
1641
|
-
assert(rc == MEMCACHED_SUCCESS);
|
1642
|
-
|
1643
|
-
for (x= 0; store_list[x] ; x++)
|
1644
|
-
{
|
1645
|
-
- rc= memcached_append(memc,
|
1646
|
-
- key, strlen(key),
|
1647
|
-
+ rc= memcached_append(memc,
|
1648
|
-
+ key, strlen(key),
|
1649
|
-
(char *)&store_list[x], sizeof(unsigned int),
|
1650
|
-
(time_t)0, (uint32_t)0);
|
1651
|
-
assert(rc == MEMCACHED_SUCCESS);
|
1652
|
-
@@ -421,7 +421,7 @@
|
1653
|
-
|
1654
|
-
for (x= 0; x < 3; x++)
|
1655
|
-
{
|
1656
|
-
- rc= memcached_set(memc, keys[x], key_length[x],
|
1657
|
-
+ rc= memcached_set(memc, keys[x], key_length[x],
|
1658
|
-
keys[x], key_length[x],
|
1659
|
-
(time_t)50, (uint32_t)9);
|
1660
|
-
assert(rc == MEMCACHED_SUCCESS);
|
1661
|
-
@@ -467,7 +467,7 @@
|
1662
|
-
|
1663
|
-
memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_SUPPORT_CAS, set);
|
1664
|
-
|
1665
|
-
- rc= memcached_set(memc, key, strlen(key),
|
1666
|
-
+ rc= memcached_set(memc, key, strlen(key),
|
1667
|
-
value, strlen(value),
|
1668
|
-
(time_t)0, (uint32_t)0);
|
1669
|
-
assert(rc == MEMCACHED_SUCCESS);
|
1670
|
-
@@ -490,7 +490,7 @@
|
1671
|
-
assert(rc == MEMCACHED_END);
|
1672
|
-
assert(results == NULL);
|
1673
|
-
#endif
|
1674
|
-
-
|
1675
|
-
+
|
1676
|
-
rc= memcached_cas(memc, key, key_length, value2, value2_length, 0, 0, cas);
|
1677
|
-
assert(rc == MEMCACHED_SUCCESS);
|
1678
|
-
|
1679
|
-
@@ -542,7 +542,7 @@
|
1680
|
-
|
1681
|
-
for (x= 0; x < number_of_keys; x++)
|
1682
|
-
{
|
1683
|
-
- rc= memcached_set(memc, keys[x], keys_length[x],
|
1684
|
-
+ rc= memcached_set(memc, keys[x], keys_length[x],
|
1685
|
-
keys[x], keys_length[x],
|
1686
|
-
(time_t)50, (uint32_t)9);
|
1687
|
-
assert(rc == MEMCACHED_SUCCESS || rc == MEMCACHED_BUFFERED);
|
1688
|
-
@@ -564,7 +564,7 @@
|
1689
|
-
assert(&results_obj == results);
|
1690
|
-
assert(rc == MEMCACHED_SUCCESS);
|
1691
|
-
assert(!memcached_result_cas(results));
|
1692
|
-
-
|
1693
|
-
+
|
1694
|
-
char *result_str = memcached_result_value(results);
|
1695
|
-
assert(strlen(result_str) == specified_length);
|
1696
|
-
|
1697
|
-
@@ -615,7 +615,7 @@
|
1698
|
-
|
1699
|
-
for (x= 0; x < number_of_keys; x++)
|
1700
|
-
{
|
1701
|
-
- rc= memcached_set(memc, keys[x], keys_length[x],
|
1702
|
-
+ rc= memcached_set(memc, keys[x], keys_length[x],
|
1703
|
-
keys[x], keys_length[x],
|
1704
|
-
(time_t)50, (uint32_t)9);
|
1705
|
-
assert(rc == MEMCACHED_SUCCESS || rc == MEMCACHED_BUFFERED);
|
1706
|
-
@@ -643,7 +643,7 @@
|
1707
|
-
assert(results);
|
1708
|
-
assert(&results_obj == results);
|
1709
|
-
assert(rc == MEMCACHED_SUCCESS);
|
1710
|
-
-
|
1711
|
-
+
|
1712
|
-
char *result_str = memcached_result_value(results);
|
1713
|
-
assert(strlen(result_str) == specified_length);
|
1714
|
-
|
1715
|
-
@@ -682,17 +682,17 @@
|
1716
|
-
rc= memcached_flush(memc, 0);
|
1717
|
-
assert(rc == MEMCACHED_SUCCESS);
|
1718
|
-
|
1719
|
-
- rc= memcached_set(memc, key, strlen(key),
|
1720
|
-
+ rc= memcached_set(memc, key, strlen(key),
|
1721
|
-
value, strlen(value),
|
1722
|
-
(time_t)0, (uint32_t)0);
|
1723
|
-
assert(rc == MEMCACHED_SUCCESS);
|
1724
|
-
|
1725
|
-
- rc= memcached_prepend(memc, key, strlen(key),
|
1726
|
-
+ rc= memcached_prepend(memc, key, strlen(key),
|
1727
|
-
"the ", strlen("the "),
|
1728
|
-
(time_t)0, (uint32_t)0);
|
1729
|
-
assert(rc == MEMCACHED_SUCCESS);
|
1730
|
-
|
1731
|
-
- rc= memcached_prepend(memc, key, strlen(key),
|
1732
|
-
+ rc= memcached_prepend(memc, key, strlen(key),
|
1733
|
-
"we ", strlen("we "),
|
1734
|
-
(time_t)0, (uint32_t)0);
|
1735
|
-
assert(rc == MEMCACHED_SUCCESS);
|
1736
|
-
@@ -707,7 +707,7 @@
|
1737
|
-
return 0;
|
1738
|
-
}
|
1739
|
-
|
1740
|
-
-/*
|
1741
|
-
+/*
|
1742
|
-
Set the value, then quit to make sure it is flushed.
|
1743
|
-
Come back in and test that add fails.
|
1744
|
-
*/
|
1745
|
-
@@ -720,12 +720,12 @@
|
1746
|
-
|
1747
|
-
setting_value= memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_NO_BLOCK);
|
1748
|
-
|
1749
|
-
- rc= memcached_set(memc, key, strlen(key),
|
1750
|
-
+ rc= memcached_set(memc, key, strlen(key),
|
1751
|
-
value, strlen(value),
|
1752
|
-
(time_t)0, (uint32_t)0);
|
1753
|
-
assert(rc == MEMCACHED_SUCCESS || rc == MEMCACHED_BUFFERED);
|
1754
|
-
memcached_quit(memc);
|
1755
|
-
- rc= memcached_add(memc, key, strlen(key),
|
1756
|
-
+ rc= memcached_add(memc, key, strlen(key),
|
1757
|
-
value, strlen(value),
|
1758
|
-
(time_t)0, (uint32_t)0);
|
1759
|
-
|
1760
|
-
@@ -766,12 +766,12 @@
|
1761
|
-
const char *value= "when we sanitize";
|
1762
|
-
const char *original= "first we insert some data";
|
1763
|
-
|
1764
|
-
- rc= memcached_set(memc, key, strlen(key),
|
1765
|
-
+ rc= memcached_set(memc, key, strlen(key),
|
1766
|
-
original, strlen(original),
|
1767
|
-
(time_t)0, (uint32_t)0);
|
1768
|
-
assert(rc == MEMCACHED_SUCCESS || rc == MEMCACHED_BUFFERED);
|
1769
|
-
|
1770
|
-
- rc= memcached_replace(memc, key, strlen(key),
|
1771
|
-
+ rc= memcached_replace(memc, key, strlen(key),
|
1772
|
-
value, strlen(value),
|
1773
|
-
(time_t)0, (uint32_t)0);
|
1774
|
-
assert(rc == MEMCACHED_SUCCESS);
|
1775
|
-
@@ -785,7 +785,7 @@
|
1776
|
-
const char *key= "foo";
|
1777
|
-
const char *value= "when we sanitize";
|
1778
|
-
|
1779
|
-
- rc= memcached_set(memc, key, strlen(key),
|
1780
|
-
+ rc= memcached_set(memc, key, strlen(key),
|
1781
|
-
value, strlen(value),
|
1782
|
-
(time_t)0, (uint32_t)0);
|
1783
|
-
assert(rc == MEMCACHED_SUCCESS || rc == MEMCACHED_BUFFERED);
|
1784
|
-
@@ -806,8 +806,8 @@
|
1785
|
-
return 0;
|
1786
|
-
}
|
1787
|
-
|
1788
|
-
-static memcached_return server_function(memcached_st *ptr __attribute__((unused)),
|
1789
|
-
- memcached_server_st *server __attribute__((unused)),
|
1790
|
-
+static memcached_return server_function(memcached_st *ptr __attribute__((unused)),
|
1791
|
-
+ memcached_server_st *server __attribute__((unused)),
|
1792
|
-
void *context __attribute__((unused)))
|
1793
|
-
{
|
1794
|
-
/* Do Nothing */
|
1795
|
-
@@ -844,7 +844,7 @@
|
1796
|
-
assert(rc == MEMCACHED_SUCCESS);
|
1797
|
-
|
1798
|
-
/* All keys are valid in the binary protocol (except for length) */
|
1799
|
-
- if (memcached_behavior_get(memc_clone, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL) == 0)
|
1800
|
-
+ if (memcached_behavior_get(memc_clone, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL) == 0)
|
1801
|
-
{
|
1802
|
-
string= memcached_get(memc_clone, key, strlen(key),
|
1803
|
-
&string_length, &flags, &rc);
|
1804
|
-
@@ -885,7 +885,7 @@
|
1805
|
-
assert(rc == MEMCACHED_SUCCESS);
|
1806
|
-
|
1807
|
-
char *longkey= malloc(max_keylen + 1);
|
1808
|
-
- if (longkey != NULL)
|
1809
|
-
+ if (longkey != NULL)
|
1810
|
-
{
|
1811
|
-
memset(longkey, 'a', max_keylen + 1);
|
1812
|
-
string= memcached_get(memc_clone, longkey, max_keylen,
|
1813
|
-
@@ -921,11 +921,11 @@
|
1814
|
-
|
1815
|
-
#define READ_THROUGH_VALUE "set for me"
|
1816
|
-
static memcached_return read_through_trigger(memcached_st *memc __attribute__((unused)),
|
1817
|
-
- char *key __attribute__((unused)),
|
1818
|
-
- size_t key_length __attribute__((unused)),
|
1819
|
-
+ char *key __attribute__((unused)),
|
1820
|
-
+ size_t key_length __attribute__((unused)),
|
1821
|
-
memcached_result_st *result)
|
1822
|
-
{
|
1823
|
-
-
|
1824
|
-
+
|
1825
|
-
return memcached_result_set_value(result, READ_THROUGH_VALUE, strlen(READ_THROUGH_VALUE));
|
1826
|
-
}
|
1827
|
-
|
1828
|
-
@@ -968,8 +968,8 @@
|
1829
|
-
return 0;
|
1830
|
-
}
|
1831
|
-
|
1832
|
-
-static memcached_return delete_trigger(memcached_st *ptr __attribute__((unused)),
|
1833
|
-
- const char *key,
|
1834
|
-
+static memcached_return delete_trigger(memcached_st *ptr __attribute__((unused)),
|
1835
|
-
+ const char *key,
|
1836
|
-
size_t key_length __attribute__((unused)))
|
1837
|
-
{
|
1838
|
-
assert(key);
|
1839
|
-
@@ -1020,7 +1020,7 @@
|
1840
|
-
size_t string_length;
|
1841
|
-
uint32_t flags;
|
1842
|
-
|
1843
|
-
- rc= memcached_set(memc, key, strlen(key),
|
1844
|
-
+ rc= memcached_set(memc, key, strlen(key),
|
1845
|
-
value, strlen(value),
|
1846
|
-
(time_t)0, (uint32_t)0);
|
1847
|
-
assert(rc == MEMCACHED_SUCCESS || rc == MEMCACHED_BUFFERED);
|
1848
|
-
@@ -1075,7 +1075,7 @@
|
1849
|
-
size_t string_length;
|
1850
|
-
uint32_t flags;
|
1851
|
-
|
1852
|
-
- rc= memcached_set(memc, key, strlen(key),
|
1853
|
-
+ rc= memcached_set(memc, key, strlen(key),
|
1854
|
-
value, strlen(value),
|
1855
|
-
(time_t)0, (uint32_t)0);
|
1856
|
-
assert(rc == MEMCACHED_SUCCESS || rc == MEMCACHED_BUFFERED);
|
1857
|
-
@@ -1108,7 +1108,7 @@
|
1858
|
-
size_t string_length;
|
1859
|
-
uint32_t flags;
|
1860
|
-
|
1861
|
-
- rc= memcached_set(memc, key, strlen(key),
|
1862
|
-
+ rc= memcached_set(memc, key, strlen(key),
|
1863
|
-
value, strlen(value),
|
1864
|
-
(time_t)0, (uint32_t)0);
|
1865
|
-
assert(rc == MEMCACHED_SUCCESS || rc == MEMCACHED_BUFFERED);
|
1866
|
-
@@ -1142,7 +1142,7 @@
|
1867
|
-
|
1868
|
-
for (x= 0; x < 10; x++)
|
1869
|
-
{
|
1870
|
-
- rc= memcached_set(memc, key, strlen(key),
|
1871
|
-
+ rc= memcached_set(memc, key, strlen(key),
|
1872
|
-
value, value_length,
|
1873
|
-
(time_t)0, (uint32_t)0);
|
1874
|
-
assert(rc == MEMCACHED_SUCCESS || rc == MEMCACHED_BUFFERED);
|
1875
|
-
@@ -1171,7 +1171,7 @@
|
1876
|
-
|
1877
|
-
sprintf(key, "foo%u", x);
|
1878
|
-
|
1879
|
-
- rc= memcached_set(memc, key, strlen(key),
|
1880
|
-
+ rc= memcached_set(memc, key, strlen(key),
|
1881
|
-
value, value_length,
|
1882
|
-
(time_t)0, (uint32_t)0);
|
1883
|
-
assert(rc == MEMCACHED_SUCCESS || rc == MEMCACHED_BUFFERED);
|
1884
|
-
@@ -1199,7 +1199,7 @@
|
1885
|
-
for (x= 0; x < value_length; x++)
|
1886
|
-
value[x] = (char) (x % 127);
|
1887
|
-
|
1888
|
-
- rc= memcached_set(memc, key, strlen(key),
|
1889
|
-
+ rc= memcached_set(memc, key, strlen(key),
|
1890
|
-
value, value_length,
|
1891
|
-
(time_t)0, (uint32_t)0);
|
1892
|
-
assert(rc == MEMCACHED_SUCCESS || rc == MEMCACHED_BUFFERED);
|
1893
|
-
@@ -1235,7 +1235,7 @@
|
1894
|
-
for (x= 0; x < value_length; x++)
|
1895
|
-
value[x] = (char) (x % 127);
|
1896
|
-
|
1897
|
-
- rc= memcached_set(memc, key, strlen(key),
|
1898
|
-
+ rc= memcached_set(memc, key, strlen(key),
|
1899
|
-
value, value_length,
|
1900
|
-
(time_t)0, (uint32_t)0);
|
1901
|
-
assert(rc == MEMCACHED_SUCCESS || rc == MEMCACHED_BUFFERED);
|
1902
|
-
@@ -1273,7 +1273,7 @@
|
1903
|
-
uint32_t flags;
|
1904
|
-
size_t rlen;
|
1905
|
-
|
1906
|
-
- memcached_return rc= memcached_set(memc, keys[0], lengths[0],
|
1907
|
-
+ memcached_return rc= memcached_set(memc, keys[0], lengths[0],
|
1908
|
-
keys[0], lengths[0], 0, 0);
|
1909
|
-
assert(rc == MEMCACHED_SUCCESS);
|
1910
|
-
rc= memcached_mget(memc, keys, lengths, 2);
|
1911
|
-
@@ -1309,7 +1309,7 @@
|
1912
|
-
memcached_return rc;
|
1913
|
-
memcached_stat_st memc_stat;
|
1914
|
-
rc= memcached_stat_servername(&memc_stat, NULL,
|
1915
|
-
- memc->hosts[0].hostname,
|
1916
|
-
+ memc->hosts[0].hostname,
|
1917
|
-
memc->hosts[0].port);
|
1918
|
-
|
1919
|
-
return 0;
|
1920
|
-
@@ -1322,7 +1322,7 @@
|
1921
|
-
const char *key= "number";
|
1922
|
-
const char *value= "0";
|
1923
|
-
|
1924
|
-
- rc= memcached_set(memc, key, strlen(key),
|
1925
|
-
+ rc= memcached_set(memc, key, strlen(key),
|
1926
|
-
value, strlen(value),
|
1927
|
-
(time_t)0, (uint32_t)0);
|
1928
|
-
assert(rc == MEMCACHED_SUCCESS || rc == MEMCACHED_BUFFERED);
|
1929
|
-
@@ -1369,7 +1369,7 @@
|
1930
|
-
const char *key= "number";
|
1931
|
-
const char *value= "3";
|
1932
|
-
|
1933
|
-
- rc= memcached_set(memc, key, strlen(key),
|
1934
|
-
+ rc= memcached_set(memc, key, strlen(key),
|
1935
|
-
value, strlen(value),
|
1936
|
-
(time_t)0, (uint32_t)0);
|
1937
|
-
assert(rc == MEMCACHED_SUCCESS || rc == MEMCACHED_BUFFERED);
|
1938
|
-
@@ -1415,13 +1415,13 @@
|
1939
|
-
const char *key= "fudge";
|
1940
|
-
const char *value= "sanford and sun";
|
1941
|
-
|
1942
|
-
- rc= memcached_set(memc, key, strlen(key),
|
1943
|
-
+ rc= memcached_set(memc, key, strlen(key),
|
1944
|
-
value, strlen(value),
|
1945
|
-
(time_t)10, (uint32_t)3);
|
1946
|
-
assert(rc == MEMCACHED_SUCCESS || rc == MEMCACHED_BUFFERED);
|
1947
|
-
memcached_quit(memc);
|
1948
|
-
|
1949
|
-
- rc= memcached_set(memc, key, strlen(key),
|
1950
|
-
+ rc= memcached_set(memc, key, strlen(key),
|
1951
|
-
value, strlen(value),
|
1952
|
-
(time_t)50, (uint32_t)9);
|
1953
|
-
assert(rc == MEMCACHED_SUCCESS || rc == MEMCACHED_BUFFERED);
|
1954
|
-
@@ -1461,7 +1461,7 @@
|
1955
|
-
|
1956
|
-
for (x= 0; x < 3; x++)
|
1957
|
-
{
|
1958
|
-
- rc= memcached_set(memc, keys[x], key_length[x],
|
1959
|
-
+ rc= memcached_set(memc, keys[x], key_length[x],
|
1960
|
-
keys[x], key_length[x],
|
1961
|
-
(time_t)50, (uint32_t)9);
|
1962
|
-
assert(rc == MEMCACHED_SUCCESS || rc == MEMCACHED_BUFFERED);
|
1963
|
-
@@ -1476,8 +1476,8 @@
|
1964
|
-
assert(&results_obj == results);
|
1965
|
-
assert(rc == MEMCACHED_SUCCESS);
|
1966
|
-
assert(memcached_result_key_length(results) == memcached_result_length(results));
|
1967
|
-
- assert(!memcmp(memcached_result_key_value(results),
|
1968
|
-
- memcached_result_value(results),
|
1969
|
-
+ assert(!memcmp(memcached_result_key_value(results),
|
1970
|
-
+ memcached_result_value(results),
|
1971
|
-
memcached_result_length(results)));
|
1972
|
-
}
|
1973
|
-
|
1974
|
-
@@ -1521,7 +1521,7 @@
|
1975
|
-
|
1976
|
-
for (x= 0; x < number_of_keys; x++)
|
1977
|
-
{
|
1978
|
-
- rc= memcached_set(memc, keys[x], key_length[x],
|
1979
|
-
+ rc= memcached_set(memc, keys[x], key_length[x],
|
1980
|
-
keys[x], key_length[x],
|
1981
|
-
(time_t)50, (uint32_t)9);
|
1982
|
-
assert(rc == MEMCACHED_SUCCESS || rc == MEMCACHED_BUFFERED);
|
1983
|
-
@@ -1585,7 +1585,7 @@
|
1984
|
-
|
1985
|
-
for (x= 0; x < 3; x++)
|
1986
|
-
{
|
1987
|
-
- rc= memcached_set(memc, keys[x], key_length[x],
|
1988
|
-
+ rc= memcached_set(memc, keys[x], key_length[x],
|
1989
|
-
keys[x], key_length[x],
|
1990
|
-
(time_t)50, (uint32_t)9);
|
1991
|
-
assert(rc == MEMCACHED_SUCCESS || rc == MEMCACHED_BUFFERED);
|
1992
|
-
@@ -1600,8 +1600,8 @@
|
1993
|
-
assert(results);
|
1994
|
-
assert(rc == MEMCACHED_SUCCESS);
|
1995
|
-
assert(memcached_result_key_length(results) == memcached_result_length(results));
|
1996
|
-
- assert(!memcmp(memcached_result_key_value(results),
|
1997
|
-
- memcached_result_value(results),
|
1998
|
-
+ assert(!memcmp(memcached_result_key_value(results),
|
1999
|
-
+ memcached_result_value(results),
|
2000
|
-
memcached_result_length(results)));
|
2001
|
-
memcached_result_free(results);
|
2002
|
-
x++;
|
2003
|
-
@@ -1611,8 +1611,8 @@
|
2004
|
-
}
|
2005
|
-
|
2006
|
-
/* Count the results */
|
2007
|
-
-static memcached_return callback_counter(memcached_st *ptr __attribute__((unused)),
|
2008
|
-
- memcached_result_st *result __attribute__((unused)),
|
2009
|
-
+static memcached_return callback_counter(memcached_st *ptr __attribute__((unused)),
|
2010
|
-
+ memcached_result_st *result __attribute__((unused)),
|
2011
|
-
void *context)
|
2012
|
-
{
|
2013
|
-
unsigned int *counter= (unsigned int *)context;
|
2014
|
-
@@ -1635,7 +1635,7 @@
|
2015
|
-
rc= memcached_flush(memc, 0);
|
2016
|
-
for (x= 0; x < 3; x++)
|
2017
|
-
{
|
2018
|
-
- rc= memcached_set(memc, keys[x], key_length[x],
|
2019
|
-
+ rc= memcached_set(memc, keys[x], key_length[x],
|
2020
|
-
keys[x], key_length[x],
|
2021
|
-
(time_t)50, (uint32_t)9);
|
2022
|
-
assert(rc == MEMCACHED_SUCCESS || rc == MEMCACHED_BUFFERED);
|
2023
|
-
@@ -1646,7 +1646,7 @@
|
2024
|
-
|
2025
|
-
callbacks[0]= &callback_counter;
|
2026
|
-
counter= 0;
|
2027
|
-
- rc= memcached_fetch_execute(memc, callbacks, (void *)&counter, 1);
|
2028
|
-
+ rc= memcached_fetch_execute(memc, callbacks, (void *)&counter, 1);
|
2029
|
-
|
2030
|
-
assert(counter == 3);
|
2031
|
-
|
2032
|
-
@@ -1673,7 +1673,7 @@
|
2033
|
-
rc= memcached_mget(memc, keys, key_length, 3);
|
2034
|
-
assert(rc == MEMCACHED_SUCCESS);
|
2035
|
-
|
2036
|
-
- while ((return_value= memcached_fetch(memc, return_key, &return_key_length,
|
2037
|
-
+ while ((return_value= memcached_fetch(memc, return_key, &return_key_length,
|
2038
|
-
&return_value_length, &flags, &rc)) != NULL)
|
2039
|
-
{
|
2040
|
-
assert(return_value);
|
2041
|
-
@@ -1684,7 +1684,7 @@
|
2042
|
-
|
2043
|
-
for (x= 0; x < 3; x++)
|
2044
|
-
{
|
2045
|
-
- rc= memcached_set(memc, keys[x], key_length[x],
|
2046
|
-
+ rc= memcached_set(memc, keys[x], key_length[x],
|
2047
|
-
keys[x], key_length[x],
|
2048
|
-
(time_t)50, (uint32_t)9);
|
2049
|
-
assert(rc == MEMCACHED_SUCCESS || rc == MEMCACHED_BUFFERED);
|
2050
|
-
@@ -1694,7 +1694,7 @@
|
2051
|
-
assert(rc == MEMCACHED_SUCCESS);
|
2052
|
-
|
2053
|
-
x= 0;
|
2054
|
-
- while ((return_value= memcached_fetch(memc, return_key, &return_key_length,
|
2055
|
-
+ while ((return_value= memcached_fetch(memc, return_key, &return_key_length,
|
2056
|
-
&return_value_length, &flags, &rc)))
|
2057
|
-
{
|
2058
|
-
assert(return_value);
|
2059
|
-
@@ -1781,7 +1781,7 @@
|
2060
|
-
char buffer[SMALL_STRING_LEN];
|
2061
|
-
|
2062
|
-
snprintf(buffer, SMALL_STRING_LEN, "%u.example.com", 400+x);
|
2063
|
-
- servers= memcached_server_list_append_with_weight(servers, buffer, 401, 0,
|
2064
|
-
+ servers= memcached_server_list_append_with_weight(servers, buffer, 401, 0,
|
2065
|
-
&rc);
|
2066
|
-
assert(rc == MEMCACHED_SUCCESS);
|
2067
|
-
assert(x == memcached_server_list_count(servers));
|
2068
|
-
@@ -1897,10 +1897,6 @@
|
2069
|
-
|
2070
|
-
value= memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_SOCKET_RECV_SIZE);
|
2071
|
-
assert(value > 0);
|
2072
|
-
-
|
2073
|
-
- value= memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_NUMBER_OF_REPLICAS);
|
2074
|
-
- memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_NUMBER_OF_REPLICAS, value + 1);
|
2075
|
-
- assert((value + 1) == memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_NUMBER_OF_REPLICAS));
|
2076
|
-
return 0;
|
2077
|
-
}
|
2078
|
-
|
2079
|
-
@@ -1913,7 +1909,7 @@
|
2080
|
-
unsigned long long total= 0;
|
2081
|
-
uint32_t size= 0;
|
2082
|
-
char key[10];
|
2083
|
-
- char randomstuff[6 * 1024];
|
2084
|
-
+ char randomstuff[6 * 1024];
|
2085
|
-
memcached_return rc;
|
2086
|
-
|
2087
|
-
memset(randomstuff, 0, 6 * 1024);
|
2088
|
-
@@ -1934,17 +1930,17 @@
|
2089
|
-
memset(randomstuff, 0, 6 * 1024);
|
2090
|
-
assert(size < 6 * 1024); /* Being safe here */
|
2091
|
-
|
2092
|
-
- for (j= 0 ; j < size ;j++)
|
2093
|
-
+ for (j= 0 ; j < size ;j++)
|
2094
|
-
randomstuff[j] = (signed char) ((rand() % 26) + 97);
|
2095
|
-
|
2096
|
-
total += size;
|
2097
|
-
sprintf(key, "%d", x);
|
2098
|
-
- rc = memcached_set(memc, key, strlen(key),
|
2099
|
-
+ rc = memcached_set(memc, key, strlen(key),
|
2100
|
-
randomstuff, strlen(randomstuff), 10, 0);
|
2101
|
-
assert(rc == MEMCACHED_SUCCESS || rc == MEMCACHED_BUFFERED);
|
2102
|
-
/* If we fail, lets try again */
|
2103
|
-
if (rc != MEMCACHED_SUCCESS && rc != MEMCACHED_BUFFERED)
|
2104
|
-
- rc = memcached_set(memc, key, strlen(key),
|
2105
|
-
+ rc = memcached_set(memc, key, strlen(key),
|
2106
|
-
randomstuff, strlen(randomstuff), 10, 0);
|
2107
|
-
assert(rc == MEMCACHED_SUCCESS || rc == MEMCACHED_BUFFERED);
|
2108
|
-
}
|
2109
|
-
@@ -1986,8 +1982,8 @@
|
2110
|
-
|
2111
|
-
snprintf(buffer, SMALL_STRING_LEN, "%u", x);
|
2112
|
-
getval= memcached_get(memc, buffer, strlen(buffer),
|
2113
|
-
- &val_len, &flags, &rc);
|
2114
|
-
- if (rc != MEMCACHED_SUCCESS)
|
2115
|
-
+ &val_len, &flags, &rc);
|
2116
|
-
+ if (rc != MEMCACHED_SUCCESS)
|
2117
|
-
{
|
2118
|
-
if (rc == MEMCACHED_NOTFOUND)
|
2119
|
-
errors++;
|
2120
|
-
@@ -2051,7 +2047,7 @@
|
2121
|
-
size_t return_value_length;
|
2122
|
-
uint32_t flags;
|
2123
|
-
|
2124
|
-
- while ((return_value= memcached_fetch(memc, return_key, &return_key_length,
|
2125
|
-
+ while ((return_value= memcached_fetch(memc, return_key, &return_key_length,
|
2126
|
-
&return_value_length, &flags, &rc)))
|
2127
|
-
{
|
2128
|
-
assert(return_value);
|
2129
|
-
@@ -2095,7 +2091,7 @@
|
2130
|
-
rc= memcached_mget(memc, keys, key_length, 3);
|
2131
|
-
assert(rc == MEMCACHED_NO_SERVERS);
|
2132
|
-
|
2133
|
-
- while ((return_value= memcached_fetch(memc, return_key, &return_key_length,
|
2134
|
-
+ while ((return_value= memcached_fetch(memc, return_key, &return_key_length,
|
2135
|
-
&return_value_length, &flags, &rc)) != NULL)
|
2136
|
-
{
|
2137
|
-
assert(return_value);
|
2138
|
-
@@ -2106,7 +2102,7 @@
|
2139
|
-
|
2140
|
-
for (x= 0; x < 3; x++)
|
2141
|
-
{
|
2142
|
-
- rc= memcached_set(memc, keys[x], key_length[x],
|
2143
|
-
+ rc= memcached_set(memc, keys[x], key_length[x],
|
2144
|
-
keys[x], key_length[x],
|
2145
|
-
(time_t)50, (uint32_t)9);
|
2146
|
-
assert(rc == MEMCACHED_NO_SERVERS);
|
2147
|
-
@@ -2116,7 +2112,7 @@
|
2148
|
-
assert(rc == MEMCACHED_NO_SERVERS);
|
2149
|
-
|
2150
|
-
x= 0;
|
2151
|
-
- while ((return_value= memcached_fetch(memc, return_key, &return_key_length,
|
2152
|
-
+ while ((return_value= memcached_fetch(memc, return_key, &return_key_length,
|
2153
|
-
&return_value_length, &flags, &rc)))
|
2154
|
-
{
|
2155
|
-
assert(return_value);
|
2156
|
-
@@ -2150,19 +2146,19 @@
|
2157
|
-
|
2158
|
-
memcached_flush(memc, 0);
|
2159
|
-
value= memcached_get(memc, keys[0], key_length[0],
|
2160
|
-
- &value_length, &flags, &rc);
|
2161
|
-
+ &value_length, &flags, &rc);
|
2162
|
-
assert(value == NULL);
|
2163
|
-
rc= memcached_mget(memc, keys, key_length, 4);
|
2164
|
-
|
2165
|
-
count= 0;
|
2166
|
-
- while ((value= memcached_fetch(memc, return_key, &return_key_length,
|
2167
|
-
+ while ((value= memcached_fetch(memc, return_key, &return_key_length,
|
2168
|
-
&value_length, &flags, &rc)))
|
2169
|
-
count++;
|
2170
|
-
assert(count == 0);
|
2171
|
-
|
2172
|
-
for (x= 0; x < 4; x++)
|
2173
|
-
{
|
2174
|
-
- rc= memcached_set(memc, keys[x], key_length[x],
|
2175
|
-
+ rc= memcached_set(memc, keys[x], key_length[x],
|
2176
|
-
insert_data, VALUE_SIZE_BUG5,
|
2177
|
-
(time_t)0, (uint32_t)0);
|
2178
|
-
assert(rc == MEMCACHED_SUCCESS);
|
2179
|
-
@@ -2171,13 +2167,13 @@
|
2180
|
-
for (x= 0; x < 10; x++)
|
2181
|
-
{
|
2182
|
-
value= memcached_get(memc, keys[0], key_length[0],
|
2183
|
-
- &value_length, &flags, &rc);
|
2184
|
-
+ &value_length, &flags, &rc);
|
2185
|
-
assert(value);
|
2186
|
-
free(value);
|
2187
|
-
|
2188
|
-
rc= memcached_mget(memc, keys, key_length, 4);
|
2189
|
-
count= 0;
|
2190
|
-
- while ((value= memcached_fetch(memc, return_key, &return_key_length,
|
2191
|
-
+ while ((value= memcached_fetch(memc, return_key, &return_key_length,
|
2192
|
-
&value_length, &flags, &rc)))
|
2193
|
-
{
|
2194
|
-
count++;
|
2195
|
-
@@ -2208,14 +2204,14 @@
|
2196
|
-
|
2197
|
-
memcached_flush(memc, 0);
|
2198
|
-
value= memcached_get(memc, keys[0], key_length[0],
|
2199
|
-
- &value_length, &flags, &rc);
|
2200
|
-
+ &value_length, &flags, &rc);
|
2201
|
-
assert(value == NULL);
|
2202
|
-
assert(rc == MEMCACHED_NOTFOUND);
|
2203
|
-
rc= memcached_mget(memc, keys, key_length, 4);
|
2204
|
-
assert(rc == MEMCACHED_SUCCESS);
|
2205
|
-
|
2206
|
-
count= 0;
|
2207
|
-
- while ((value= memcached_fetch(memc, return_key, &return_key_length,
|
2208
|
-
+ while ((value= memcached_fetch(memc, return_key, &return_key_length,
|
2209
|
-
&value_length, &flags, &rc)))
|
2210
|
-
count++;
|
2211
|
-
assert(count == 0);
|
2212
|
-
@@ -2223,7 +2219,7 @@
|
2213
|
-
|
2214
|
-
for (x= 0; x < 4; x++)
|
2215
|
-
{
|
2216
|
-
- rc= memcached_set(memc, keys[x], key_length[x],
|
2217
|
-
+ rc= memcached_set(memc, keys[x], key_length[x],
|
2218
|
-
insert_data, VALUE_SIZE_BUG5,
|
2219
|
-
(time_t)0, (uint32_t)0);
|
2220
|
-
assert(rc == MEMCACHED_SUCCESS);
|
2221
|
-
@@ -2232,7 +2228,7 @@
|
2222
|
-
for (x= 0; x < 2; x++)
|
2223
|
-
{
|
2224
|
-
value= memcached_get(memc, keys[0], key_length[0],
|
2225
|
-
- &value_length, &flags, &rc);
|
2226
|
-
+ &value_length, &flags, &rc);
|
2227
|
-
assert(value);
|
2228
|
-
free(value);
|
2229
|
-
|
2230
|
-
@@ -2242,7 +2238,7 @@
|
2231
|
-
/* We test for purge of partial complete fetches */
|
2232
|
-
for (count= 3; count; count--)
|
2233
|
-
{
|
2234
|
-
- value= memcached_fetch(memc, return_key, &return_key_length,
|
2235
|
-
+ value= memcached_fetch(memc, return_key, &return_key_length,
|
2236
|
-
&value_length, &flags, &rc);
|
2237
|
-
assert(rc == MEMCACHED_SUCCESS);
|
2238
|
-
assert(!(memcmp(value, insert_data, value_length)));
|
2239
|
-
@@ -2304,14 +2300,14 @@
|
2240
|
-
memcached_flush(memc, 0);
|
2241
|
-
|
2242
|
-
flags= 245;
|
2243
|
-
- rc= memcached_set(memc, keys, key_length,
|
2244
|
-
+ rc= memcached_set(memc, keys, key_length,
|
2245
|
-
insert_data, VALUE_SIZE_BUG5,
|
2246
|
-
(time_t)0, flags);
|
2247
|
-
assert(rc == MEMCACHED_SUCCESS);
|
2248
|
-
|
2249
|
-
flags= 0;
|
2250
|
-
value= memcached_get(memc, keys, key_length,
|
2251
|
-
- &value_length, &flags, &rc);
|
2252
|
-
+ &value_length, &flags, &rc);
|
2253
|
-
assert(flags == 245);
|
2254
|
-
assert(value);
|
2255
|
-
free(value);
|
2256
|
-
@@ -2319,7 +2315,7 @@
|
2257
|
-
rc= memcached_mget(memc, &keys, &key_length, 1);
|
2258
|
-
|
2259
|
-
flags= 0;
|
2260
|
-
- value= memcached_fetch(memc, return_key, &return_key_length,
|
2261
|
-
+ value= memcached_fetch(memc, return_key, &return_key_length,
|
2262
|
-
&value_length, &flags, &rc);
|
2263
|
-
assert(flags == 245);
|
2264
|
-
assert(value);
|
2265
|
-
@@ -2351,7 +2347,7 @@
|
2266
|
-
|
2267
|
-
for (x= 0; x < 3; x++)
|
2268
|
-
{
|
2269
|
-
- rc= memcached_set(memc, keys[x], key_length[x],
|
2270
|
-
+ rc= memcached_set(memc, keys[x], key_length[x],
|
2271
|
-
keys[x], key_length[x],
|
2272
|
-
(time_t)50, (uint32_t)9);
|
2273
|
-
assert(rc == MEMCACHED_SUCCESS);
|
2274
|
-
@@ -2361,7 +2357,7 @@
|
2275
|
-
assert(rc == MEMCACHED_SUCCESS);
|
2276
|
-
|
2277
|
-
/* We need to empty the server before continueing test */
|
2278
|
-
- while ((return_value= memcached_fetch(memc, return_key, &return_key_length,
|
2279
|
-
+ while ((return_value= memcached_fetch(memc, return_key, &return_key_length,
|
2280
|
-
&return_value_length, &flags, &rc)) != NULL)
|
2281
|
-
{
|
2282
|
-
assert(return_value);
|
2283
|
-
@@ -2401,7 +2397,7 @@
|
2284
|
-
{
|
2285
|
-
rc= memcached_set(mclone, key, key_len,value, value_length, 0, 0);
|
2286
|
-
|
2287
|
-
- assert(rc == MEMCACHED_SUCCESS || rc == MEMCACHED_WRITE_FAILURE ||
|
2288
|
-
+ assert(rc == MEMCACHED_SUCCESS || rc == MEMCACHED_WRITE_FAILURE ||
|
2289
|
-
rc == MEMCACHED_BUFFERED || rc == MEMCACHED_TIMEOUT);
|
2290
|
-
|
2291
|
-
if (rc == MEMCACHED_WRITE_FAILURE || rc == MEMCACHED_TIMEOUT)
|
2292
|
-
@@ -2467,7 +2463,7 @@
|
2293
|
-
uint64_t number_value;
|
2294
|
-
|
2295
|
-
value= memcached_get(memc, "autoincrement", strlen("autoincrement"),
|
2296
|
-
- &value_length, &flags, &rc);
|
2297
|
-
+ &value_length, &flags, &rc);
|
2298
|
-
assert(value == NULL);
|
2299
|
-
assert(rc == MEMCACHED_NOTFOUND);
|
2300
|
-
|
2301
|
-
@@ -2476,7 +2472,7 @@
|
2302
|
-
|
2303
|
-
assert(value == NULL);
|
2304
|
-
/* The binary protocol will set the key if it doesn't exist */
|
2305
|
-
- if (memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL) == 1)
|
2306
|
-
+ if (memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL) == 1)
|
2307
|
-
assert(rc == MEMCACHED_SUCCESS);
|
2308
|
-
else
|
2309
|
-
assert(rc == MEMCACHED_NOTFOUND);
|
2310
|
-
@@ -2484,7 +2480,7 @@
|
2311
|
-
rc= memcached_set(memc, "autoincrement", strlen("autoincrement"), "1", 1, 0, 0);
|
2312
|
-
|
2313
|
-
value= memcached_get(memc, "autoincrement", strlen("autoincrement"),
|
2314
|
-
- &value_length, &flags, &rc);
|
2315
|
-
+ &value_length, &flags, &rc);
|
2316
|
-
assert(value);
|
2317
|
-
assert(rc == MEMCACHED_SUCCESS);
|
2318
|
-
free(value);
|
2319
|
-
@@ -2561,7 +2557,7 @@
|
2320
|
-
|
2321
|
-
for (current_length= 0; current_length < value_length; current_length++)
|
2322
|
-
{
|
2323
|
-
- rc= memcached_set(memc, key, strlen(key),
|
2324
|
-
+ rc= memcached_set(memc, key, strlen(key),
|
2325
|
-
value, current_length,
|
2326
|
-
(time_t)0, (uint32_t)0);
|
2327
|
-
assert(rc == MEMCACHED_SUCCESS || rc == MEMCACHED_BUFFERED);
|
2328
|
-
@@ -2595,7 +2591,7 @@
|
2329
|
-
|
2330
|
-
for (x= 0; x < 2; x++)
|
2331
|
-
{
|
2332
|
-
- rc= memcached_set(memc, key, strlen(key),
|
2333
|
-
+ rc= memcached_set(memc, key, strlen(key),
|
2334
|
-
NULL, 0,
|
2335
|
-
(time_t)0, (uint32_t)0);
|
2336
|
-
|
2337
|
-
@@ -2630,7 +2626,7 @@
|
2338
|
-
size_t length;
|
2339
|
-
uint32_t flags;
|
2340
|
-
|
2341
|
-
- rc= memcached_set(memc, key, strlen(key),
|
2342
|
-
+ rc= memcached_set(memc, key, strlen(key),
|
2343
|
-
NULL, 0,
|
2344
|
-
(time_t)0, UINT32_MAX);
|
2345
|
-
|
2346
|
-
@@ -2745,7 +2741,7 @@
|
2347
|
-
|
2348
|
-
memc= memcached_create(NULL);
|
2349
|
-
assert(memc);
|
2350
|
-
-
|
2351
|
-
+
|
2352
|
-
rc= memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_KETAMA_WEIGHTED, 1);
|
2353
|
-
assert(rc == MEMCACHED_SUCCESS);
|
2354
|
-
|
2355
|
-
@@ -2760,7 +2756,7 @@
|
2356
|
-
|
2357
|
-
server_pool = memcached_servers_parse("10.0.1.1:11211 600,10.0.1.2:11211 300,10.0.1.3:11211 200,10.0.1.4:11211 350,10.0.1.5:11211 1000,10.0.1.6:11211 800,10.0.1.7:11211 950,10.0.1.8:11211 100");
|
2358
|
-
memcached_server_push(memc, server_pool);
|
2359
|
-
-
|
2360
|
-
+
|
2361
|
-
/* verify that the server list was parsed okay. */
|
2362
|
-
assert(memc->number_of_hosts == 8);
|
2363
|
-
assert(strcmp(server_pool[0].hostname, "10.0.1.1") == 0);
|
2364
|
-
@@ -2993,7 +2989,7 @@
|
2365
|
-
|
2366
|
-
for (x= 0; x < global_count; x++)
|
2367
|
-
{
|
2368
|
-
- global_keys[x]= global_pairs[x].key;
|
2369
|
-
+ global_keys[x]= global_pairs[x].key;
|
2370
|
-
global_keys_length[x]= global_pairs[x].key_length;
|
2371
|
-
}
|
2372
|
-
|
2373
|
-
@@ -3008,7 +3004,7 @@
|
2374
|
-
|
2375
|
-
for (x= 0; x < global_count; x++)
|
2376
|
-
{
|
2377
|
-
- global_keys[x]= global_pairs[x].key;
|
2378
|
-
+ global_keys[x]= global_pairs[x].key;
|
2379
|
-
global_keys_length[x]= global_pairs[x].key_length;
|
2380
|
-
}
|
2381
|
-
|
2382
|
-
@@ -3181,7 +3177,7 @@
|
2383
|
-
|
2384
|
-
callbacks[0]= &callback_counter;
|
2385
|
-
counter= 0;
|
2386
|
-
- rc= memcached_fetch_execute(memc, callbacks, (void *)&counter, 1);
|
2387
|
-
+ rc= memcached_fetch_execute(memc, callbacks, (void *)&counter, 1);
|
2388
|
-
|
2389
|
-
return 0;
|
2390
|
-
}
|
2391
|
-
@@ -3230,7 +3226,7 @@
|
2392
|
-
char buffer[SMALL_STRING_LEN];
|
2393
|
-
|
2394
|
-
snprintf(buffer, SMALL_STRING_LEN, "%u.example.com", 400+x);
|
2395
|
-
- servers= memcached_server_list_append_with_weight(servers, buffer, 401, 0,
|
2396
|
-
+ servers= memcached_server_list_append_with_weight(servers, buffer, 401, 0,
|
2397
|
-
&rc);
|
2398
|
-
assert(rc == MEMCACHED_SUCCESS);
|
2399
|
-
assert(x == memcached_server_list_count(servers));
|
2400
|
-
@@ -3264,7 +3260,7 @@
|
2401
|
-
// will not toggle protocol on an connection.
|
2402
|
-
memcached_version(memc_clone);
|
2403
|
-
|
2404
|
-
- if (memc_clone->hosts[0].major_version >= 1 && memc_clone->hosts[0].minor_version > 2)
|
2405
|
-
+ if (memc_clone->hosts[0].major_version >= 1 && memc_clone->hosts[0].minor_version > 2)
|
2406
|
-
{
|
2407
|
-
memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_NO_BLOCK, 0);
|
2408
|
-
rc = memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL, 1);
|
2409
|
-
@@ -3388,7 +3384,7 @@
|
2410
|
-
// will not toggle protocol on an connection.
|
2411
|
-
memcached_version(memc_clone);
|
2412
|
-
|
2413
|
-
- if (memc_clone->hosts[0].major_version >= 1 && memc_clone->hosts[0].minor_version > 2)
|
2414
|
-
+ if (memc_clone->hosts[0].major_version >= 1 && memc_clone->hosts[0].minor_version > 2)
|
2415
|
-
{
|
2416
|
-
rc = memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL, 1);
|
2417
|
-
assert(rc == MEMCACHED_SUCCESS);
|
2418
|
-
@@ -3399,34 +3395,6 @@
|
2419
|
-
return rc;
|
2420
|
-
}
|
2421
|
-
|
2422
|
-
-static memcached_return pre_replication(memcached_st *memc)
|
2423
|
-
-{
|
2424
|
-
- memcached_return rc= MEMCACHED_FAILURE;
|
2425
|
-
- if (pre_binary(memc) == MEMCACHED_SUCCESS)
|
2426
|
-
- {
|
2427
|
-
- /*
|
2428
|
-
- * Make sure that we store the item on all servers
|
2429
|
-
- * (master + replicas == number of servers)
|
2430
|
-
- */
|
2431
|
-
- rc= memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_NUMBER_OF_REPLICAS,
|
2432
|
-
- memc->number_of_hosts - 1);
|
2433
|
-
- assert(rc == MEMCACHED_SUCCESS);
|
2434
|
-
- assert(memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_NUMBER_OF_REPLICAS) == memc->number_of_hosts - 1);
|
2435
|
-
- }
|
2436
|
-
-
|
2437
|
-
- return rc;
|
2438
|
-
-}
|
2439
|
-
-
|
2440
|
-
-static memcached_return pre_replication_noblock(memcached_st *memc)
|
2441
|
-
-{
|
2442
|
-
- memcached_return rc= MEMCACHED_FAILURE;
|
2443
|
-
- if (pre_replication(memc) == MEMCACHED_SUCCESS &&
|
2444
|
-
- pre_nonblock(memc) == MEMCACHED_SUCCESS)
|
2445
|
-
- rc= MEMCACHED_SUCCESS;
|
2446
|
-
-
|
2447
|
-
- return rc;
|
2448
|
-
-}
|
2449
|
-
-
|
2450
|
-
static void my_free(memcached_st *ptr __attribute__((unused)), void *mem)
|
2451
|
-
{
|
2452
|
-
free(mem);
|
2453
|
-
@@ -3526,7 +3494,7 @@
|
2454
|
-
void *test_ptr= NULL;
|
2455
|
-
void *cb_ptr= NULL;
|
2456
|
-
{
|
2457
|
-
- memcached_malloc_function malloc_cb=
|
2458
|
-
+ memcached_malloc_function malloc_cb=
|
2459
|
-
(memcached_malloc_function)my_malloc;
|
2460
|
-
cb_ptr= *(void **)&malloc_cb;
|
2461
|
-
memcached_return rc;
|
2462
|
-
@@ -3539,7 +3507,7 @@
|
2463
|
-
}
|
2464
|
-
|
2465
|
-
{
|
2466
|
-
- memcached_realloc_function realloc_cb=
|
2467
|
-
+ memcached_realloc_function realloc_cb=
|
2468
|
-
(memcached_realloc_function)my_realloc;
|
2469
|
-
cb_ptr= *(void **)&realloc_cb;
|
2470
|
-
memcached_return rc;
|
2471
|
-
@@ -3552,7 +3520,7 @@
|
2472
|
-
}
|
2473
|
-
|
2474
|
-
{
|
2475
|
-
- memcached_free_function free_cb=
|
2476
|
-
+ memcached_free_function free_cb=
|
2477
|
-
(memcached_free_function)my_free;
|
2478
|
-
cb_ptr= *(void **)&free_cb;
|
2479
|
-
memcached_return rc;
|
2480
|
-
@@ -3570,19 +3538,19 @@
|
2481
|
-
static memcached_return set_memory_alloc(memcached_st *memc)
|
2482
|
-
{
|
2483
|
-
memcached_return rc;
|
2484
|
-
- rc= memcached_set_memory_allocators(memc, NULL, my_free,
|
2485
|
-
+ rc= memcached_set_memory_allocators(memc, NULL, my_free,
|
2486
|
-
my_realloc, my_calloc);
|
2487
|
-
assert(rc == MEMCACHED_FAILURE);
|
2488
|
-
|
2489
|
-
- rc= memcached_set_memory_allocators(memc, my_malloc, my_free,
|
2490
|
-
+ rc= memcached_set_memory_allocators(memc, my_malloc, my_free,
|
2491
|
-
my_realloc, my_calloc);
|
2492
|
-
-
|
2493
|
-
+
|
2494
|
-
memcached_malloc_function mem_malloc;
|
2495
|
-
memcached_free_function mem_free;
|
2496
|
-
memcached_realloc_function mem_realloc;
|
2497
|
-
memcached_calloc_function mem_calloc;
|
2498
|
-
- memcached_get_memory_allocators(memc, &mem_malloc, &mem_free,
|
2499
|
-
- &mem_realloc, &mem_calloc);
|
2500
|
-
+ memcached_get_memory_allocators(memc, &mem_malloc, &mem_free,
|
2501
|
-
+ &mem_realloc, &mem_calloc);
|
2502
|
-
|
2503
|
-
assert(mem_malloc == my_malloc);
|
2504
|
-
assert(mem_realloc == my_realloc);
|
2505
|
-
@@ -3616,7 +3584,7 @@
|
2506
|
-
|
2507
|
-
memcached_version(memc);
|
2508
|
-
|
2509
|
-
- if ((memc->hosts[0].major_version >= 1 && (memc->hosts[0].minor_version == 2 && memc->hosts[0].micro_version >= 4))
|
2510
|
-
+ if ((memc->hosts[0].major_version >= 1 && (memc->hosts[0].minor_version == 2 && memc->hosts[0].micro_version >= 4))
|
2511
|
-
|| memc->hosts[0].minor_version > 2)
|
2512
|
-
{
|
2513
|
-
memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_SUPPORT_CAS, set);
|
2514
|
-
@@ -3822,7 +3790,7 @@
|
2515
|
-
assert(rc == MEMCACHED_SUCCESS);
|
2516
|
-
assert(memc_stat);
|
2517
|
-
|
2518
|
-
- report= memcached_analyze(memc, memc_stat, &rc);
|
2519
|
-
+ report= memcached_analyze(memc, memc_stat, &rc);
|
2520
|
-
assert(rc == MEMCACHED_SUCCESS);
|
2521
|
-
assert(report);
|
2522
|
-
|
2523
|
-
@@ -3833,9 +3801,9 @@
|
2524
|
-
}
|
2525
|
-
|
2526
|
-
/* Count the objects */
|
2527
|
-
-static memcached_return callback_dump_counter(memcached_st *ptr __attribute__((unused)),
|
2528
|
-
- const char *key __attribute__((unused)),
|
2529
|
-
- size_t key_length __attribute__((unused)),
|
2530
|
-
+static memcached_return callback_dump_counter(memcached_st *ptr __attribute__((unused)),
|
2531
|
-
+ const char *key __attribute__((unused)),
|
2532
|
-
+ size_t key_length __attribute__((unused)),
|
2533
|
-
void *context)
|
2534
|
-
{
|
2535
|
-
uint32_t *counter= (uint32_t *)context;
|
2536
|
-
@@ -3932,214 +3900,6 @@
|
2537
|
-
}
|
2538
|
-
#endif
|
2539
|
-
|
2540
|
-
-static test_return replication_set_test(memcached_st *memc)
|
2541
|
-
-{
|
2542
|
-
- memcached_return rc;
|
2543
|
-
- memcached_st *memc_clone= memcached_clone(NULL, memc);
|
2544
|
-
- memcached_behavior_set(memc_clone, MEMCACHED_BEHAVIOR_NUMBER_OF_REPLICAS, 0);
|
2545
|
-
-
|
2546
|
-
- rc= memcached_set(memc, "bubba", 5, "0", 1, 0, 0);
|
2547
|
-
- assert(rc == MEMCACHED_SUCCESS);
|
2548
|
-
-
|
2549
|
-
- /*
|
2550
|
-
- ** We are using the quiet commands to store the replicas, so we need
|
2551
|
-
- ** to ensure that all of them are processed before we can continue.
|
2552
|
-
- ** In the test we go directly from storing the object to trying to
|
2553
|
-
- ** receive the object from all of the different servers, so we
|
2554
|
-
- ** could end up in a race condition (the memcached server hasn't yet
|
2555
|
-
- ** processed the quiet command from the replication set when it process
|
2556
|
-
- ** the request from the other client (created by the clone)). As a
|
2557
|
-
- ** workaround for that we call memcached_quit to send the quit command
|
2558
|
-
- ** to the server and wait for the response ;-) If you use the test code
|
2559
|
-
- ** as an example for your own code, please note that you shouldn't need
|
2560
|
-
- ** to do this ;-)
|
2561
|
-
- */
|
2562
|
-
- memcached_quit(memc);
|
2563
|
-
-
|
2564
|
-
- /*
|
2565
|
-
- ** "bubba" should now be stored on all of our servers. We don't have an
|
2566
|
-
- ** easy to use API to address each individual server, so I'll just iterate
|
2567
|
-
- ** through a bunch of "master keys" and I should most likely hit all of the
|
2568
|
-
- ** servers...
|
2569
|
-
- */
|
2570
|
-
- for (int x= 'a'; x <= 'z'; ++x)
|
2571
|
-
- {
|
2572
|
-
- char key[2]= { [0]= (char)x };
|
2573
|
-
- size_t len;
|
2574
|
-
- uint32_t flags;
|
2575
|
-
- char *val= memcached_get_by_key(memc_clone, key, 1, "bubba", 5,
|
2576
|
-
- GET_LEN_ARG_UNSPECIFIED,
|
2577
|
-
- &len, &flags, &rc);
|
2578
|
-
- assert(rc == MEMCACHED_SUCCESS);
|
2579
|
-
- assert(val != NULL);
|
2580
|
-
- free(val);
|
2581
|
-
- }
|
2582
|
-
-
|
2583
|
-
- memcached_free(memc_clone);
|
2584
|
-
-
|
2585
|
-
- return TEST_SUCCESS;
|
2586
|
-
-}
|
2587
|
-
-
|
2588
|
-
-static test_return replication_get_test(memcached_st *memc)
|
2589
|
-
-{
|
2590
|
-
- memcached_return rc;
|
2591
|
-
-
|
2592
|
-
- /*
|
2593
|
-
- * Don't do the following in your code. I am abusing the internal details
|
2594
|
-
- * within the library, and this is not a supported interface.
|
2595
|
-
- * This is to verify correct behavior in the library
|
2596
|
-
- */
|
2597
|
-
- for (uint32_t host= 0; host < memc->number_of_hosts; ++host)
|
2598
|
-
- {
|
2599
|
-
- memcached_st *memc_clone= memcached_clone(NULL, memc);
|
2600
|
-
- memc_clone->hosts[host].port= 0;
|
2601
|
-
-
|
2602
|
-
- for (int x= 'a'; x <= 'z'; ++x)
|
2603
|
-
- {
|
2604
|
-
- char key[2]= { [0]= (char)x };
|
2605
|
-
- size_t len;
|
2606
|
-
- uint32_t flags;
|
2607
|
-
- char *val= memcached_get_by_key(memc_clone, key, 1, "bubba", 5,
|
2608
|
-
- GET_LEN_ARG_UNSPECIFIED,
|
2609
|
-
- &len, &flags, &rc);
|
2610
|
-
- assert(rc == MEMCACHED_SUCCESS);
|
2611
|
-
- assert(val != NULL);
|
2612
|
-
- free(val);
|
2613
|
-
- }
|
2614
|
-
-
|
2615
|
-
- memcached_free(memc_clone);
|
2616
|
-
- }
|
2617
|
-
-
|
2618
|
-
- return TEST_SUCCESS;
|
2619
|
-
-}
|
2620
|
-
-
|
2621
|
-
-static test_return replication_mget_test(memcached_st *memc)
|
2622
|
-
-{
|
2623
|
-
- memcached_return rc;
|
2624
|
-
- memcached_st *memc_clone= memcached_clone(NULL, memc);
|
2625
|
-
- memcached_behavior_set(memc_clone, MEMCACHED_BEHAVIOR_NUMBER_OF_REPLICAS, 0);
|
2626
|
-
-
|
2627
|
-
- const char *keys[]= { "bubba", "key1", "key2", "key3" };
|
2628
|
-
- size_t len[]= { 5, 4, 4, 4 };
|
2629
|
-
-
|
2630
|
-
- for (int x=0; x< 4; ++x)
|
2631
|
-
- {
|
2632
|
-
- rc= memcached_set(memc, keys[x], len[x], "0", 1, 0, 0);
|
2633
|
-
- assert(rc == MEMCACHED_SUCCESS);
|
2634
|
-
- }
|
2635
|
-
-
|
2636
|
-
- /*
|
2637
|
-
- ** We are using the quiet commands to store the replicas, so we need
|
2638
|
-
- ** to ensure that all of them are processed before we can continue.
|
2639
|
-
- ** In the test we go directly from storing the object to trying to
|
2640
|
-
- ** receive the object from all of the different servers, so we
|
2641
|
-
- ** could end up in a race condition (the memcached server hasn't yet
|
2642
|
-
- ** processed the quiet command from the replication set when it process
|
2643
|
-
- ** the request from the other client (created by the clone)). As a
|
2644
|
-
- ** workaround for that we call memcached_quit to send the quit command
|
2645
|
-
- ** to the server and wait for the response ;-) If you use the test code
|
2646
|
-
- ** as an example for your own code, please note that you shouldn't need
|
2647
|
-
- ** to do this ;-)
|
2648
|
-
- */
|
2649
|
-
- memcached_quit(memc);
|
2650
|
-
-
|
2651
|
-
- /*
|
2652
|
-
- * Don't do the following in your code. I am abusing the internal details
|
2653
|
-
- * within the library, and this is not a supported interface.
|
2654
|
-
- * This is to verify correct behavior in the library
|
2655
|
-
- */
|
2656
|
-
- memcached_result_st result_obj;
|
2657
|
-
- for (uint32_t host= 0; host < memc_clone->number_of_hosts; host++)
|
2658
|
-
- {
|
2659
|
-
- memcached_st *new_clone= memcached_clone(NULL, memc);
|
2660
|
-
- new_clone->hosts[host].port= 0;
|
2661
|
-
-
|
2662
|
-
- for (int x= 'a'; x <= 'z'; ++x)
|
2663
|
-
- {
|
2664
|
-
- const char key[2]= { [0]= (const char)x };
|
2665
|
-
-
|
2666
|
-
- rc= memcached_mget_by_key(new_clone, key, 1, keys, len,
|
2667
|
-
- 4, GET_LEN_ARG_UNSPECIFIED);
|
2668
|
-
- assert(rc == MEMCACHED_SUCCESS);
|
2669
|
-
-
|
2670
|
-
- memcached_result_st *results= memcached_result_create(new_clone, &result_obj);
|
2671
|
-
- assert(results);
|
2672
|
-
-
|
2673
|
-
- int hits= 0;
|
2674
|
-
- while ((results= memcached_fetch_result(new_clone, &result_obj, &rc)) != NULL)
|
2675
|
-
- {
|
2676
|
-
- hits++;
|
2677
|
-
- }
|
2678
|
-
- assert(hits == 4);
|
2679
|
-
- memcached_result_free(&result_obj);
|
2680
|
-
- }
|
2681
|
-
-
|
2682
|
-
- memcached_free(new_clone);
|
2683
|
-
- }
|
2684
|
-
-
|
2685
|
-
- memcached_free(memc_clone);
|
2686
|
-
-
|
2687
|
-
- return TEST_SUCCESS;
|
2688
|
-
-}
|
2689
|
-
-
|
2690
|
-
-static test_return replication_delete_test(memcached_st *memc)
|
2691
|
-
-{
|
2692
|
-
- memcached_return rc;
|
2693
|
-
- memcached_st *memc_clone= memcached_clone(NULL, memc);
|
2694
|
-
- /* Delete the items from all of the servers except 1 */
|
2695
|
-
- uint64_t repl= memcached_behavior_get(memc,
|
2696
|
-
- MEMCACHED_BEHAVIOR_NUMBER_OF_REPLICAS);
|
2697
|
-
- memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_NUMBER_OF_REPLICAS, --repl);
|
2698
|
-
-
|
2699
|
-
- const char *keys[]= { "bubba", "key1", "key2", "key3" };
|
2700
|
-
- size_t len[]= { 5, 4, 4, 4 };
|
2701
|
-
-
|
2702
|
-
- for (int x=0; x< 4; ++x)
|
2703
|
-
- {
|
2704
|
-
- rc= memcached_delete_by_key(memc, keys[0], len[0], keys[x], len[x], 0);
|
2705
|
-
- assert(rc == MEMCACHED_SUCCESS);
|
2706
|
-
- }
|
2707
|
-
-
|
2708
|
-
- /*
|
2709
|
-
- * Don't do the following in your code. I am abusing the internal details
|
2710
|
-
- * within the library, and this is not a supported interface.
|
2711
|
-
- * This is to verify correct behavior in the library
|
2712
|
-
- */
|
2713
|
-
- uint32_t hash= memcached_generate_hash(memc, keys[0], len[0]);
|
2714
|
-
- for (uint32_t x= 0; x < (repl + 1); ++x)
|
2715
|
-
- {
|
2716
|
-
- memc_clone->hosts[hash].port= 0;
|
2717
|
-
- if (++hash == memc_clone->number_of_hosts)
|
2718
|
-
- hash= 0;
|
2719
|
-
- }
|
2720
|
-
-
|
2721
|
-
- memcached_result_st result_obj;
|
2722
|
-
- for (uint32_t host= 0; host < memc_clone->number_of_hosts; ++host)
|
2723
|
-
- {
|
2724
|
-
- for (int x= 'a'; x <= 'z'; ++x)
|
2725
|
-
- {
|
2726
|
-
- const char key[2]= { [0]= (const char)x };
|
2727
|
-
-
|
2728
|
-
- rc= memcached_mget_by_key(memc_clone, key, 1, keys, len,
|
2729
|
-
- 4, GET_LEN_ARG_UNSPECIFIED);
|
2730
|
-
- assert(rc == MEMCACHED_SUCCESS);
|
2731
|
-
-
|
2732
|
-
- memcached_result_st *results= memcached_result_create(memc_clone, &result_obj);
|
2733
|
-
- assert(results);
|
2734
|
-
-
|
2735
|
-
- int hits= 0;
|
2736
|
-
- while ((results= memcached_fetch_result(memc_clone, &result_obj, &rc)) != NULL)
|
2737
|
-
- {
|
2738
|
-
- ++hits;
|
2739
|
-
- }
|
2740
|
-
- assert(hits == 4);
|
2741
|
-
- memcached_result_free(&result_obj);
|
2742
|
-
- }
|
2743
|
-
- }
|
2744
|
-
- memcached_free(memc_clone);
|
2745
|
-
-
|
2746
|
-
- return TEST_SUCCESS;
|
2747
|
-
-}
|
2748
|
-
|
2749
|
-
static void increment_request_id(uint16_t *id)
|
2750
|
-
{
|
2751
|
-
@@ -4245,7 +4005,7 @@
|
2752
|
-
assert(memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_USE_UDP, 1) == MEMCACHED_SUCCESS);
|
2753
|
-
assert(memc->flags & MEM_USE_UDP);
|
2754
|
-
assert(memc->flags & MEM_NOREPLY);;
|
2755
|
-
-
|
2756
|
-
+
|
2757
|
-
assert(memc->number_of_hosts == 0);
|
2758
|
-
|
2759
|
-
memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_USE_UDP,0);
|
2760
|
-
@@ -4278,11 +4038,11 @@
|
2761
|
-
if (rc == MEMCACHED_SUCCESS ||
|
2762
|
-
memc->hosts[server_key].write_buffer_offset < init_offset)
|
2763
|
-
increment_request_id(&expected_ids[server_key]);
|
2764
|
-
-
|
2765
|
-
+
|
2766
|
-
if (rc == MEMCACHED_SUCCESS)
|
2767
|
-
{
|
2768
|
-
assert(memc->hosts[server_key].write_buffer_offset == UDP_DATAGRAM_HEADER_LENGTH);
|
2769
|
-
- }
|
2770
|
-
+ }
|
2771
|
-
else
|
2772
|
-
{
|
2773
|
-
assert(memc->hosts[server_key].write_buffer_offset != UDP_DATAGRAM_HEADER_LENGTH);
|
2774
|
-
@@ -4370,7 +4130,7 @@
|
2775
|
-
memcached_return rc;
|
2776
|
-
uint16_t *expected_ids= get_udp_request_ids(memc);
|
2777
|
-
unsigned int x;
|
2778
|
-
- for (x= 0; x < memc->number_of_hosts;x++)
|
2779
|
-
+ for (x= 0; x < memc->number_of_hosts;x++)
|
2780
|
-
increment_request_id(&expected_ids[x]);
|
2781
|
-
|
2782
|
-
rc= memcached_flush(memc,0);
|
2783
|
-
@@ -4383,10 +4143,10 @@
|
2784
|
-
memcached_return rc;
|
2785
|
-
const char *key= "incr";
|
2786
|
-
const char *value= "1";
|
2787
|
-
- rc= memcached_set(memc, key, strlen(key),
|
2788
|
-
+ rc= memcached_set(memc, key, strlen(key),
|
2789
|
-
value, strlen(value),
|
2790
|
-
(time_t)0, (uint32_t)0);
|
2791
|
-
-
|
2792
|
-
+
|
2793
|
-
assert(rc == MEMCACHED_SUCCESS);
|
2794
|
-
uint16_t *expected_ids= get_udp_request_ids(memc);
|
2795
|
-
unsigned int server_key= memcached_generate_hash(memc, key, strlen(key));
|
2796
|
-
@@ -4402,10 +4162,10 @@
|
2797
|
-
memcached_return rc;
|
2798
|
-
const char *key= "decr";
|
2799
|
-
const char *value= "1";
|
2800
|
-
- rc= memcached_set(memc, key, strlen(key),
|
2801
|
-
+ rc= memcached_set(memc, key, strlen(key),
|
2802
|
-
value, strlen(value),
|
2803
|
-
(time_t)0, (uint32_t)0);
|
2804
|
-
-
|
2805
|
-
+
|
2806
|
-
assert(rc == MEMCACHED_SUCCESS);
|
2807
|
-
uint16_t *expected_ids= get_udp_request_ids(memc);
|
2808
|
-
unsigned int server_key= memcached_generate_hash(memc, key, strlen(key));
|
2809
|
-
@@ -4521,16 +4281,16 @@
|
2810
|
-
const char **ptr;
|
2811
|
-
uint32_t values[]= { 3195025439U, 2556848621U, 3724893440U, 3332385401U,
|
2812
|
-
245758794U, 2550894432U, 121710495U, 3053817768U,
|
2813
|
-
- 1250994555U, 1862072655U, 2631955953U, 2951528551U,
|
2814
|
-
+ 1250994555U, 1862072655U, 2631955953U, 2951528551U,
|
2815
|
-
1451250070U, 2820856945U, 2060845566U, 3646985608U,
|
2816
|
-
2138080750U, 217675895U, 2230934345U, 1234361223U,
|
2817
|
-
- 3968582726U, 2455685270U, 1293568479U, 199067604U,
|
2818
|
-
+ 3968582726U, 2455685270U, 1293568479U, 199067604U,
|
2819
|
-
2042482093U };
|
2820
|
-
|
2821
|
-
|
2822
|
-
for (ptr= list, x= 0; *ptr; ptr++, x++)
|
2823
|
-
{
|
2824
|
-
- uint32_t hash_val;
|
2825
|
-
+ uint32_t hash_val;
|
2826
|
-
|
2827
|
-
hash_val= memcached_generate_hash_value(*ptr, strlen(*ptr), MEMCACHED_HASH_MD5);
|
2828
|
-
assert(values[x] == hash_val);
|
2829
|
-
@@ -4545,12 +4305,12 @@
|
2830
|
-
const char **ptr;
|
2831
|
-
uint32_t values[]= { 10542U, 22009U, 14526U, 19510U, 19432U, 10199U, 20634U,
|
2832
|
-
9369U, 11511U, 10362U, 7893U, 31289U, 11313U, 9354U,
|
2833
|
-
- 7621U, 30628U, 15218U, 25967U, 2695U, 9380U,
|
2834
|
-
+ 7621U, 30628U, 15218U, 25967U, 2695U, 9380U,
|
2835
|
-
17300U, 28156U, 9192U, 20484U, 16925U };
|
2836
|
-
|
2837
|
-
for (ptr= list, x= 0; *ptr; ptr++, x++)
|
2838
|
-
{
|
2839
|
-
- uint32_t hash_val;
|
2840
|
-
+ uint32_t hash_val;
|
2841
|
-
|
2842
|
-
hash_val= memcached_generate_hash_value(*ptr, strlen(*ptr), MEMCACHED_HASH_CRC);
|
2843
|
-
assert(values[x] == hash_val);
|
2844
|
-
@@ -4563,17 +4323,17 @@
|
2845
|
-
{
|
2846
|
-
uint32_t x;
|
2847
|
-
const char **ptr;
|
2848
|
-
- uint32_t values[]= { 473199127U, 4148981457U, 3971873300U, 3257986707U,
|
2849
|
-
- 1722477987U, 2991193800U, 4147007314U, 3633179701U,
|
2850
|
-
+ uint32_t values[]= { 473199127U, 4148981457U, 3971873300U, 3257986707U,
|
2851
|
-
+ 1722477987U, 2991193800U, 4147007314U, 3633179701U,
|
2852
|
-
1805162104U, 3503289120U, 3395702895U, 3325073042U,
|
2853
|
-
2345265314U, 3340346032U, 2722964135U, 1173398992U,
|
2854
|
-
- 2815549194U, 2562818319U, 224996066U, 2680194749U,
|
2855
|
-
+ 2815549194U, 2562818319U, 224996066U, 2680194749U,
|
2856
|
-
3035305390U, 246890365U, 2395624193U, 4145193337U,
|
2857
|
-
1801941682U };
|
2858
|
-
|
2859
|
-
for (ptr= list, x= 0; *ptr; ptr++, x++)
|
2860
|
-
{
|
2861
|
-
- uint32_t hash_val;
|
2862
|
-
+ uint32_t hash_val;
|
2863
|
-
|
2864
|
-
hash_val= memcached_generate_hash_value(*ptr, strlen(*ptr), MEMCACHED_HASH_FNV1_64);
|
2865
|
-
assert(values[x] == hash_val);
|
2866
|
-
@@ -4586,17 +4346,17 @@
|
2867
|
-
{
|
2868
|
-
uint32_t x;
|
2869
|
-
const char **ptr;
|
2870
|
-
- uint32_t values[]= { 1488911807U, 2500855813U, 1510099634U, 1390325195U,
|
2871
|
-
- 3647689787U, 3241528582U, 1669328060U, 2604311949U,
|
2872
|
-
+ uint32_t values[]= { 1488911807U, 2500855813U, 1510099634U, 1390325195U,
|
2873
|
-
+ 3647689787U, 3241528582U, 1669328060U, 2604311949U,
|
2874
|
-
734810122U, 1516407546U, 560948863U, 1767346780U,
|
2875
|
-
561034892U, 4156330026U, 3716417003U, 3475297030U,
|
2876
|
-
- 1518272172U, 227211583U, 3938128828U, 126112909U,
|
2877
|
-
+ 1518272172U, 227211583U, 3938128828U, 126112909U,
|
2878
|
-
3043416448U, 3131561933U, 1328739897U, 2455664041U,
|
2879
|
-
- 2272238452U };
|
2880
|
-
+ 2272238452U };
|
2881
|
-
|
2882
|
-
for (ptr= list, x= 0; *ptr; ptr++, x++)
|
2883
|
-
{
|
2884
|
-
- uint32_t hash_val;
|
2885
|
-
+ uint32_t hash_val;
|
2886
|
-
|
2887
|
-
hash_val= memcached_generate_hash_value(*ptr, strlen(*ptr), MEMCACHED_HASH_FNV1A_64);
|
2888
|
-
assert(values[x] == hash_val);
|
2889
|
-
@@ -4609,9 +4369,9 @@
|
2890
|
-
{
|
2891
|
-
uint32_t x;
|
2892
|
-
const char **ptr;
|
2893
|
-
- uint32_t values[]= { 67176023U, 1190179409U, 2043204404U, 3221866419U,
|
2894
|
-
+ uint32_t values[]= { 67176023U, 1190179409U, 2043204404U, 3221866419U,
|
2895
|
-
2567703427U, 3787535528U, 4147287986U, 3500475733U,
|
2896
|
-
- 344481048U, 3865235296U, 2181839183U, 119581266U,
|
2897
|
-
+ 344481048U, 3865235296U, 2181839183U, 119581266U,
|
2898
|
-
510234242U, 4248244304U, 1362796839U, 103389328U,
|
2899
|
-
1449620010U, 182962511U, 3554262370U, 3206747549U,
|
2900
|
-
1551306158U, 4127558461U, 1889140833U, 2774173721U,
|
2901
|
-
@@ -4620,7 +4380,7 @@
|
2902
|
-
|
2903
|
-
for (ptr= list, x= 0; *ptr; ptr++, x++)
|
2904
|
-
{
|
2905
|
-
- uint32_t hash_val;
|
2906
|
-
+ uint32_t hash_val;
|
2907
|
-
|
2908
|
-
hash_val= memcached_generate_hash_value(*ptr, strlen(*ptr), MEMCACHED_HASH_FNV1_32);
|
2909
|
-
assert(values[x] == hash_val);
|
2910
|
-
@@ -4643,7 +4403,7 @@
|
2911
|
-
|
2912
|
-
for (ptr= list, x= 0; *ptr; ptr++, x++)
|
2913
|
-
{
|
2914
|
-
- uint32_t hash_val;
|
2915
|
-
+ uint32_t hash_val;
|
2916
|
-
|
2917
|
-
hash_val= memcached_generate_hash_value(*ptr, strlen(*ptr), MEMCACHED_HASH_FNV1A_32);
|
2918
|
-
assert(values[x] == hash_val);
|
2919
|
-
@@ -4668,7 +4428,7 @@
|
2920
|
-
|
2921
|
-
for (ptr= list, x= 0; *ptr; ptr++, x++)
|
2922
|
-
{
|
2923
|
-
- uint32_t hash_val;
|
2924
|
-
+ uint32_t hash_val;
|
2925
|
-
|
2926
|
-
hash_val= memcached_generate_hash_value(*ptr, strlen(*ptr), MEMCACHED_HASH_HSIEH);
|
2927
|
-
assert(values[x] == hash_val);
|
2928
|
-
@@ -4691,7 +4451,7 @@
|
2929
|
-
|
2930
|
-
for (ptr= list, x= 0; *ptr; ptr++, x++)
|
2931
|
-
{
|
2932
|
-
- uint32_t hash_val;
|
2933
|
-
+ uint32_t hash_val;
|
2934
|
-
|
2935
|
-
hash_val= memcached_generate_hash_value(*ptr, strlen(*ptr), MEMCACHED_HASH_FNV1_64);
|
2936
|
-
assert(values[x] == hash_val);
|
2937
|
-
@@ -4715,7 +4475,7 @@
|
2938
|
-
|
2939
|
-
for (ptr= list, x= 0; *ptr; ptr++, x++)
|
2940
|
-
{
|
2941
|
-
- uint32_t hash_val;
|
2942
|
-
+ uint32_t hash_val;
|
2943
|
-
|
2944
|
-
hash_val= memcached_generate_hash_value(*ptr, strlen(*ptr), MEMCACHED_HASH_JENKINS);
|
2945
|
-
assert(values[x] == hash_val);
|
2946
|
-
@@ -4776,7 +4536,7 @@
|
2947
|
-
{"get3", 0, get_test3 },
|
2948
|
-
{"get4", 0, get_test4 },
|
2949
|
-
{"partial mget", 0, get_test5 },
|
2950
|
-
- {"get_len", 1, get_len_test },
|
2951
|
-
+ {"get_len", 1, get_len_test },
|
2952
|
-
{"get_len2", 0, get_len_test2 },
|
2953
|
-
{"get_len3", 0, get_len_test3 },
|
2954
|
-
{"stats_servername", 0, stats_servername_test },
|
2955
|
-
@@ -4859,8 +4619,8 @@
|
2956
|
-
{"user_supplied_bug15", 1, user_supplied_bug15 },
|
2957
|
-
{"user_supplied_bug16", 1, user_supplied_bug16 },
|
2958
|
-
#ifndef __sun
|
2959
|
-
- /*
|
2960
|
-
- ** It seems to be something weird with the character sets..
|
2961
|
-
+ /*
|
2962
|
-
+ ** It seems to be something weird with the character sets..
|
2963
|
-
** value_fetch is unable to parse the value line (iscntrl "fails"), so I
|
2964
|
-
** guess I need to find out how this is supposed to work.. Perhaps I need
|
2965
|
-
** to run the test in a specific locale (I tried zh_CN.UTF-8 without success,
|
2966
|
-
@@ -4874,14 +4634,6 @@
|
2967
|
-
{0, 0, 0}
|
2968
|
-
};
|
2969
|
-
|
2970
|
-
-test_st replication_tests[]= {
|
2971
|
-
- {"set", 1, replication_set_test },
|
2972
|
-
- {"get", 0, replication_get_test },
|
2973
|
-
- {"mget", 0, replication_mget_test },
|
2974
|
-
- {"delete", 0, replication_delete_test },
|
2975
|
-
- {0, 0, 0}
|
2976
|
-
-};
|
2977
|
-
-
|
2978
|
-
test_st generate_tests[] ={
|
2979
|
-
{"generate_pairs", 1, generate_pairs },
|
2980
|
-
{"generate_data", 1, generate_data },
|
2981
|
-
@@ -4988,8 +4740,6 @@
|
2982
|
-
{"consistent_ketama", pre_behavior_ketama, 0, consistent_tests},
|
2983
|
-
{"consistent_ketama_weighted", pre_behavior_ketama_weighted, 0, consistent_weighted_tests},
|
2984
|
-
{"test_hashes", 0, 0, hash_tests},
|
2985
|
-
- {"replication", pre_replication, 0, replication_tests},
|
2986
|
-
- {"replication_noblock", pre_replication_noblock, 0, replication_tests},
|
2987
|
-
{0, 0, 0, 0}
|
2988
|
-
};
|
2989
|
-
|