Extended consistent hash logic to handle splice (should distribute keys much
[awesomized/libmemcached] / lib / memcached_hash.c
index 9cc846a80e8ab568b047d4b7e8c9896a9b4f9da9..95d7f8622d23975e61015d38ff9e49c8450e9a11 100644 (file)
@@ -85,18 +85,18 @@ unsigned int memcached_generate_hash(memcached_st *ptr, char *key, size_t key_le
   }
 
   WATCHPOINT_ASSERT(hash);
-  if (ptr->flags & MEM_USE_KETAMA)
+
+  if (ptr->distribution == MEMCACHED_DISTRIBUTION_MODULUS)
   {
-    WATCHPOINT_ASSERT(0);
-    return 0;
+    return hash % ptr->number_of_hosts;
   }
   else
   {
     unsigned int server_key;
 
-    server_key= hash % ptr->number_of_hosts;
+    server_key= hash % MEMCACHED_WHEEL_SIZE;
 
-    return server_key;
+    return ptr->wheel[server_key];
   }
 }