/*
+--------------------------------------------------------------------+
- | 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. |
| 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) {
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);
}