1 Generating hash values directly
2 ===============================
9 #include <libmemcached/memcached.h>
10 Compile and link with -lmemcachedutil -lmemcached
12 .. function:: uint32_t memcached_generate_hash_value (const char *key, size_t key_length, memcached_hash_t hash_algorithm)
14 :param key: the key to generate a hash of
15 :param key_length: the length of the `key` without any terminating zero
16 :param hash_algorithm: `memcached_hash_t`, the algorithm to use
17 :returns: a 32 bit hash value
19 .. function:: uint32_t memcached_generate_hash (memcached_st *ptr, const char *key, size_t key_length)
21 :param ptr: pointer to an initialized `memcached_st` struct
22 :param key: the key to generate a hash of
23 :param key_length: the length of the `key` without any terminating zero
24 :returns: a 32 bit hash value
26 .. c:type:: enum memcached_hash_t memcached_hash_t
28 .. enum:: memcached_hash_t
30 .. enumerator:: MEMCACHED_HASH_DEFAULT
32 .. enumerator:: MEMCACHED_HASH_MD5
34 .. enumerator:: MEMCACHED_HASH_CRC
36 .. enumerator:: MEMCACHED_HASH_FNV1_64
38 .. enumerator:: MEMCACHED_HASH_FNV1A_64
40 .. enumerator:: MEMCACHED_HASH_FNV1_32
42 .. enumerator:: MEMCACHED_HASH_FNV1A_32
44 .. enumerator:: MEMCACHED_HASH_HSIEH
46 .. enumerator:: MEMCACHED_HASH_MURMUR
48 .. enumerator:: MEMCACHED_HASH_JENKINS
50 .. enumerator:: MEMCACHED_HASH_MURMUR3
52 .. enumerator:: MEMCACHED_HASH_CUSTOM
59 :func:`memcached_generate_hash_value` allows you to hash a key using one of
60 the hash functions defined in the library. This method is provided for
61 the convenience of higher-level language bindings and is not necessary
62 for normal memcache operations.
64 Support for `MEMCACHED_HASH_HSIEH` is a compile time option that is
65 disabled by default. To enable tests for this hashing algorithm,
66 configure and build libmemcached with the Hsieh hash enabled.
68 :func:`memcached_generate_hash` takes a :type:`memcached_st` structure
69 and produces the hash value that would have been generated based on the
70 defaults of :type:`memcached_st`.
72 As of version 0.36 all hash methods have been placed into the library
73 libhashkit(3) which is linked with libmemcached(3). For more information please see its documentation.
78 A 32-bit integer which is the result of hashing the given key.
79 For 64-bit hash algorithms, only the least-significant 32 bits are
87 :manpage:`memcached(1)` :manpage:`libmemcached(3)` :manpage:`memcached_strerror(3)`