---
name: "memcached_generate_hash_value"
section: "3"
platform: "linux"
package: "libmemcached-awesome"
version: "1.1.4-4"
release: "Arch Linux 2026-11-01"
platforms: ["linux"]
url: "https://new.carta.tech/memcached_generate_hash_value"
---

# memcached\_generate\_hash\_value(3)

Generating hash values directly Hash a key value

## NAME

memcached\_generate\_hash\_value - Generating hash values directly

Hash a key value

## 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 \<#\_CPPv412memcached\_st\> \*ptr, const char \*key, size\_t key\_length)**

  - **Parameters**

    - •

      **ptr** -- pointer to an initialized **memcached\_st** \<#\_CPPv412memcached\_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

**memcached\_generate\_hash\_value()** allows you to hash a key using one of the hash functions defined in the library. This method is provided for the convenience of higher-level language bindings and is not necessary for normal memcache operations.

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.

**memcached\_generate\_hash()** takes a **memcached\_st** \<#\_CPPv412memcached\_st\> structure and produces the hash value that would have been generated based on the defaults of **memcached\_st** \<#\_CPPv412memcached\_st\>.

As of version 0.36 all hash methods have been placed into the library [libhashkit(3)](/libhashkit/3.md) which is linked with [libmemcached(3)](/libmemcached/3.md). For more information please see its documentation.

## 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.

## SEE ALSO

**[memcached(1)](/memcached/1.md) \<https://linux.die.net/man/1/memcached\>** **[libmemcached(3)](/libmemcached/3.md) \<https://linux.die.net/man/3/libmemcached\>** **[memcached\_strerror(3)](/memcached_strerror/3.md) \<https://linux.die.net/man/3/memcached\_strerror\>**
