MEMCACHED_GENERATE_HASH_VALUE(3)

πŸ’– MEMCACHED_GENERATE_HASH_VALUE β€” a.k.a. memcached_generate_hash_value πŸ’–

okay bestie so you're in the libmemcached-awesome manual, section 3, and today's main character is memcached_generate_hash_value ✨ buckle up, it's giving hash-core πŸ¦‹


✨ NAME ✨

memcached_generate_hash_value β€” generating hash values directly, bestie. like, hashing a key value yourself, on purpose, with your whole chest πŸ’…


🌸 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 β€” the receipts πŸ“‹

  • key β€” the key you wanna generate a hash of, no cap
  • key_length β€” the length of the key, and note it's without any terminating zero 🫢
  • hash_algorithm β€” a memcached_hash_t, aka which algorithm you're picking, choose wisely ✨

Returns β€” a 32 bit hash value πŸŽ€

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

Parameters β€” round two, keep up πŸ’…

  • ptr β€” pointer to an initialized memcached_st struct, initialized being the key word bestie πŸ‘€
  • key β€” the key to generate a hash of (yes again, iconic)
  • key_length β€” the length of the key, again without any terminating zero

Returns β€” a 32 bit hash value 🌈

typedef enum memcached_hash_t memcached_hash_t
enum memcached_hash_t

The whole roster, in order, no skips πŸŽ€:

  • 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 πŸ¦‹

so memcached_generate_hash_value() lets you hash a key using one of the hash functions defined in the library πŸ’– It's literally there for the convenience of higher-level language bindings β€” it is not necessary for normal memcache operations, so don't come for me if you never touch it, it's fine, live your life πŸ’…

🚨 heads up bestie: support for MEMCACHED_HASH_HSIEH is a compile time option that is disabled by default. To enable tests for this hashing algorithm, configure and build libmemcached with the Hsieh hash enabled. it's giving "opt-in only" energy ✨

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 β€” like, it's not inventing anything new, it's matching the vibe of your struct 🫢

and a lil history moment for you: 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. slay, they got their own house 🏠✨


πŸ‘‘ RETURN VALUE πŸ‘‘

A 32-bit integer which is the result of hashing the given key. and here's the fine print, don't skip it πŸ™ˆ β€” for 64-bit hash algorithms, only the least-significant 32 bits are returned. so if you were expecting all 64, you're getting the bottom half, periodt πŸ’…


πŸ”₯ SEE ALSO πŸ”₯


and that's the whole page bestie, you ate that πŸ“ this was libmemcached-awesome, version 1.1, dated Jul 24, 2025 β€” go forth and hash responsibly, mwah πŸ’œπŸ§š

πŸ“¦ where this page comes from