change license header library name to libmemcached-awesome
[awesomized/libmemcached] / src / libmemcached / hash.cc
index 33766b5fd50420bc0941a41e3d5de5065b8edba2..5e8eb2b6eafbb43627eed828ca47282fb98595d6 100644 (file)
@@ -1,6 +1,6 @@
 /*
     +--------------------------------------------------------------------+
-    | libmemcached - C/C++ Client Library for memcached                  |
+    | libmemcached-awesome - C/C++ Client Library for memcached          |
     +--------------------------------------------------------------------+
     | Redistribution and use in source and binary forms, with or without |
     | modification, are permitted under the terms of the BSD license.    |
@@ -9,15 +9,14 @@
     | the terms online at: https://opensource.org/licenses/BSD-3-Clause  |
     +--------------------------------------------------------------------+
     | Copyright (c) 2006-2014 Brian Aker   https://datadifferential.com/ |
-    | Copyright (c) 2020 Michael Wallner   <mike@php.net>                |
+    | Copyright (c) 2020-2021 Michael Wallner        https://awesome.co/ |
     +--------------------------------------------------------------------+
 */
 
 #include "libmemcached/common.h"
-
-#include <sys/time.h>
-
 #include "libmemcached/virtual_bucket.h"
+#include "p9y/gettimeofday.hpp"
+#include "p9y/random.hpp"
 
 uint32_t memcached_generate_hash_value(const char *key, size_t key_length,
                                        memcached_hash_t hash_algorithm) {
@@ -52,8 +51,10 @@ static uint32_t dispatch_host(const Memcached *ptr, uint32_t hash) {
       right = begin;
     return right->index;
   }
-  case MEMCACHED_DISTRIBUTION_MODULA: return hash % memcached_server_count(ptr);
-  case MEMCACHED_DISTRIBUTION_RANDOM: return (uint32_t) random() % memcached_server_count(ptr);
+  case MEMCACHED_DISTRIBUTION_MODULA:
+    return hash % memcached_server_count(ptr);
+  case MEMCACHED_DISTRIBUTION_RANDOM:
+    return (uint32_t) random() % memcached_server_count(ptr);
   case MEMCACHED_DISTRIBUTION_VIRTUAL_BUCKET: {
     return memcached_virtual_bucket_get(ptr, hash);
   }