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,32 @@
|
|
1
|
+
#ifndef __CLIENT_OPTIONS_H__
|
2
|
+
#define __CLIENT_OPTIONS_H__
|
3
|
+
|
4
|
+
typedef struct memcached_help_text_st memcached_help_text_st;
|
5
|
+
|
6
|
+
typedef enum {
|
7
|
+
OPT_SERVERS= 's',
|
8
|
+
OPT_VERSION= 'V',
|
9
|
+
OPT_HELP= 'h',
|
10
|
+
OPT_VERBOSE= 'v',
|
11
|
+
OPT_DEBUG= 'd',
|
12
|
+
OPT_ANALYZE= 'a',
|
13
|
+
OPT_FLAG= 257,
|
14
|
+
OPT_EXPIRE,
|
15
|
+
OPT_SET,
|
16
|
+
OPT_REPLACE,
|
17
|
+
OPT_ADD,
|
18
|
+
OPT_SLAP_EXECUTE_NUMBER,
|
19
|
+
OPT_SLAP_INITIAL_LOAD,
|
20
|
+
OPT_SLAP_TEST,
|
21
|
+
OPT_SLAP_CONCURRENCY,
|
22
|
+
OPT_SLAP_NON_BLOCK,
|
23
|
+
OPT_SLAP_TCP_NODELAY,
|
24
|
+
OPT_FLUSH,
|
25
|
+
OPT_HASH,
|
26
|
+
OPT_BINARY,
|
27
|
+
OPT_UDP,
|
28
|
+
OPT_USERNAME,
|
29
|
+
OPT_PASSWD
|
30
|
+
} memcached_options;
|
31
|
+
|
32
|
+
#endif /* CLIENT_OPTIONS */
|
@@ -0,0 +1,64 @@
|
|
1
|
+
/*
|
2
|
+
Execute a memcached_set() a set of pairs.
|
3
|
+
Return the number of rows set.
|
4
|
+
*/
|
5
|
+
|
6
|
+
#include "libmemcached/common.h"
|
7
|
+
|
8
|
+
#include "execute.h"
|
9
|
+
|
10
|
+
unsigned int execute_set(memcached_st *memc, pairs_st *pairs, unsigned int number_of)
|
11
|
+
{
|
12
|
+
memcached_return rc;
|
13
|
+
unsigned int x;
|
14
|
+
unsigned int pairs_sent;
|
15
|
+
|
16
|
+
for (x= 0, pairs_sent= 0; x < number_of; x++)
|
17
|
+
{
|
18
|
+
rc= memcached_set(memc, pairs[x].key, pairs[x].key_length,
|
19
|
+
pairs[x].value, pairs[x].value_length,
|
20
|
+
0, 0);
|
21
|
+
if (rc != MEMCACHED_SUCCESS && rc != MEMCACHED_BUFFERED)
|
22
|
+
fprintf(stderr, "Failured on insert of %.*s\n",
|
23
|
+
(unsigned int)pairs[x].key_length, pairs[x].key);
|
24
|
+
else
|
25
|
+
pairs_sent++;
|
26
|
+
}
|
27
|
+
|
28
|
+
return pairs_sent;
|
29
|
+
}
|
30
|
+
|
31
|
+
/*
|
32
|
+
Execute a memcached_get() on a set of pairs.
|
33
|
+
Return the number of rows retrieved.
|
34
|
+
*/
|
35
|
+
unsigned int execute_get(memcached_st *memc, pairs_st *pairs, unsigned int number_of)
|
36
|
+
{
|
37
|
+
memcached_return rc;
|
38
|
+
unsigned int x;
|
39
|
+
unsigned int retrieved;
|
40
|
+
|
41
|
+
|
42
|
+
for (retrieved= 0,x= 0; x < number_of; x++)
|
43
|
+
{
|
44
|
+
char *value;
|
45
|
+
size_t value_length;
|
46
|
+
uint32_t flags;
|
47
|
+
unsigned int fetch_key;
|
48
|
+
|
49
|
+
fetch_key= (unsigned int)random() % number_of;
|
50
|
+
|
51
|
+
value= memcached_get(memc, pairs[fetch_key].key, pairs[fetch_key].key_length,
|
52
|
+
&value_length, &flags, &rc);
|
53
|
+
|
54
|
+
if (rc != MEMCACHED_SUCCESS)
|
55
|
+
fprintf(stderr, "Failured on read of %.*s\n",
|
56
|
+
(unsigned int)pairs[fetch_key].key_length, pairs[fetch_key].key);
|
57
|
+
else
|
58
|
+
retrieved++;
|
59
|
+
|
60
|
+
free(value);
|
61
|
+
}
|
62
|
+
|
63
|
+
return retrieved;
|
64
|
+
}
|
@@ -0,0 +1,74 @@
|
|
1
|
+
#include "libmemcached/common.h"
|
2
|
+
|
3
|
+
#include <stdio.h>
|
4
|
+
#include <stdlib.h>
|
5
|
+
#include <stdint.h>
|
6
|
+
#include <string.h>
|
7
|
+
|
8
|
+
#include "generator.h"
|
9
|
+
|
10
|
+
/* Use this for string generation */
|
11
|
+
static const char ALPHANUMERICS[]=
|
12
|
+
"0123456789ABCDEFGHIJKLMNOPQRSTWXYZabcdefghijklmnopqrstuvwxyz";
|
13
|
+
|
14
|
+
#define ALPHANUMERICS_SIZE (sizeof(ALPHANUMERICS)-1)
|
15
|
+
|
16
|
+
static size_t get_alpha_num(void)
|
17
|
+
{
|
18
|
+
return (size_t)random() % ALPHANUMERICS_SIZE;
|
19
|
+
}
|
20
|
+
|
21
|
+
static void get_random_string(char *buffer, size_t size)
|
22
|
+
{
|
23
|
+
char *buffer_ptr= buffer;
|
24
|
+
|
25
|
+
while (--size)
|
26
|
+
*buffer_ptr++= ALPHANUMERICS[get_alpha_num()];
|
27
|
+
*buffer_ptr++= ALPHANUMERICS[get_alpha_num()];
|
28
|
+
}
|
29
|
+
|
30
|
+
void pairs_free(pairs_st *pairs)
|
31
|
+
{
|
32
|
+
uint32_t x;
|
33
|
+
|
34
|
+
if (!pairs)
|
35
|
+
return;
|
36
|
+
|
37
|
+
/* We free until we hit the null pair we stores during creation */
|
38
|
+
for (x= 0; pairs[x].key; x++)
|
39
|
+
{
|
40
|
+
free(pairs[x].key);
|
41
|
+
free(pairs[x].value);
|
42
|
+
}
|
43
|
+
|
44
|
+
free(pairs);
|
45
|
+
}
|
46
|
+
|
47
|
+
pairs_st *pairs_generate(uint64_t number_of, size_t value_length)
|
48
|
+
{
|
49
|
+
unsigned int x;
|
50
|
+
pairs_st *pairs= calloc((size_t)(number_of + 1), sizeof(pairs_st));
|
51
|
+
|
52
|
+
if (!pairs)
|
53
|
+
goto error;
|
54
|
+
|
55
|
+
for (x= 0; x < number_of; x++)
|
56
|
+
{
|
57
|
+
pairs[x].key= (char *)calloc(100, sizeof(char));
|
58
|
+
if (!pairs[x].key)
|
59
|
+
goto error;
|
60
|
+
get_random_string(pairs[x].key, 100);
|
61
|
+
pairs[x].key_length= 100;
|
62
|
+
|
63
|
+
pairs[x].value= (char *)calloc(value_length, sizeof(char));
|
64
|
+
if (!pairs[x].value)
|
65
|
+
goto error;
|
66
|
+
get_random_string(pairs[x].value, value_length);
|
67
|
+
pairs[x].value_length= value_length;
|
68
|
+
}
|
69
|
+
|
70
|
+
return pairs;
|
71
|
+
error:
|
72
|
+
fprintf(stderr, "Memory Allocation failure in pairs_generate.\n");
|
73
|
+
exit(0);
|
74
|
+
}
|
@@ -0,0 +1,20 @@
|
|
1
|
+
/*
|
2
|
+
Code to generate data to be pushed into memcached
|
3
|
+
*/
|
4
|
+
|
5
|
+
#ifndef __GENERATOR_H__
|
6
|
+
#define __GENERATOR_H__
|
7
|
+
|
8
|
+
typedef struct pairs_st pairs_st;
|
9
|
+
|
10
|
+
struct pairs_st {
|
11
|
+
char *key;
|
12
|
+
size_t key_length;
|
13
|
+
char *value;
|
14
|
+
size_t value_length;
|
15
|
+
};
|
16
|
+
|
17
|
+
pairs_st *pairs_generate(uint64_t number_of, size_t value_length);
|
18
|
+
void pairs_free(pairs_st *pairs);
|
19
|
+
|
20
|
+
#endif
|
@@ -0,0 +1,178 @@
|
|
1
|
+
#include "libmemcached/common.h"
|
2
|
+
#include <stdio.h>
|
3
|
+
#include <inttypes.h>
|
4
|
+
#include <string.h>
|
5
|
+
#include <unistd.h>
|
6
|
+
#include <getopt.h>
|
7
|
+
#include <libmemcached/memcached.h>
|
8
|
+
|
9
|
+
#include "utilities.h"
|
10
|
+
|
11
|
+
#define PROGRAM_NAME "memcat"
|
12
|
+
#define PROGRAM_DESCRIPTION "Cat a set of key values to stdout."
|
13
|
+
|
14
|
+
|
15
|
+
/* Prototypes */
|
16
|
+
void options_parse(int argc, char *argv[]);
|
17
|
+
|
18
|
+
static int opt_binary= 0;
|
19
|
+
static int opt_verbose= 0;
|
20
|
+
static int opt_displayflag= 0;
|
21
|
+
static char *opt_servers= NULL;
|
22
|
+
static char *opt_hash= NULL;
|
23
|
+
static char *opt_username;
|
24
|
+
static char *opt_passwd;
|
25
|
+
|
26
|
+
int main(int argc, char *argv[])
|
27
|
+
{
|
28
|
+
memcached_st *memc;
|
29
|
+
char *string;
|
30
|
+
size_t string_length;
|
31
|
+
uint32_t flags;
|
32
|
+
memcached_return rc;
|
33
|
+
memcached_server_st *servers;
|
34
|
+
|
35
|
+
options_parse(argc, argv);
|
36
|
+
|
37
|
+
if (!opt_servers)
|
38
|
+
{
|
39
|
+
char *temp;
|
40
|
+
|
41
|
+
if ((temp= getenv("MEMCACHED_SERVERS")))
|
42
|
+
opt_servers= strdup(temp);
|
43
|
+
else
|
44
|
+
{
|
45
|
+
fprintf(stderr, "No Servers provided\n");
|
46
|
+
exit(1);
|
47
|
+
}
|
48
|
+
}
|
49
|
+
|
50
|
+
memc= memcached_create(NULL);
|
51
|
+
process_hash_option(memc, opt_hash);
|
52
|
+
|
53
|
+
servers= memcached_servers_parse(opt_servers);
|
54
|
+
|
55
|
+
memcached_server_push(memc, servers);
|
56
|
+
memcached_server_list_free(servers);
|
57
|
+
memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL,
|
58
|
+
(uint64_t)opt_binary);
|
59
|
+
|
60
|
+
if (!initialize_sasl(memc, opt_username, opt_passwd))
|
61
|
+
{
|
62
|
+
memcached_free(memc);
|
63
|
+
return 1;
|
64
|
+
}
|
65
|
+
|
66
|
+
while (optind < argc)
|
67
|
+
{
|
68
|
+
string= memcached_get(memc, argv[optind], strlen(argv[optind]),
|
69
|
+
&string_length, &flags, &rc);
|
70
|
+
if (rc == MEMCACHED_SUCCESS)
|
71
|
+
{
|
72
|
+
if (opt_displayflag)
|
73
|
+
{
|
74
|
+
if (opt_verbose)
|
75
|
+
printf("key: %s\nflags: ", argv[optind]);
|
76
|
+
printf("%x\n", flags);
|
77
|
+
}
|
78
|
+
else
|
79
|
+
{
|
80
|
+
if (opt_verbose)
|
81
|
+
printf("key: %s\nflags: %x\nlength: %zu\nvalue: ",
|
82
|
+
argv[optind], flags, string_length);
|
83
|
+
printf("%.*s\n", (int)string_length, string);
|
84
|
+
free(string);
|
85
|
+
}
|
86
|
+
}
|
87
|
+
else if (rc != MEMCACHED_NOTFOUND)
|
88
|
+
{
|
89
|
+
fprintf(stderr, "memcat: %s: memcache error %s",
|
90
|
+
argv[optind], memcached_strerror(memc, rc));
|
91
|
+
if (memc->cached_errno)
|
92
|
+
fprintf(stderr, " system error %s", strerror(memc->cached_errno));
|
93
|
+
fprintf(stderr, "\n");
|
94
|
+
}
|
95
|
+
optind++;
|
96
|
+
}
|
97
|
+
|
98
|
+
memcached_free(memc);
|
99
|
+
|
100
|
+
if (opt_servers)
|
101
|
+
free(opt_servers);
|
102
|
+
if (opt_hash)
|
103
|
+
free(opt_hash);
|
104
|
+
|
105
|
+
shutdown_sasl();
|
106
|
+
|
107
|
+
return 0;
|
108
|
+
}
|
109
|
+
|
110
|
+
|
111
|
+
void options_parse(int argc, char *argv[])
|
112
|
+
{
|
113
|
+
int option_index= 0;
|
114
|
+
int option_rv;
|
115
|
+
|
116
|
+
memcached_programs_help_st help_options[]=
|
117
|
+
{
|
118
|
+
{0},
|
119
|
+
};
|
120
|
+
|
121
|
+
static struct option long_options[]=
|
122
|
+
{
|
123
|
+
{(OPTIONSTRING)"version", no_argument, NULL, OPT_VERSION},
|
124
|
+
{(OPTIONSTRING)"help", no_argument, NULL, OPT_HELP},
|
125
|
+
{(OPTIONSTRING)"verbose", no_argument, &opt_verbose, OPT_VERBOSE},
|
126
|
+
{(OPTIONSTRING)"debug", no_argument, &opt_verbose, OPT_DEBUG},
|
127
|
+
{(OPTIONSTRING)"servers", required_argument, NULL, OPT_SERVERS},
|
128
|
+
{(OPTIONSTRING)"flag", no_argument, &opt_displayflag, OPT_FLAG},
|
129
|
+
{(OPTIONSTRING)"hash", required_argument, NULL, OPT_HASH},
|
130
|
+
{(OPTIONSTRING)"binary", no_argument, NULL, OPT_BINARY},
|
131
|
+
{(OPTIONSTRING)"username", required_argument, NULL, OPT_USERNAME},
|
132
|
+
{(OPTIONSTRING)"password", required_argument, NULL, OPT_PASSWD},
|
133
|
+
{0, 0, 0, 0},
|
134
|
+
};
|
135
|
+
|
136
|
+
while (1)
|
137
|
+
{
|
138
|
+
option_rv= getopt_long(argc, argv, "Vhvds:", long_options, &option_index);
|
139
|
+
if (option_rv == -1) break;
|
140
|
+
switch (option_rv)
|
141
|
+
{
|
142
|
+
case 0:
|
143
|
+
break;
|
144
|
+
case OPT_BINARY:
|
145
|
+
opt_binary = 1;
|
146
|
+
break;
|
147
|
+
case OPT_VERBOSE: /* --verbose or -v */
|
148
|
+
opt_verbose = OPT_VERBOSE;
|
149
|
+
break;
|
150
|
+
case OPT_DEBUG: /* --debug or -d */
|
151
|
+
opt_verbose = OPT_DEBUG;
|
152
|
+
break;
|
153
|
+
case OPT_VERSION: /* --version or -V */
|
154
|
+
version_command(PROGRAM_NAME);
|
155
|
+
break;
|
156
|
+
case OPT_HELP: /* --help or -h */
|
157
|
+
help_command(PROGRAM_NAME, PROGRAM_DESCRIPTION, long_options, help_options);
|
158
|
+
break;
|
159
|
+
case OPT_SERVERS: /* --servers or -s */
|
160
|
+
opt_servers= strdup(optarg);
|
161
|
+
break;
|
162
|
+
case OPT_HASH:
|
163
|
+
opt_hash= strdup(optarg);
|
164
|
+
break;
|
165
|
+
case OPT_USERNAME:
|
166
|
+
opt_username= optarg;
|
167
|
+
break;
|
168
|
+
case OPT_PASSWD:
|
169
|
+
opt_passwd= optarg;
|
170
|
+
break;
|
171
|
+
case '?':
|
172
|
+
/* getopt_long already printed an error message. */
|
173
|
+
exit(1);
|
174
|
+
default:
|
175
|
+
abort();
|
176
|
+
}
|
177
|
+
}
|
178
|
+
}
|
@@ -0,0 +1,251 @@
|
|
1
|
+
#include "libmemcached/common.h"
|
2
|
+
#include <stdio.h>
|
3
|
+
#include <stdlib.h>
|
4
|
+
#include <inttypes.h>
|
5
|
+
#include <unistd.h>
|
6
|
+
#include <getopt.h>
|
7
|
+
#include <sys/types.h>
|
8
|
+
#include <sys/stat.h>
|
9
|
+
#include <sys/types.h>
|
10
|
+
#include <fcntl.h>
|
11
|
+
#include <errno.h>
|
12
|
+
#include <strings.h>
|
13
|
+
#include <string.h>
|
14
|
+
|
15
|
+
#include <libmemcached/memcached.h>
|
16
|
+
|
17
|
+
#include "client_options.h"
|
18
|
+
#include "utilities.h"
|
19
|
+
|
20
|
+
#define PROGRAM_NAME "memcp"
|
21
|
+
#define PROGRAM_DESCRIPTION "Copy a set of files to a memcached cluster."
|
22
|
+
|
23
|
+
/* Prototypes */
|
24
|
+
void options_parse(int argc, char *argv[]);
|
25
|
+
|
26
|
+
static int opt_binary=0;
|
27
|
+
static int opt_verbose= 0;
|
28
|
+
static char *opt_servers= NULL;
|
29
|
+
static char *opt_hash= NULL;
|
30
|
+
static int opt_method= OPT_SET;
|
31
|
+
static uint32_t opt_flags= 0;
|
32
|
+
static time_t opt_expires= 0;
|
33
|
+
static char *opt_username;
|
34
|
+
static char *opt_passwd;
|
35
|
+
|
36
|
+
int main(int argc, char *argv[])
|
37
|
+
{
|
38
|
+
memcached_st *memc;
|
39
|
+
memcached_return rc;
|
40
|
+
memcached_server_st *servers;
|
41
|
+
|
42
|
+
options_parse(argc, argv);
|
43
|
+
|
44
|
+
memc= memcached_create(NULL);
|
45
|
+
process_hash_option(memc, opt_hash);
|
46
|
+
|
47
|
+
if (!opt_servers)
|
48
|
+
{
|
49
|
+
char *temp;
|
50
|
+
|
51
|
+
if ((temp= getenv("MEMCACHED_SERVERS")))
|
52
|
+
opt_servers= strdup(temp);
|
53
|
+
else
|
54
|
+
{
|
55
|
+
fprintf(stderr, "No Servers provided\n");
|
56
|
+
exit(1);
|
57
|
+
}
|
58
|
+
}
|
59
|
+
|
60
|
+
if (opt_servers)
|
61
|
+
servers= memcached_servers_parse(opt_servers);
|
62
|
+
else
|
63
|
+
servers= memcached_servers_parse(argv[--argc]);
|
64
|
+
|
65
|
+
memcached_server_push(memc, servers);
|
66
|
+
memcached_server_list_free(servers);
|
67
|
+
memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL,
|
68
|
+
(uint64_t)opt_binary);
|
69
|
+
if (!initialize_sasl(memc, opt_username, opt_passwd))
|
70
|
+
{
|
71
|
+
memcached_free(memc);
|
72
|
+
return 1;
|
73
|
+
}
|
74
|
+
|
75
|
+
while (optind < argc)
|
76
|
+
{
|
77
|
+
struct stat sbuf;
|
78
|
+
int fd;
|
79
|
+
char *ptr;
|
80
|
+
ssize_t read_length;
|
81
|
+
char *file_buffer_ptr;
|
82
|
+
|
83
|
+
fd= open(argv[optind], O_RDONLY);
|
84
|
+
if (fd < 0)
|
85
|
+
{
|
86
|
+
fprintf(stderr, "memcp: %s: %s\n", argv[optind], strerror(errno));
|
87
|
+
optind++;
|
88
|
+
continue;
|
89
|
+
}
|
90
|
+
|
91
|
+
(void)fstat(fd, &sbuf);
|
92
|
+
|
93
|
+
ptr= rindex(argv[optind], '/');
|
94
|
+
if (ptr)
|
95
|
+
ptr++;
|
96
|
+
else
|
97
|
+
ptr= argv[optind];
|
98
|
+
|
99
|
+
if (opt_verbose)
|
100
|
+
{
|
101
|
+
static const char *opstr[] = { "set", "add", "replace" };
|
102
|
+
printf("op: %s\nsource file: %s\nlength: %zu\n"
|
103
|
+
"key: %s\nflags: %x\nexpires: %llu\n",
|
104
|
+
opstr[opt_method - OPT_SET], argv[optind], (size_t)sbuf.st_size,
|
105
|
+
ptr, opt_flags, (unsigned long long)opt_expires);
|
106
|
+
}
|
107
|
+
|
108
|
+
if ((file_buffer_ptr= (char *)malloc(sizeof(char) * (size_t)sbuf.st_size)) == NULL)
|
109
|
+
{
|
110
|
+
fprintf(stderr, "malloc: %s\n", strerror(errno));
|
111
|
+
exit(1);
|
112
|
+
}
|
113
|
+
|
114
|
+
if ((read_length= read(fd, file_buffer_ptr, (size_t)sbuf.st_size)) == -1)
|
115
|
+
{
|
116
|
+
fprintf(stderr, "read: %s\n", strerror(errno));
|
117
|
+
exit(1);
|
118
|
+
}
|
119
|
+
|
120
|
+
if (read_length != sbuf.st_size)
|
121
|
+
{
|
122
|
+
fprintf(stderr, "Failure reading from file\n");
|
123
|
+
exit(1);
|
124
|
+
}
|
125
|
+
|
126
|
+
if (opt_method == OPT_ADD)
|
127
|
+
rc= memcached_add(memc, ptr, strlen(ptr),
|
128
|
+
file_buffer_ptr, (size_t)sbuf.st_size,
|
129
|
+
opt_expires, opt_flags);
|
130
|
+
else if (opt_method == OPT_REPLACE)
|
131
|
+
rc= memcached_replace(memc, ptr, strlen(ptr),
|
132
|
+
file_buffer_ptr, (size_t)sbuf.st_size,
|
133
|
+
opt_expires, opt_flags);
|
134
|
+
else
|
135
|
+
rc= memcached_set(memc, ptr, strlen(ptr),
|
136
|
+
file_buffer_ptr, (size_t)sbuf.st_size,
|
137
|
+
opt_expires, opt_flags);
|
138
|
+
|
139
|
+
if (rc != MEMCACHED_SUCCESS)
|
140
|
+
{
|
141
|
+
fprintf(stderr, "memcp: %s: memcache error %s",
|
142
|
+
ptr, memcached_strerror(memc, rc));
|
143
|
+
if (memc->cached_errno)
|
144
|
+
fprintf(stderr, " system error %s", strerror(memc->cached_errno));
|
145
|
+
fprintf(stderr, "\n");
|
146
|
+
}
|
147
|
+
|
148
|
+
free(file_buffer_ptr);
|
149
|
+
close(fd);
|
150
|
+
optind++;
|
151
|
+
}
|
152
|
+
|
153
|
+
memcached_free(memc);
|
154
|
+
|
155
|
+
if (opt_servers)
|
156
|
+
free(opt_servers);
|
157
|
+
if (opt_hash)
|
158
|
+
free(opt_hash);
|
159
|
+
shutdown_sasl();
|
160
|
+
|
161
|
+
return 0;
|
162
|
+
}
|
163
|
+
|
164
|
+
void options_parse(int argc, char *argv[])
|
165
|
+
{
|
166
|
+
int option_index= 0;
|
167
|
+
int option_rv;
|
168
|
+
|
169
|
+
memcached_programs_help_st help_options[]=
|
170
|
+
{
|
171
|
+
{0},
|
172
|
+
};
|
173
|
+
|
174
|
+
static struct option long_options[]=
|
175
|
+
{
|
176
|
+
{(OPTIONSTRING)"version", no_argument, NULL, OPT_VERSION},
|
177
|
+
{(OPTIONSTRING)"help", no_argument, NULL, OPT_HELP},
|
178
|
+
{(OPTIONSTRING)"verbose", no_argument, &opt_verbose, OPT_VERBOSE},
|
179
|
+
{(OPTIONSTRING)"debug", no_argument, &opt_verbose, OPT_DEBUG},
|
180
|
+
{(OPTIONSTRING)"servers", required_argument, NULL, OPT_SERVERS},
|
181
|
+
{(OPTIONSTRING)"flag", required_argument, NULL, OPT_FLAG},
|
182
|
+
{(OPTIONSTRING)"expire", required_argument, NULL, OPT_EXPIRE},
|
183
|
+
{(OPTIONSTRING)"set", no_argument, NULL, OPT_SET},
|
184
|
+
{(OPTIONSTRING)"add", no_argument, NULL, OPT_ADD},
|
185
|
+
{(OPTIONSTRING)"replace", no_argument, NULL, OPT_REPLACE},
|
186
|
+
{(OPTIONSTRING)"hash", required_argument, NULL, OPT_HASH},
|
187
|
+
{(OPTIONSTRING)"binary", no_argument, NULL, OPT_BINARY},
|
188
|
+
{(OPTIONSTRING)"username", required_argument, NULL, OPT_USERNAME},
|
189
|
+
{(OPTIONSTRING)"password", required_argument, NULL, OPT_PASSWD},
|
190
|
+
{0, 0, 0, 0},
|
191
|
+
};
|
192
|
+
|
193
|
+
while (1)
|
194
|
+
{
|
195
|
+
option_rv= getopt_long(argc, argv, "Vhvds:", long_options, &option_index);
|
196
|
+
|
197
|
+
if (option_rv == -1) break;
|
198
|
+
|
199
|
+
switch (option_rv)
|
200
|
+
{
|
201
|
+
case 0:
|
202
|
+
break;
|
203
|
+
case OPT_BINARY:
|
204
|
+
opt_binary = 1;
|
205
|
+
break;
|
206
|
+
case OPT_VERBOSE: /* --verbose or -v */
|
207
|
+
opt_verbose = OPT_VERBOSE;
|
208
|
+
break;
|
209
|
+
case OPT_DEBUG: /* --debug or -d */
|
210
|
+
opt_verbose = OPT_DEBUG;
|
211
|
+
break;
|
212
|
+
case OPT_VERSION: /* --version or -V */
|
213
|
+
version_command(PROGRAM_NAME);
|
214
|
+
break;
|
215
|
+
case OPT_HELP: /* --help or -h */
|
216
|
+
help_command(PROGRAM_NAME, PROGRAM_DESCRIPTION, long_options, help_options);
|
217
|
+
break;
|
218
|
+
case OPT_SERVERS: /* --servers or -s */
|
219
|
+
opt_servers= strdup(optarg);
|
220
|
+
break;
|
221
|
+
case OPT_FLAG: /* --flag */
|
222
|
+
opt_flags= (uint32_t)strtol(optarg, (char **)NULL, 16);
|
223
|
+
break;
|
224
|
+
case OPT_EXPIRE: /* --expire */
|
225
|
+
opt_expires= (time_t)strtoll(optarg, (char **)NULL, 10);
|
226
|
+
break;
|
227
|
+
case OPT_SET:
|
228
|
+
opt_method= OPT_SET;
|
229
|
+
break;
|
230
|
+
case OPT_REPLACE:
|
231
|
+
opt_method= OPT_REPLACE;
|
232
|
+
break;
|
233
|
+
case OPT_ADD:
|
234
|
+
opt_method= OPT_ADD;
|
235
|
+
case OPT_HASH:
|
236
|
+
opt_hash= strdup(optarg);
|
237
|
+
break;
|
238
|
+
case OPT_USERNAME:
|
239
|
+
opt_username= optarg;
|
240
|
+
break;
|
241
|
+
case OPT_PASSWD:
|
242
|
+
opt_passwd= optarg;
|
243
|
+
break;
|
244
|
+
case '?':
|
245
|
+
/* getopt_long already printed an error message. */
|
246
|
+
exit(1);
|
247
|
+
default:
|
248
|
+
abort();
|
249
|
+
}
|
250
|
+
}
|
251
|
+
}
|