memcached 1.2.6 → 1.2.7
Sign up to get free protection for your applications and to get access to all the features.
- 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
@@ -0,0 +1,7 @@
|
|
1
|
+
For your convenience libmemcached contains a copy of protocol_binary.h so that
|
2
|
+
you may compile libmemcached without having a memcached server with support
|
3
|
+
for the binary protocol installed on your computer. Please do not modify this
|
4
|
+
fine, but replace it with a fresh copy from a new distribution if they are
|
5
|
+
out of sync.
|
6
|
+
|
7
|
+
Trond Norbye
|
@@ -0,0 +1,366 @@
|
|
1
|
+
/*
|
2
|
+
* Copyright (c) <2008>, Sun Microsystems, Inc.
|
3
|
+
* All rights reserved.
|
4
|
+
*
|
5
|
+
* Redistribution and use in source and binary forms, with or without
|
6
|
+
* modification, are permitted provided that the following conditions are met:
|
7
|
+
* * Redistributions of source code must retain the above copyright
|
8
|
+
* notice, this list of conditions and the following disclaimer.
|
9
|
+
* * Redistributions in binary form must reproduce the above copyright
|
10
|
+
* notice, this list of conditions and the following disclaimer in the
|
11
|
+
* documentation and/or other materials provided with the distribution.
|
12
|
+
* * Neither the name of the nor the
|
13
|
+
* names of its contributors may be used to endorse or promote products
|
14
|
+
* derived from this software without specific prior written permission.
|
15
|
+
*
|
16
|
+
* THIS SOFTWARE IS PROVIDED BY SUN MICROSYSTEMS, INC. ``AS IS'' AND ANY
|
17
|
+
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
18
|
+
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
19
|
+
* DISCLAIMED. IN NO EVENT SHALL SUN MICROSYSTEMS, INC. BE LIABLE FOR ANY
|
20
|
+
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
21
|
+
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
22
|
+
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
23
|
+
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
24
|
+
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
25
|
+
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
26
|
+
*/
|
27
|
+
/*
|
28
|
+
* Summary: Constants used by to implement the binary protocol.
|
29
|
+
*
|
30
|
+
* Copy: See Copyright for the status of this software.
|
31
|
+
*
|
32
|
+
* Author: Trond Norbye <trond.norbye@sun.com>
|
33
|
+
*/
|
34
|
+
|
35
|
+
#ifndef PROTOCOL_BINARY_H
|
36
|
+
#define PROTOCOL_BINARY_H
|
37
|
+
|
38
|
+
#include <stdint.h>
|
39
|
+
|
40
|
+
/**
|
41
|
+
* This file contains definitions of the constants and packet formats
|
42
|
+
* defined in the binary specification. Please note that you _MUST_ remember
|
43
|
+
* to convert each multibyte field to / from network byte order to / from
|
44
|
+
* host order.
|
45
|
+
*/
|
46
|
+
#ifdef __cplusplus
|
47
|
+
extern "C"
|
48
|
+
{
|
49
|
+
#endif
|
50
|
+
|
51
|
+
/**
|
52
|
+
* Definition of the legal "magic" values used in a packet.
|
53
|
+
* See section 3.1 Magic byte
|
54
|
+
*/
|
55
|
+
typedef enum {
|
56
|
+
PROTOCOL_BINARY_REQ = 0x80,
|
57
|
+
PROTOCOL_BINARY_RES = 0x81
|
58
|
+
} protocol_binary_magic;
|
59
|
+
|
60
|
+
/**
|
61
|
+
* Definition of the valid response status numbers.
|
62
|
+
* See section 3.2 Response Status
|
63
|
+
*/
|
64
|
+
typedef enum {
|
65
|
+
PROTOCOL_BINARY_RESPONSE_SUCCESS = 0x00,
|
66
|
+
PROTOCOL_BINARY_RESPONSE_KEY_ENOENT = 0x01,
|
67
|
+
PROTOCOL_BINARY_RESPONSE_KEY_EEXISTS = 0x02,
|
68
|
+
PROTOCOL_BINARY_RESPONSE_E2BIG = 0x03,
|
69
|
+
PROTOCOL_BINARY_RESPONSE_EINVAL = 0x04,
|
70
|
+
PROTOCOL_BINARY_RESPONSE_NOT_STORED = 0x05,
|
71
|
+
PROTOCOL_BINARY_RESPONSE_AUTH_ERROR = 0x20,
|
72
|
+
PROTOCOL_BINARY_RESPONSE_AUTH_CONTINUE = 0x21,
|
73
|
+
PROTOCOL_BINARY_RESPONSE_UNKNOWN_COMMAND = 0x81,
|
74
|
+
PROTOCOL_BINARY_RESPONSE_ENOMEM = 0x82
|
75
|
+
} protocol_binary_response_status;
|
76
|
+
|
77
|
+
/**
|
78
|
+
* Defintion of the different command opcodes.
|
79
|
+
* See section 3.3 Command Opcodes
|
80
|
+
*/
|
81
|
+
typedef enum {
|
82
|
+
PROTOCOL_BINARY_CMD_GET = 0x00,
|
83
|
+
PROTOCOL_BINARY_CMD_SET = 0x01,
|
84
|
+
PROTOCOL_BINARY_CMD_ADD = 0x02,
|
85
|
+
PROTOCOL_BINARY_CMD_REPLACE = 0x03,
|
86
|
+
PROTOCOL_BINARY_CMD_DELETE = 0x04,
|
87
|
+
PROTOCOL_BINARY_CMD_INCREMENT = 0x05,
|
88
|
+
PROTOCOL_BINARY_CMD_DECREMENT = 0x06,
|
89
|
+
PROTOCOL_BINARY_CMD_QUIT = 0x07,
|
90
|
+
PROTOCOL_BINARY_CMD_FLUSH = 0x08,
|
91
|
+
PROTOCOL_BINARY_CMD_GETQ = 0x09,
|
92
|
+
PROTOCOL_BINARY_CMD_NOOP = 0x0a,
|
93
|
+
PROTOCOL_BINARY_CMD_VERSION = 0x0b,
|
94
|
+
PROTOCOL_BINARY_CMD_GETK = 0x0c,
|
95
|
+
PROTOCOL_BINARY_CMD_GETKQ = 0x0d,
|
96
|
+
PROTOCOL_BINARY_CMD_APPEND = 0x0e,
|
97
|
+
PROTOCOL_BINARY_CMD_PREPEND = 0x0f,
|
98
|
+
PROTOCOL_BINARY_CMD_STAT = 0x10,
|
99
|
+
PROTOCOL_BINARY_CMD_SETQ = 0x11,
|
100
|
+
PROTOCOL_BINARY_CMD_ADDQ = 0x12,
|
101
|
+
PROTOCOL_BINARY_CMD_REPLACEQ = 0x13,
|
102
|
+
PROTOCOL_BINARY_CMD_DELETEQ = 0x14,
|
103
|
+
PROTOCOL_BINARY_CMD_INCREMENTQ = 0x15,
|
104
|
+
PROTOCOL_BINARY_CMD_DECREMENTQ = 0x16,
|
105
|
+
PROTOCOL_BINARY_CMD_QUITQ = 0x17,
|
106
|
+
PROTOCOL_BINARY_CMD_FLUSHQ = 0x18,
|
107
|
+
PROTOCOL_BINARY_CMD_APPENDQ = 0x19,
|
108
|
+
PROTOCOL_BINARY_CMD_PREPENDQ = 0x1a,
|
109
|
+
PROTOCOL_BINARY_CMD_SASL_LIST_MECHS = 0x20,
|
110
|
+
PROTOCOL_BINARY_CMD_SASL_AUTH = 0x21,
|
111
|
+
PROTOCOL_BINARY_CMD_SASL_STEP = 0x22,
|
112
|
+
} protocol_binary_command;
|
113
|
+
|
114
|
+
/**
|
115
|
+
* Definition of the data types in the packet
|
116
|
+
* See section 3.4 Data Types
|
117
|
+
*/
|
118
|
+
typedef enum {
|
119
|
+
PROTOCOL_BINARY_RAW_BYTES = 0x00
|
120
|
+
} protocol_binary_datatypes;
|
121
|
+
|
122
|
+
/**
|
123
|
+
* Definition of the header structure for a request packet.
|
124
|
+
* See section 2
|
125
|
+
*/
|
126
|
+
typedef union {
|
127
|
+
struct {
|
128
|
+
uint8_t magic;
|
129
|
+
uint8_t opcode;
|
130
|
+
uint16_t keylen;
|
131
|
+
uint8_t extlen;
|
132
|
+
uint8_t datatype;
|
133
|
+
uint16_t reserved;
|
134
|
+
uint32_t bodylen;
|
135
|
+
uint32_t opaque;
|
136
|
+
uint64_t cas;
|
137
|
+
} request;
|
138
|
+
uint8_t bytes[24];
|
139
|
+
} protocol_binary_request_header;
|
140
|
+
|
141
|
+
/**
|
142
|
+
* Definition of the header structure for a response packet.
|
143
|
+
* See section 2
|
144
|
+
*/
|
145
|
+
typedef union {
|
146
|
+
struct {
|
147
|
+
uint8_t magic;
|
148
|
+
uint8_t opcode;
|
149
|
+
uint16_t keylen;
|
150
|
+
uint8_t extlen;
|
151
|
+
uint8_t datatype;
|
152
|
+
uint16_t status;
|
153
|
+
uint32_t bodylen;
|
154
|
+
uint32_t opaque;
|
155
|
+
uint64_t cas;
|
156
|
+
} response;
|
157
|
+
uint8_t bytes[24];
|
158
|
+
} protocol_binary_response_header;
|
159
|
+
|
160
|
+
/**
|
161
|
+
* Definition of a request-packet containing no extras
|
162
|
+
*/
|
163
|
+
typedef union {
|
164
|
+
struct {
|
165
|
+
protocol_binary_request_header header;
|
166
|
+
} message;
|
167
|
+
uint8_t bytes[sizeof(protocol_binary_request_header)];
|
168
|
+
} protocol_binary_request_no_extras;
|
169
|
+
|
170
|
+
/**
|
171
|
+
* Definition of a response-packet containing no extras
|
172
|
+
*/
|
173
|
+
typedef union {
|
174
|
+
struct {
|
175
|
+
protocol_binary_response_header header;
|
176
|
+
} message;
|
177
|
+
uint8_t bytes[sizeof(protocol_binary_response_header)];
|
178
|
+
} protocol_binary_response_no_extras;
|
179
|
+
|
180
|
+
/**
|
181
|
+
* Definition of the packet used by the get, getq, getk and getkq command.
|
182
|
+
* See section 4
|
183
|
+
*/
|
184
|
+
typedef protocol_binary_request_no_extras protocol_binary_request_get;
|
185
|
+
typedef protocol_binary_request_no_extras protocol_binary_request_getq;
|
186
|
+
typedef protocol_binary_request_no_extras protocol_binary_request_getk;
|
187
|
+
typedef protocol_binary_request_no_extras protocol_binary_request_getkq;
|
188
|
+
|
189
|
+
/**
|
190
|
+
* Definition of the packet returned from a successful get, getq, getk and
|
191
|
+
* getkq.
|
192
|
+
* See section 4
|
193
|
+
*/
|
194
|
+
typedef union {
|
195
|
+
struct {
|
196
|
+
protocol_binary_response_header header;
|
197
|
+
struct {
|
198
|
+
uint32_t flags;
|
199
|
+
} body;
|
200
|
+
} message;
|
201
|
+
uint8_t bytes[sizeof(protocol_binary_response_header) + 4];
|
202
|
+
} protocol_binary_response_get;
|
203
|
+
|
204
|
+
typedef protocol_binary_response_get protocol_binary_response_getq;
|
205
|
+
typedef protocol_binary_response_get protocol_binary_response_getk;
|
206
|
+
typedef protocol_binary_response_get protocol_binary_response_getkq;
|
207
|
+
|
208
|
+
/**
|
209
|
+
* Definition of the packet used by the delete command
|
210
|
+
* See section 4
|
211
|
+
*/
|
212
|
+
typedef protocol_binary_request_no_extras protocol_binary_request_delete;
|
213
|
+
|
214
|
+
/**
|
215
|
+
* Definition of the packet returned by the delete command
|
216
|
+
* See section 4
|
217
|
+
*/
|
218
|
+
typedef protocol_binary_response_no_extras protocol_binary_response_delete;
|
219
|
+
|
220
|
+
/**
|
221
|
+
* Definition of the packet used by the flush command
|
222
|
+
* See section 4
|
223
|
+
* Please note that the expiration field is optional, so remember to see
|
224
|
+
* check the header.bodysize to see if it is present.
|
225
|
+
*/
|
226
|
+
typedef union {
|
227
|
+
struct {
|
228
|
+
protocol_binary_request_header header;
|
229
|
+
struct {
|
230
|
+
uint32_t expiration;
|
231
|
+
} body;
|
232
|
+
} message;
|
233
|
+
uint8_t bytes[sizeof(protocol_binary_request_header) + 4];
|
234
|
+
} protocol_binary_request_flush;
|
235
|
+
|
236
|
+
/**
|
237
|
+
* Definition of the packet returned by the flush command
|
238
|
+
* See section 4
|
239
|
+
*/
|
240
|
+
typedef protocol_binary_response_no_extras protocol_binary_response_flush;
|
241
|
+
|
242
|
+
/**
|
243
|
+
* Definition of the packet used by set, add and replace
|
244
|
+
* See section 4
|
245
|
+
*/
|
246
|
+
typedef union {
|
247
|
+
struct {
|
248
|
+
protocol_binary_request_header header;
|
249
|
+
struct {
|
250
|
+
uint32_t flags;
|
251
|
+
uint32_t expiration;
|
252
|
+
} body;
|
253
|
+
} message;
|
254
|
+
uint8_t bytes[sizeof(protocol_binary_request_header) + 8];
|
255
|
+
} protocol_binary_request_set;
|
256
|
+
typedef protocol_binary_request_set protocol_binary_request_add;
|
257
|
+
typedef protocol_binary_request_set protocol_binary_request_replace;
|
258
|
+
|
259
|
+
/**
|
260
|
+
* Definition of the packet returned by set, add and replace
|
261
|
+
* See section 4
|
262
|
+
*/
|
263
|
+
typedef protocol_binary_response_no_extras protocol_binary_response_set;
|
264
|
+
typedef protocol_binary_response_no_extras protocol_binary_response_add;
|
265
|
+
typedef protocol_binary_response_no_extras protocol_binary_response_replace;
|
266
|
+
|
267
|
+
/**
|
268
|
+
* Definition of the noop packet
|
269
|
+
* See section 4
|
270
|
+
*/
|
271
|
+
typedef protocol_binary_request_no_extras protocol_binary_request_noop;
|
272
|
+
|
273
|
+
/**
|
274
|
+
* Definition of the packet returned by the noop command
|
275
|
+
* See section 4
|
276
|
+
*/
|
277
|
+
typedef protocol_binary_response_no_extras protocol_binary_response_noop;
|
278
|
+
|
279
|
+
/**
|
280
|
+
* Definition of the structure used by the increment and decrement
|
281
|
+
* command.
|
282
|
+
* See section 4
|
283
|
+
*/
|
284
|
+
typedef union {
|
285
|
+
struct {
|
286
|
+
protocol_binary_request_header header;
|
287
|
+
struct {
|
288
|
+
uint64_t delta;
|
289
|
+
uint64_t initial;
|
290
|
+
uint32_t expiration;
|
291
|
+
} body;
|
292
|
+
} message;
|
293
|
+
uint8_t bytes[sizeof(protocol_binary_request_header) + 20];
|
294
|
+
} protocol_binary_request_incr;
|
295
|
+
typedef protocol_binary_request_incr protocol_binary_request_decr;
|
296
|
+
|
297
|
+
/**
|
298
|
+
* Definition of the response from an incr or decr command
|
299
|
+
* command.
|
300
|
+
* See section 4
|
301
|
+
*/
|
302
|
+
typedef union {
|
303
|
+
struct {
|
304
|
+
protocol_binary_response_header header;
|
305
|
+
struct {
|
306
|
+
uint64_t value;
|
307
|
+
} body;
|
308
|
+
} message;
|
309
|
+
uint8_t bytes[sizeof(protocol_binary_response_header) + 8];
|
310
|
+
} protocol_binary_response_incr;
|
311
|
+
typedef protocol_binary_response_incr protocol_binary_response_decr;
|
312
|
+
|
313
|
+
/**
|
314
|
+
* Definition of the quit
|
315
|
+
* See section 4
|
316
|
+
*/
|
317
|
+
typedef protocol_binary_request_no_extras protocol_binary_request_quit;
|
318
|
+
|
319
|
+
/**
|
320
|
+
* Definition of the packet returned by the quit command
|
321
|
+
* See section 4
|
322
|
+
*/
|
323
|
+
typedef protocol_binary_response_no_extras protocol_binary_response_quit;
|
324
|
+
|
325
|
+
/**
|
326
|
+
* Definition of the packet used by append and prepend command
|
327
|
+
* See section 4
|
328
|
+
*/
|
329
|
+
typedef protocol_binary_request_no_extras protocol_binary_request_append;
|
330
|
+
typedef protocol_binary_request_no_extras protocol_binary_request_prepend;
|
331
|
+
|
332
|
+
/**
|
333
|
+
* Definition of the packet returned from a successful append or prepend
|
334
|
+
* See section 4
|
335
|
+
*/
|
336
|
+
typedef protocol_binary_response_no_extras protocol_binary_response_append;
|
337
|
+
typedef protocol_binary_response_no_extras protocol_binary_response_prepend;
|
338
|
+
|
339
|
+
/**
|
340
|
+
* Definition of the packet used by the version command
|
341
|
+
* See section 4
|
342
|
+
*/
|
343
|
+
typedef protocol_binary_request_no_extras protocol_binary_request_version;
|
344
|
+
|
345
|
+
/**
|
346
|
+
* Definition of the packet returned from a successful version command
|
347
|
+
* See section 4
|
348
|
+
*/
|
349
|
+
typedef protocol_binary_response_no_extras protocol_binary_response_version;
|
350
|
+
|
351
|
+
|
352
|
+
/**
|
353
|
+
* Definition of the packet used by the stats command.
|
354
|
+
* See section 4
|
355
|
+
*/
|
356
|
+
typedef protocol_binary_request_no_extras protocol_binary_request_stats;
|
357
|
+
|
358
|
+
/**
|
359
|
+
* Definition of the packet returned from a successful stats command
|
360
|
+
* See section 4
|
361
|
+
*/
|
362
|
+
typedef protocol_binary_response_no_extras protocol_binary_response_stats;
|
363
|
+
#ifdef __cplusplus
|
364
|
+
}
|
365
|
+
#endif
|
366
|
+
#endif /* PROTOCOL_BINARY_H */
|
@@ -0,0 +1,72 @@
|
|
1
|
+
#include "common.h"
|
2
|
+
|
3
|
+
void libmemcached_free(memcached_st *ptr, void *mem)
|
4
|
+
{
|
5
|
+
(void) ptr;
|
6
|
+
free(mem);
|
7
|
+
}
|
8
|
+
|
9
|
+
void *libmemcached_malloc(memcached_st *ptr, size_t size)
|
10
|
+
{
|
11
|
+
(void) ptr;
|
12
|
+
return malloc(size);
|
13
|
+
}
|
14
|
+
|
15
|
+
void *libmemcached_realloc(memcached_st *ptr, void *mem, size_t size)
|
16
|
+
{
|
17
|
+
(void) ptr;
|
18
|
+
return realloc(mem, size);
|
19
|
+
}
|
20
|
+
|
21
|
+
void *libmemcached_calloc(memcached_st *ptr, size_t nelem, size_t size)
|
22
|
+
{
|
23
|
+
if (ptr->call_malloc != libmemcached_malloc)
|
24
|
+
{
|
25
|
+
void *ret = libmemcached_malloc(ptr, nelem * size);
|
26
|
+
if (ret != NULL)
|
27
|
+
memset(ret, 0, nelem * size);
|
28
|
+
|
29
|
+
return ret;
|
30
|
+
}
|
31
|
+
|
32
|
+
return calloc(nelem, size);
|
33
|
+
}
|
34
|
+
|
35
|
+
memcached_return memcached_set_memory_allocators(memcached_st *ptr,
|
36
|
+
memcached_malloc_function mem_malloc,
|
37
|
+
memcached_free_function mem_free,
|
38
|
+
memcached_realloc_function mem_realloc,
|
39
|
+
memcached_calloc_function mem_calloc)
|
40
|
+
{
|
41
|
+
/* All should be set, or none should be set */
|
42
|
+
if (mem_malloc == NULL && mem_free == NULL && mem_realloc == NULL && mem_calloc == NULL)
|
43
|
+
{
|
44
|
+
ptr->call_malloc= libmemcached_malloc;
|
45
|
+
ptr->call_free= libmemcached_free;
|
46
|
+
ptr->call_realloc= libmemcached_realloc;
|
47
|
+
ptr->call_calloc= libmemcached_calloc;
|
48
|
+
}
|
49
|
+
else if (mem_malloc == NULL || mem_free == NULL || mem_realloc == NULL || mem_calloc == NULL)
|
50
|
+
return MEMCACHED_FAILURE;
|
51
|
+
else
|
52
|
+
{
|
53
|
+
ptr->call_malloc= mem_malloc;
|
54
|
+
ptr->call_free= mem_free;
|
55
|
+
ptr->call_realloc= mem_realloc;
|
56
|
+
ptr->call_calloc= mem_calloc;
|
57
|
+
}
|
58
|
+
|
59
|
+
return MEMCACHED_SUCCESS;
|
60
|
+
}
|
61
|
+
|
62
|
+
void memcached_get_memory_allocators(memcached_st *ptr,
|
63
|
+
memcached_malloc_function *mem_malloc,
|
64
|
+
memcached_free_function *mem_free,
|
65
|
+
memcached_realloc_function *mem_realloc,
|
66
|
+
memcached_calloc_function *mem_calloc)
|
67
|
+
{
|
68
|
+
*mem_malloc= ptr->call_malloc;
|
69
|
+
*mem_free= ptr->call_free;
|
70
|
+
*mem_realloc= ptr->call_realloc;
|
71
|
+
*mem_calloc= ptr->call_calloc;
|
72
|
+
}
|
@@ -0,0 +1,100 @@
|
|
1
|
+
#include "common.h"
|
2
|
+
|
3
|
+
static void calc_largest_consumption(memcached_analysis_st *result,
|
4
|
+
const uint32_t server_num,
|
5
|
+
const uint64_t nbytes)
|
6
|
+
{
|
7
|
+
if (result->most_used_bytes < nbytes)
|
8
|
+
{
|
9
|
+
result->most_used_bytes= nbytes;
|
10
|
+
result->most_consumed_server= server_num;
|
11
|
+
}
|
12
|
+
}
|
13
|
+
|
14
|
+
static void calc_oldest_node(memcached_analysis_st *result,
|
15
|
+
const uint32_t server_num,
|
16
|
+
const uint32_t uptime)
|
17
|
+
{
|
18
|
+
if (result->longest_uptime < uptime)
|
19
|
+
{
|
20
|
+
result->longest_uptime= uptime;
|
21
|
+
result->oldest_server= server_num;
|
22
|
+
}
|
23
|
+
}
|
24
|
+
|
25
|
+
static void calc_least_free_node(memcached_analysis_st *result,
|
26
|
+
const uint32_t server_num,
|
27
|
+
const uint64_t max_allowed_bytes,
|
28
|
+
const uint64_t used_bytes)
|
29
|
+
{
|
30
|
+
uint64_t remaining_bytes= max_allowed_bytes - used_bytes;
|
31
|
+
|
32
|
+
if (result->least_remaining_bytes == 0 ||
|
33
|
+
remaining_bytes < result->least_remaining_bytes)
|
34
|
+
{
|
35
|
+
result->least_remaining_bytes= remaining_bytes;
|
36
|
+
result->least_free_server= server_num;
|
37
|
+
}
|
38
|
+
}
|
39
|
+
|
40
|
+
static void calc_average_item_size(memcached_analysis_st *result,
|
41
|
+
const uint64_t total_items,
|
42
|
+
const uint64_t total_bytes)
|
43
|
+
{
|
44
|
+
if (total_items > 0 && total_bytes > 0)
|
45
|
+
result->average_item_size= (uint32_t) (total_bytes / total_items);
|
46
|
+
}
|
47
|
+
|
48
|
+
static void calc_hit_ratio(memcached_analysis_st *result,
|
49
|
+
const uint64_t total_get_hits,
|
50
|
+
const uint64_t total_get_cmds)
|
51
|
+
{
|
52
|
+
if (total_get_hits == 0 || total_get_cmds == 0)
|
53
|
+
{
|
54
|
+
result->pool_hit_ratio= 0;
|
55
|
+
return;
|
56
|
+
}
|
57
|
+
|
58
|
+
double temp= (double) (total_get_hits/total_get_cmds);
|
59
|
+
result->pool_hit_ratio= temp * 100;
|
60
|
+
}
|
61
|
+
|
62
|
+
memcached_analysis_st *memcached_analyze(memcached_st *memc,
|
63
|
+
memcached_stat_st *memc_stat,
|
64
|
+
memcached_return *error)
|
65
|
+
{
|
66
|
+
uint64_t total_items= 0, total_bytes= 0;
|
67
|
+
uint64_t total_get_cmds= 0, total_get_hits= 0;
|
68
|
+
uint32_t server_count, x;
|
69
|
+
memcached_analysis_st *result;
|
70
|
+
|
71
|
+
*error= MEMCACHED_SUCCESS;
|
72
|
+
server_count= memcached_server_count(memc);
|
73
|
+
result= (memcached_analysis_st*)calloc(memc->number_of_hosts,
|
74
|
+
sizeof(memcached_analysis_st));
|
75
|
+
|
76
|
+
if (!result)
|
77
|
+
{
|
78
|
+
*error= MEMCACHED_MEMORY_ALLOCATION_FAILURE;
|
79
|
+
return NULL;
|
80
|
+
}
|
81
|
+
|
82
|
+
for (x= 0; x < server_count; x++)
|
83
|
+
{
|
84
|
+
calc_largest_consumption(result, x, memc_stat[x].bytes);
|
85
|
+
calc_oldest_node(result, x, memc_stat[x].uptime);
|
86
|
+
calc_least_free_node(result, x,
|
87
|
+
memc_stat[x].limit_maxbytes,
|
88
|
+
memc_stat[x].bytes);
|
89
|
+
|
90
|
+
total_get_hits+= memc_stat[x].get_hits;
|
91
|
+
total_get_cmds+= memc_stat[x].cmd_get;
|
92
|
+
total_items+= memc_stat[x].curr_items;
|
93
|
+
total_bytes+= memc_stat[x].bytes;
|
94
|
+
}
|
95
|
+
|
96
|
+
calc_average_item_size(result, total_items, total_bytes);
|
97
|
+
calc_hit_ratio(result, total_get_hits, total_get_cmds);
|
98
|
+
|
99
|
+
return result;
|
100
|
+
}
|