From e2a313f77fd825bdaec9db1649b0549b2d5962c2 Mon Sep 17 00:00:00 2001 From: Date: Wed, 5 Dec 2007 22:13:52 +0900 Subject: [PATCH] Cleanup of spelling error in option. Documentation on storage by key commands. --- ChangeLog | 1 + docs/Makefile.am | 24 ++++++++++++++++ docs/memcached_behavior.pod | 2 +- docs/memcached_set.pod | 55 ++++++++++++++++++++++++++++++++++++ include/memcached.h | 4 +-- lib/memcached.c | 4 +-- lib/memcached_hash.c | 2 +- src/memslap.c | 2 +- support/libmemcached.spec.in | 5 ++++ tests/Makefile.am | 15 ++++++---- tests/t/memslap.test | 2 +- 11 files changed, 103 insertions(+), 13 deletions(-) diff --git a/ChangeLog b/ChangeLog index 3875e7e1..79cb10c7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -10,6 +10,7 @@ * Fixed bug where key could be out of range of characters * Added _by_key() methods to allow partitioning of values to particular servers. + * MEMCACHED_DEFAILT_TIMEOUT is now set to 100 microseconds. 0.11 Mon Nov 26 01:05:52 PST 2007 * Added option to memcache_behavior_set() so that poll() can be timed out. diff --git a/docs/Makefile.am b/docs/Makefile.am index d9795ad5..b19cc769 100644 --- a/docs/Makefile.am +++ b/docs/Makefile.am @@ -33,10 +33,13 @@ man_MANS = libmemcached.3\ memslap.1\ memstat.1\ memcached_add.3\ + memcached_add_by_key.3\ memcached_append.3\ + memcached_append_by_key.3\ memcached_behavior_get.3\ memcached_behavior_set.3\ memcached_cas.3\ + memcached_cas_by_key.3\ memcached_clone.3\ memcached_create.3\ memcached_decrement.3\ @@ -50,7 +53,9 @@ man_MANS = libmemcached.3\ memcached_mget.3\ memcached_mget_by_key.3\ memcached_prepend.3\ + memcached_prepend_by_key.3\ memcached_replace.3\ + memcached_replace_by_key.3\ memcached_server_add.3\ memcached_server_count.3\ memcached_server_list.3\ @@ -60,6 +65,7 @@ man_MANS = libmemcached.3\ memcached_server_push.3\ memcached_servers_parse.3\ memcached_set.3\ + memcached_set_by_key.3\ memcached_stat.3\ memcached_stat_get_keys.3\ memcached_stat_get_value.3\ @@ -86,21 +92,39 @@ memcached_clone.3: memcached_create.pod memcached_set.3: memcached_set.pod pod2man -c "libmemcached" -r "" -s 3 memcached_set.pod > memcached_set.3 +memcached_set_by_key.3: memcached_set.pod + pod2man -c "libmemcached" -r "" -s 3 memcached_set.pod > memcached_set_by_key.3 + memcached_cas.3: memcached_set.pod pod2man -c "libmemcached" -r "" -s 3 memcached_set.pod > memcached_cas.3 +memcached_cas_by_key.3: memcached_set.pod + pod2man -c "libmemcached" -r "" -s 3 memcached_set.pod > memcached_cas_by_key.3 + memcached_replace.3: memcached_set.pod pod2man -c "libmemcached" -r "" -s 3 memcached_set.pod > memcached_replace.3 +memcached_replace_by_key.3: memcached_set.pod + pod2man -c "libmemcached" -r "" -s 3 memcached_set.pod > memcached_replace_by_key.3 + memcached_add.3: memcached_set.pod pod2man -c "libmemcached" -r "" -s 3 memcached_set.pod > memcached_add.3 +memcached_add_by_key.3: memcached_set.pod + pod2man -c "libmemcached" -r "" -s 3 memcached_set.pod > memcached_add_by_key.3 + memcached_prepend.3: memcached_set.pod pod2man -c "libmemcached" -r "" -s 3 memcached_set.pod > memcached_prepend.3 +memcached_prepend_by_key.3: memcached_set.pod + pod2man -c "libmemcached" -r "" -s 3 memcached_set.pod > memcached_prepend_by_key.3 + memcached_append.3: memcached_set.pod pod2man -c "libmemcached" -r "" -s 3 memcached_set.pod > memcached_append.3 +memcached_append_by_key.3: memcached_set.pod + pod2man -c "libmemcached" -r "" -s 3 memcached_set.pod > memcached_append_by_key.3 + memcached_delete.3: memcached_delete.pod pod2man -c "libmemcached" -r "" -s 3 memcached_delete.pod > memcached_delete.3 diff --git a/docs/memcached_behavior.pod b/docs/memcached_behavior.pod index e6547785..b1545534 100755 --- a/docs/memcached_behavior.pod +++ b/docs/memcached_behavior.pod @@ -54,7 +54,7 @@ Makes the default hashing algorithm for keys use MD5. The value can be set to ei =item MEMCACHED_BEHAVIOR_DISTRIBUTION Using this you can enable different means of distributing values to servers. -The default method is MEMCACHED_DISTRIBUTION_MODULO. You can enable +The default method is MEMCACHED_DISTRIBUTION_MODULA. You can enable consistent hashing by setting MEMCACHED_DISTRIBUTION_CONSISTENT. Consistent hashing delivers better distribution and allows servers to be added to the cluster with minimal cache losses. diff --git a/docs/memcached_set.pod b/docs/memcached_set.pod index 0578d17f..8db5b06d 100755 --- a/docs/memcached_set.pod +++ b/docs/memcached_set.pod @@ -52,6 +52,55 @@ C Client Library for memcached (libmemcached, -lmemcached) uint16_t flags, uint64_t cas); + memcached_return + memcached_set_by_key(memcached_st *ptr, + char *master_key, size_t master_key_length, + char *key, size_t key_length, + char *value, size_t value_length, + time_t expiration, + uint16_t flags); + + memcached_return + memcached_add_by_key(memcached_st *ptr, + char *master_key, size_t master_key_length, + char *key, size_t key_length, + char *value, size_t value_length, + time_t expiration, + uint16_t flags); + + memcached_return + memcached_replace_by_key(memcached_st *ptr, + char *master_key, size_t master_key_length, + char *key, size_t key_length, + char *value, size_t value_length, + time_t expiration, + uint16_t flags); + + memcached_return + memcached_prepend_by_key(memcached_st *ptr, + char *master_key, size_t master_key_length, + char *key, size_t key_length, + char *value, size_t value_length, + time_t expiration, + uint16_t flags); + + memcached_return + memcached_append_by_key(memcached_st *ptr, + char *master_key, size_t master_key_length, + char *key, size_t key_length, + char *value, size_t value_length, + time_t expiration, + uint16_t flags); + + memcached_return + memcached_cas_by_key(memcached_st *ptr, + char *master_key, size_t master_key_length, + char *key, size_t key_length, + char *value, size_t value_length, + time_t expiration, + uint16_t flags, + uint64_t cas); + =head1 DESCRIPTION memcached_set(), memcached_add(), and memcached_replace() are all used to @@ -85,6 +134,12 @@ that this note was written cas is still buggy in memached. Turning on support for it in libmemcached(3) is optional. Please see memcached_set() for information on how to do this. +memcached_set_by_key(), memcached_add_by_key(), memcached_replace_by_key(), +memcached_prepend_by_key(), memcached_append_by_key_by_key(), +memcached_cas_by_key() methods all behave in a similar method as the non key +methods. The difference is that they use their master_key parameter to map +objects to particular servers. + If you are looking for performance, memcached_set() with non-blocking IO is the fastest way to store data on the server. diff --git a/include/memcached.h b/include/memcached.h index 2b448081..175c93c3 100644 --- a/include/memcached.h +++ b/include/memcached.h @@ -35,7 +35,7 @@ typedef struct memcached_server_st memcached_server_st; #define MEMCACHED_MAX_HOST_LENGTH 64 #define MEMCACHED_WHEEL_SIZE 1024 #define MEMCACHED_STRIDE 4 -#define MEMCACHED_DEFAILT_TIMEOUT 100 +#define MEMCACHED_DEFAULT_TIMEOUT 100 typedef enum { MEMCACHED_SUCCESS, @@ -72,7 +72,7 @@ typedef enum { } memcached_return; typedef enum { - MEMCACHED_DISTRIBUTION_MODULO, + MEMCACHED_DISTRIBUTION_MODULA, MEMCACHED_DISTRIBUTION_CONSISTENT, } memcached_server_distribution; diff --git a/lib/memcached.c b/lib/memcached.c index 9ee49d66..30099c39 100644 --- a/lib/memcached.c +++ b/lib/memcached.c @@ -22,8 +22,8 @@ memcached_st *memcached_create(memcached_st *ptr) } string_ptr= memcached_string_create(ptr, &ptr->result_buffer, 0); WATCHPOINT_ASSERT(string_ptr); - ptr->poll_timeout= MEMCACHED_DEFAILT_TIMEOUT; - ptr->distribution= MEMCACHED_DISTRIBUTION_MODULO; + ptr->poll_timeout= MEMCACHED_DEFAULT_TIMEOUT; + ptr->distribution= MEMCACHED_DISTRIBUTION_MODULA; return ptr; } diff --git a/lib/memcached_hash.c b/lib/memcached_hash.c index 3ea5df97..87c59d51 100644 --- a/lib/memcached_hash.c +++ b/lib/memcached_hash.c @@ -86,7 +86,7 @@ unsigned int memcached_generate_hash(memcached_st *ptr, char *key, size_t key_le WATCHPOINT_ASSERT(hash); - if (ptr->distribution == MEMCACHED_DISTRIBUTION_MODULO) + if (ptr->distribution == MEMCACHED_DISTRIBUTION_MODULA) { return hash % ptr->number_of_hosts; } diff --git a/src/memslap.c b/src/memslap.c index e25d0c03..486ff7ce 100644 --- a/src/memslap.c +++ b/src/memslap.c @@ -123,7 +123,7 @@ int main(int argc, char *argv[]) void scheduler(memcached_server_st *servers, conclusions_st *conclusion) { unsigned int x; - unsigned int actual_loaded; + unsigned int actual_loaded= 0; /* Fix warning */ memcached_st *memc; struct timeval start_time, end_time; diff --git a/support/libmemcached.spec.in b/support/libmemcached.spec.in index 580241fc..d94eac38 100644 --- a/support/libmemcached.spec.in +++ b/support/libmemcached.spec.in @@ -67,10 +67,13 @@ memerror - Creates human readable messages from libmemecached error codes. %{_mandir}/man3/libmemcached.3.gz %{_mandir}/man3/libmemcached_examples.3.gz %{_mandir}/man3/memcached_add.3.gz +%{_mandir}/man3/memcached_add_by_key.3.gz %{_mandir}/man3/memcached_append.3.gz +%{_mandir}/man3/memcached_append_by_key.3.gz %{_mandir}/man3/memcached_behavior_get.3.gz %{_mandir}/man3/memcached_behavior_set.3.gz %{_mandir}/man3/memcached_cas.3.gz +%{_mandir}/man3/memcached_cas_by_key.3.gz %{_mandir}/man3/memcached_clone.3.gz %{_mandir}/man3/memcached_create.3.gz %{_mandir}/man3/memcached_decrement.3.gz @@ -84,6 +87,7 @@ memerror - Creates human readable messages from libmemecached error codes. %{_mandir}/man3/memcached_mget.3.gz %{_mandir}/man3/memcached_mget_by_key.3.gz %{_mandir}/man3/memcached_prepend.3.gz +%{_mandir}/man3/memcached_prepend_by_key.3.gz %{_mandir}/man3/memcached_quit.3.gz %{_mandir}/man3/memcached_replace.3.gz %{_mandir}/man3/memcached_server_add.3.gz @@ -95,6 +99,7 @@ memerror - Creates human readable messages from libmemecached error codes. %{_mandir}/man3/memcached_server_push.3.gz %{_mandir}/man3/memcached_servers_parse.3.gz %{_mandir}/man3/memcached_set.3.gz +%{_mandir}/man3/memcached_set_by_key.3.gz %{_mandir}/man3/memcached_stat.3.gz %{_mandir}/man3/memcached_stat_get_keys.3.gz %{_mandir}/man3/memcached_stat_get_value.3.gz diff --git a/tests/Makefile.am b/tests/Makefile.am index dc84803e..cb4269b3 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -32,9 +32,16 @@ record: record-extended: ./testapp extended > output2.res -test: testapp +test: testapp library_test + echo "Tests completed" + +library_test: ./testapp > output.cmp diff output.res output.cmp + +clients: + memcached -d -P /tmp/Xumemc.pid -p 12555 + export MEMCACHED_SERVERS="localhost:12555" sh t/memcat.test > r/memcat.cmp diff r/memcat.res r/memcat.cmp sh t/memcp.test > r/memcp.cmp @@ -45,10 +52,8 @@ test: testapp diff r/memslap.res r/memslap.cmp sh t/memstat.test > r/memstat.cmp diff r/memstat.res r/memstat.cmp - -test-extended: testapp - ./testapp extended > output.cmp - diff output2.res output.cmp + cat /tmp/Xumemc.pid | xargs kill + rm /tmp/Xumemc.pid valgrind: libtool --mode=execute valgrind --leak-check=yes --show-reachable=yes testapp diff --git a/tests/t/memslap.test b/tests/t/memslap.test index cc4ea80f..c3c71ff9 100644 --- a/tests/t/memslap.test +++ b/tests/t/memslap.test @@ -2,4 +2,4 @@ MEMSLAP="../src/memslap" $MEMSLAP --help -$MEMSLAP --servers=localhost --initial-load=5000 --verbose --flush --concurrency=500 --execute-number=500 > /dev/null +$MEMSLAP --initial-load=5000 --verbose --flush --concurrency=500 --execute-number=500 > /dev/null -- 2.30.2