From: Date: Tue, 18 Sep 2007 13:04:46 +0000 (+0200) Subject: Small cleanups for design of some functions that will work with cluster. X-Git-Tag: 0.2~27 X-Git-Url: https://git.m6w6.name/?a=commitdiff_plain;h=a990db6e910f8b040dc8b232d1aee2c925bfb7f3;p=awesomized%2Flibmemcached Small cleanups for design of some functions that will work with cluster. --- diff --git a/include/memcached.h b/include/memcached.h index 9ab209d3..33abcc81 100644 --- a/include/memcached.h +++ b/include/memcached.h @@ -65,6 +65,7 @@ typedef enum { struct memcached_host_st { char *hostname; unsigned int port; + int fd; memcached_host_st *next; }; @@ -130,9 +131,8 @@ memcached_stat_st **memcached_stat(memcached_st *ptr, memcached_return *error); memcached_return memcached_stat_hostname(memcached_stat_st *stat, char *args, char *hostname, unsigned int port); memcached_return memcached_flush(memcached_st *ptr, time_t expiration); -char *memcached_version(memcached_st *ptr, memcached_return *error); memcached_return memcached_verbosity(memcached_st *ptr, unsigned int verbosity); -memcached_return memcached_quit(memcached_st *ptr); +memcached_return memcached_quit(memcached_st *ptr, char *hostname, unsigned port); char *memcached_get(memcached_st *ptr, char *key, size_t key_length, size_t *value_length, uint16_t *flags, diff --git a/lib/memcached.c b/lib/memcached.c index 944e0f43..fb046827 100644 --- a/lib/memcached.c +++ b/lib/memcached.c @@ -60,17 +60,32 @@ memcached_return memcached_flush(memcached_st *ptr, time_t expiration) return memcached_response(ptr, buffer, MEMCACHED_DEFAULT_COMMAND_SIZE); } -char *memcached_version(memcached_st *ptr, memcached_return *error) -{ - return MEMCACHED_SUCCESS; -} - memcached_return memcached_verbosity(memcached_st *ptr, unsigned int verbosity) { - return MEMCACHED_SUCCESS; + size_t send_length; + memcached_return rc; + char buffer[MEMCACHED_DEFAULT_COMMAND_SIZE]; + + rc= memcached_connect(ptr); + + send_length= snprintf(buffer, MEMCACHED_DEFAULT_COMMAND_SIZE, + "verbosity %u\r\n", verbosity); + + if ((send(ptr->fd, buffer, send_length, 0) == -1)) + { + fprintf(stderr, "failed verbosity\n"); + + return MEMCACHED_WRITE_FAILURE; + } + + return memcached_response(ptr, buffer, MEMCACHED_DEFAULT_COMMAND_SIZE); } -memcached_return memcached_quit(memcached_st *ptr) +/* + When this is implemented you will be able to remove single hosts + from your current pool of hosts. +*/ +memcached_return memcached_quit(memcached_st *ptr, char *hostname, unsigned port) { return MEMCACHED_SUCCESS; }