---
name: "memcached_result_flags"
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_result_flags"
---

# memcached\_result\_flags(3)

Working with result sets

## NAME

memcached\_result\_flags - Working with result sets

## SYNOPSIS

- **#include \<libmemcached/memcached.h\>**

  Compile and link with -lmemcachedutil -lmemcached

- **typedef struct memcached\_result\_st memcached\_result\_st**

  - **memcached\_result\_st \*memcached\_result\_create(memcached\_st \<#\_CPPv412memcached\_st\> \*ptr, memcached\_result\_st \*result)**

  - **Parameters**

    - •

      **ptr** -- pointer to initialized **memcached\_st** \<#\_CPPv412memcached\_st\> struct

    - •

      **result** -- pointer to an **memcached\_result\_st** instance to initialize or nullptr to allocate a new instance

  - **Returns**

    pointer to initialized **memcached\_result\_st** instance

- **void memcached\_result\_free(memcached\_result\_st \*result)**

  - **Parameters**

    **result** -- pointer to initialized **memcached\_result\_st** struct

- **const char \*memcached\_result\_key\_value(memcached\_result\_st \*result)**

  - **Parameters**

    **result** -- pointer to initialized **memcached\_result\_st** struct

  - **Returns**

    the key value associated with the current result object

- **size\_t memcached\_result\_key\_length(const memcached\_result\_st \*result)**

  - **Parameters**

    **result** -- pointer to initialized **memcached\_result\_st** struct

  - **Returns**

    the key length associated with the current result object

- **const char \*memcached\_result\_value(memcached\_result\_st \*result)**

  - **Parameters**

    **result** -- pointer to initialized **memcached\_result\_st** struct

  - **Returns**

    the result value associated with the current result object

- **char \*memcached\_result\_take\_value(memcached\_result\_st \*result)**

  - **Parameters**

    **result** -- pointer to initialized **memcached\_result\_st** struct

  - **Returns**

    the result value associated with the current result object

- **size\_t memcached\_result\_length(const memcached\_result\_st \*result)**

  - **Parameters**

    **result** -- pointer to initialized **memcached\_result\_st** struct

  - **Returns**

    the result length associated with the current result object

- **uint32\_t memcached\_result\_flags(const memcached\_result\_st \*result)**

  - **Parameters**

    **result** -- pointer to initialized **memcached\_result\_st** struct

  - **Returns**

    the flags associated with the current result object

- **uint64\_t memcached\_result\_cas(const memcached\_result\_st \*result)**

  - **Parameters**

    **result** -- pointer to initialized **memcached\_result\_st** struct

  - **Returns**

    the cas associated with the current result object

- **memcached\_return\_t \<#\_CPPv418memcached\_return\_t\> memcached\_result\_set\_value(memcached\_result\_st \*result, const char \*value, size\_t length)**

  - **Parameters**

    - •

      **result** -- pointer to initialized **memcached\_result\_st** struct

    - •

      **value** -- byte array to set the value of the current result object to

    - •

      **length** -- the length of **value** wothout any terminating zero

  - **Returns**

    **memcached\_return\_t** \<#\_CPPv418memcached\_return\_t\> indicating success

- **void memcached\_result\_set\_flags(memcached\_result\_st \*result, uint32\_t flags)**

  - **Parameters**

    - •

      **result** -- pointer to initialized **memcached\_result\_st** struct

    - •

      **flags** -- a new value for the flags field

- **void memcached\_result\_set\_expiration(memcached\_result\_st \*result, time\_t expiration)**

  - **Parameters**

    - •

      **result** -- pointer to initialized **memcached\_result\_st** struct

    - •

      **expiration** -- a new value for the expiration field

## DESCRIPTION

**libmemcached** can optionally return a **memcached\_result\_st** which acts as a result object. The result objects have added benefits over the character pointer return values, in that they are forward compatible with new return items that future memcached servers may implement (the best current example of this is the CAS return item). The structures can also be reused, which will save on calls to **[malloc(3)](/malloc/3.md) \<https://linux.die.net/man/3/malloc\>**. It is suggested that you use result objects over char \* return functions.

The structure of **memcached\_result\_st** has been encapsulated, you should not write code directly accessing members of the structure.

**memcached\_result\_create()** will either allocate memory for a **memcached\_result\_st** or will initialize a structure passed to it.

**memcached\_result\_free()** will deallocate any memory attached to the structure. If the structure was also allocated, it will deallocate it.

**memcached\_result\_key\_value()** returns the key value associated with the current result object.

**memcached\_result\_key\_length()** returns the key length associated with the current result object.

**memcached\_result\_value()** returns the result value associated with the current result object.

**memcached\_result\_take\_value()** returns and hands over the result value associated with the current result object. You must call **[free(3)](/free/3.md) \<https://linux.die.net/man/3/free\>** to release this value, unless you have made use of a custom allocator. Use of a custom allocator requires that you create your own custom free() to release it.

**memcached\_result\_length()** returns the result length associated with the current result object.

**memcached\_result\_flags()** returns the flags associated with the current result object.

**memcached\_result\_cas()** returns the cas associated with the current result object. This value will only be available if the server tests it.

**memcached\_result\_set\_value()** takes a byte array and a size and sets the result to this value. This function is used for trigger responses.

**memcached\_result\_set\_flags()** takes a result structure and stores a new value for the flags field.

**memcached\_result\_set\_expiration()** takes a result structure and stores a new value for the expiration field (this is only used by read through triggers).

## RETURN VALUE

Varies, see particular functions. All structures must have **memcached\_result\_free()** called on them for cleanup purposes. Failure to do this will result in leaked memory.

## 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\>** **[memcached\_memory\_allocators(3)](/memcached_memory_allocators/3.md) \<https://linux.die.net/man/3/memcached\_memory\_allocators\>**
