MEMCACHED_GENERATE_HASH(3)

โœจ NAME โœจ

memcached_generate_hash โ€” generating hash values directly ๐Ÿ’…

Hash a key value, bestie. That's the whole vibe.


๐ŸŽ€ SYNOPSIS ๐ŸŽ€

#include <libmemcached/memcached.h>
       Compile and link with -lmemcachedutil -lmemcached
uint32_t memcached_generate_hash_value(const char *key, size_t
key_length, memcached_hash_t hash_algorithm)

Parameters ๐Ÿซถ

  • key โ€” the key to generate a hash of
  • key_length โ€” the length of the key without any terminating zero
  • hash_algorithm โ€” memcached_hash_t, the algorithm to use

Returns โ€” a 32 bit hash value โœจ

uint32_t memcached_generate_hash(memcached_st *ptr, const char *key,
size_t key_length)

Parameters ๐Ÿซถ

  • ptr โ€” pointer to an initialized memcached_st struct
  • key โ€” the key to generate a hash of
  • key_length โ€” the length of the key without any terminating zero

Returns โ€” a 32 bit hash value โœจ

typedef enum memcached_hash_t memcached_hash_t
enum memcached_hash_t
  • enumerator MEMCACHED_HASH_DEFAULT
  • enumerator MEMCACHED_HASH_MD5
  • enumerator MEMCACHED_HASH_CRC
  • enumerator MEMCACHED_HASH_FNV1_64
  • enumerator MEMCACHED_HASH_FNV1A_64
  • enumerator MEMCACHED_HASH_FNV1_32
  • enumerator MEMCACHED_HASH_FNV1A_32
  • enumerator MEMCACHED_HASH_HSIEH
  • enumerator MEMCACHED_HASH_MURMUR
  • enumerator MEMCACHED_HASH_JENKINS
  • enumerator MEMCACHED_HASH_MURMUR3
  • enumerator MEMCACHED_HASH_CUSTOM

๐Ÿ’– DESCRIPTION ๐Ÿ’–

Okay so memcached_generate_hash_value() lets you hash a key using one of the hash functions defined in the library. It's literally giving convenience for higher-level language bindings โ€” it is not necessary for normal memcache operations. So if you're just doing your regular memcache thing, you don't need this. It's a special-occasion slay. ๐Ÿ‘‘

Support for MEMCACHED_HASH_HSIEH is a compile time option that is disabled by default, bestie. To enable tests for this hashing algorithm, configure and build libmemcached with the Hsieh hash enabled. No cap. ๐Ÿงš

memcached_generate_hash() takes a memcached_st structure and produces the hash value that would have been generated based on the defaults of memcached_st. It's likeโ€ฆ peeking at the future your struct already decided on. ๐Ÿ”ฎ

As of version 0.36 all hash methods have been placed into the library libhashkit(3) which is linked with libmemcached(3). For more information please see its documentation. Go read it, it's iconic. ๐Ÿ“š


๐ŸŒˆ RETURN VALUE ๐ŸŒˆ

A 32-bit integer which is the result of hashing the given key. For 64-bit hash algorithms, only the least-significant 32 bits are returned. So yeah, you're getting the bottom half of the number โ€” that's just how it is, periodt. ๐Ÿ’…


๐Ÿฆ‹ SEE ALSO ๐Ÿฆ‹


k bye bestie ๐Ÿ’– this was libmemcached-awesome version 1.1, dated Jul 24, 2025. go hash something cute ๐ŸŽ€โœจ๐Ÿซถ

๐Ÿ“ฆ where this page comes from