9d8e00b311e18392fd14772d8cdf894cf8ecca16
[awesomized/libmemcached] / docs / source / libmemcached / memcached_generate_hash_value.rst
1 ===============================
2 Generating hash values directly
3 ===============================
4
5 .. index:: object: memcached_st
6
7 Hash a key value
8
9 SYNOPSIS
10 --------
11
12 #include <libmemcached/memcached.h>
13
14 .. type:: memcached_hash_t
15
16 .. function:: uint32_t memcached_generate_hash_value (const char *key, size_t key_length, memcached_hash_t hash_algorithm)
17
18 .. function:: uint32_t memcached_generate_hash (memcached_st *ptr, const char *key, size_t key_length)
19
20 .. type:: MEMCACHED_HASH_DEFAULT
21
22 .. type:: MEMCACHED_HASH_MD5
23
24 .. type:: MEMCACHED_HASH_CRC
25
26 .. type:: MEMCACHED_HASH_FNV1_64
27
28 .. type:: MEMCACHED_HASH_FNV1A_64
29
30 .. type:: MEMCACHED_HASH_FNV1_32
31
32 .. type:: MEMCACHED_HASH_FNV1A_32
33
34 .. type:: MEMCACHED_HASH_JENKINS
35
36 .. type:: MEMCACHED_HASH_MURMUR
37
38 .. type:: MEMCACHED_HASH_HSIEH
39
40 .. type:: MEMCACHED_HASH_MURMUR3
41
42 Compile and link with -lmemcachedutil -lmemcached
43
44 -----------
45 DESCRIPTION
46 -----------
47
48 :func:`memcached_generate_hash_value` allows you to hash a key using one of
49 the hash functions defined in the library. This method is provided for
50 the convenience of higher-level language bindings and is not necessary
51 for normal memcache operations.
52
53 The allowed hash algorithm constants are listed in the manpage for
54 :func:`memcached_behavior_set`.
55
56 :func:`memcached_generate_hash` takes a :type:`memcached_st` structure
57 and produces the hash value that would have been generated based on the
58 defaults of :type:`memcached_st`.
59
60 As of version 0.36 all hash methods have been placed into the library
61 libhashkit(3) which is linked with libmemcached(3). For more information please see its documentation.
62
63 ------
64 RETURN
65 ------
66
67 A 32-bit integer which is the result of hashing the given key.
68 For 64-bit hash algorithms, only the least-significant 32 bits are
69 returned.
70
71 --------
72 SEE ALSO
73 --------
74
75 .. only:: man
76
77 :manpage:`memcached(1)` :manpage:`libmemcached(3)` :manpage:`memcached_strerror(3)`