IPV6 support, plus cleanup around consistent hashing.
[awesomized/libmemcached] / include / memcached.h
index 122b6f9790b321ca3d30dc9fc23b94ef547d0977..971b4ab43ee0d2b840eb475aba175969b5fae01f 100644 (file)
@@ -32,6 +32,9 @@ typedef struct memcached_server_st memcached_server_st;
 #define HUGE_STRING_LEN 8196
 #define MEMCACHED_MAX_KEY 251 /* We add one to have it null terminated */
 #define MEMCACHED_MAX_BUFFER HUGE_STRING_LEN
+#define MEMCACHED_MAX_HOST_LENGTH 64
+#define MEMCACHED_WHEEL_SIZE 1024
+#define MEMCACHED_STRIDE 4
 
 typedef enum {
   MEMCACHED_SUCCESS,
@@ -66,6 +69,11 @@ typedef enum {
   MEMCACHED_MAXIMUM_RETURN, /* Always add new error code before */
 } memcached_return;
 
+typedef enum {
+  MEMCACHED_DISTRIBUTION_MODULO,
+  MEMCACHED_DISTRIBUTION_CONSISTENT,
+} memcached_server_distribution;
+
 typedef enum {
   MEMCACHED_BEHAVIOR_NO_BLOCK,
   MEMCACHED_BEHAVIOR_TCP_NODELAY,
@@ -87,6 +95,7 @@ typedef enum {
   MEMCACHED_HASH_FNV1_32,
   MEMCACHED_HASH_FNV1A_32,
   MEMCACHED_HASH_KETAMA,
+  MEMCACHED_HASH_HSIEH,
 } memcached_hash;
 
 typedef enum {
@@ -103,7 +112,7 @@ typedef enum {
 } memcached_allocated;
 
 struct memcached_server_st {
-  char *hostname;
+  char hostname[MEMCACHED_MAX_HOST_LENGTH];
   unsigned int port;
   int fd;
   unsigned int stack_responses;
@@ -115,7 +124,7 @@ struct memcached_server_st {
   size_t read_buffer_length;
   char *read_ptr;
   memcached_allocated sockaddr_inited;
-  struct sockaddr_in servAddr;
+  struct addrinfo *address_info;
   memcached_connection type;
   uint8_t major_version;
   uint8_t minor_version;
@@ -124,32 +133,30 @@ struct memcached_server_st {
 };
 
 struct memcached_stat_st {
-  unsigned int pid;
-  unsigned int uptime;
-  unsigned int threads;
-  time_t time;
+  uint32_t pid;
+  uint32_t uptime;
+  uint32_t threads;
+  uint32_t time;
+  uint32_t pointer_size;
+  uint32_t rusage_user_seconds;
+  uint32_t rusage_user_microseconds;
+  uint32_t rusage_system_seconds;
+  uint32_t rusage_system_microseconds;
+  uint32_t curr_items;
+  uint32_t total_items;
+  uint32_t limit_maxbytes;
+  uint32_t curr_connections;
+  uint32_t total_connections;
+  uint32_t connection_structures;
+  uint64_t bytes;
+  uint64_t cmd_get;
+  uint64_t cmd_set;
+  uint64_t get_hits;
+  uint64_t get_misses;
+  uint64_t evictions;
+  uint64_t bytes_read;
+  uint64_t bytes_written;
   char version[MEMCACHED_VERSION_STRING];
-  unsigned int pointer_size;
-  unsigned int rusage_user;
-  unsigned int rusage_system;
-  unsigned int rusage_user_seconds;
-  unsigned int rusage_user_microseconds;
-  unsigned int rusage_system_seconds;
-  unsigned int rusage_system_microseconds;
-  unsigned int curr_items;
-  unsigned int total_items;
-  unsigned long long bytes;
-  unsigned int curr_connections;
-  unsigned int total_connections;
-  unsigned int connection_structures;
-  unsigned long long cmd_get;
-  unsigned long long cmd_set;
-  unsigned long long get_hits;
-  unsigned long long get_misses;
-  unsigned long long evictions;
-  unsigned long long bytes_read;
-  unsigned long long bytes_written;
-  unsigned int limit_maxbytes;
 };
 
 struct memcached_string_st {
@@ -184,6 +191,8 @@ struct memcached_st {
   int32_t poll_timeout;
   memcached_string_st result_buffer;
   memcached_hash hash;
+  memcached_server_distribution distribution;
+  unsigned int wheel[MEMCACHED_WHEEL_SIZE];
   memcached_return warning; /* Future Use */
 };