From: Date: Fri, 7 Dec 2007 03:22:25 +0000 (+0900) Subject: Adding delete_by_key function to complete partitioning by key feature. X-Git-Tag: 0.13~44 X-Git-Url: https://git.m6w6.name/?a=commitdiff_plain;h=2dce97932fbd574db1179add7bc3facc0318186c;p=awesomized%2Flibmemcached Adding delete_by_key function to complete partitioning by key feature. --- diff --git a/docs/Makefile.am b/docs/Makefile.am index b19cc769..2b0c4321 100644 --- a/docs/Makefile.am +++ b/docs/Makefile.am @@ -44,6 +44,7 @@ man_MANS = libmemcached.3\ memcached_create.3\ memcached_decrement.3\ memcached_delete.3\ + memcached_delete_by_key.3\ memcached_fetch.3\ memcached_fetch_result.3\ memcached_free.3\ @@ -128,6 +129,9 @@ memcached_append_by_key.3: memcached_set.pod memcached_delete.3: memcached_delete.pod pod2man -c "libmemcached" -r "" -s 3 memcached_delete.pod > memcached_delete.3 +memcached_delete_by_key.3: memcached_delete.pod + pod2man -c "libmemcached" -r "" -s 3 memcached_delete.pod > memcached_delete_by_key.3 + memcached_increment.3: pod2man -c "libmemcached" -r "" -s 3 memcached_auto.pod > memcached_increment.3 diff --git a/docs/memcached_delete.pod b/docs/memcached_delete.pod index 82e25f21..18fec84b 100755 --- a/docs/memcached_delete.pod +++ b/docs/memcached_delete.pod @@ -15,10 +15,18 @@ C Client Library for memcached (libmemcached, -lmemcached) char *key, size_t key_length, time_t expiration); + memcached_return + memcached_delete_by_key (memcached_st *ptr, + char *master_key, size_t master_key_length, + char *key, size_t key_length, + time_t expiration); + =head1 DESCRIPTION memcached_delete() is used to delete a particular key. An expiration value can be applied so that the key is deleted after that many seconds. +memcached_delete_by_key() works the same, but it takes a master key to +find the given value. =head1 RETURN diff --git a/include/memcached.h b/include/memcached.h index ba8b650c..bc74c18d 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_DEFAULT_TIMEOUT 800 +#define MEMCACHED_DEFAULT_TIMEOUT 2000 typedef enum { MEMCACHED_SUCCESS, @@ -353,6 +353,10 @@ memcached_return memcached_cas_by_key(memcached_st *ptr, time_t expiration, uint16_t flags, uint64_t cas); +memcached_return memcached_delete_by_key(memcached_st *ptr, + char *master_key, size_t master_key_length, + char *key, size_t key_length, + time_t expiration); /* Result Struct */ void memcached_result_free(memcached_result_st *result); diff --git a/lib/memcached_delete.c b/lib/memcached_delete.c index 0c36aaeb..7c026cbc 100644 --- a/lib/memcached_delete.c +++ b/lib/memcached_delete.c @@ -2,6 +2,15 @@ memcached_return memcached_delete(memcached_st *ptr, char *key, size_t key_length, time_t expiration) +{ + return memcached_delete_by_key(ptr, key, key_length, + key, key_length, expiration); +} + +memcached_return memcached_delete_by_key(memcached_st *ptr, + char *master_key, size_t master_key_length, + char *key, size_t key_length, + time_t expiration) { char to_write; size_t send_length; @@ -17,7 +26,7 @@ memcached_return memcached_delete(memcached_st *ptr, char *key, size_t key_lengt if (ptr->hosts == NULL || ptr->number_of_hosts == 0) return MEMCACHED_NO_SERVERS; - server_key= memcached_generate_hash(ptr, key, key_length); + server_key= memcached_generate_hash(ptr, master_key, master_key_length); if (expiration) send_length= snprintf(buffer, MEMCACHED_DEFAULT_COMMAND_SIZE, diff --git a/support/libmemcached.spec.in b/support/libmemcached.spec.in index d94eac38..6fb66b62 100644 --- a/support/libmemcached.spec.in +++ b/support/libmemcached.spec.in @@ -78,6 +78,7 @@ memerror - Creates human readable messages from libmemecached error codes. %{_mandir}/man3/memcached_create.3.gz %{_mandir}/man3/memcached_decrement.3.gz %{_mandir}/man3/memcached_delete.3.gz +%{_mandir}/man3/memcached_delete_by_key.3.gz %{_mandir}/man3/memcached_fetch.3.gz %{_mandir}/man3/memcached_fetch_result.3.gz %{_mandir}/man3/memcached_free.3.gz