---
name: "memcached_touch_by_key"
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_touch_by_key"
---

# memcached\_touch\_by\_key(3)

libmemcached Documentation

## NAME

memcached\_touch\_by\_key - libmemcached Documentation

## SYNOPSIS

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

  Compile and link with -lmemcached

- **memcached\_return\_t \<#\_CPPv418memcached\_return\_t\> memcached\_touch(memcached\_st \<#\_CPPv412memcached\_st\> \*ptr, const char \*key, size\_t key\_length, time\_t expiration)**

  - **Parameters**

    - •

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

    - •

      **key** -- the key to touch

    - •

      **key\_length** -- the length of **key** without any terminating zero

    - •

      **expiration** -- new expiration as a unix timestamp or as relative expiration time in seconds

  - **Returns**

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

- **memcached\_return\_t \<#\_CPPv418memcached\_return\_t\> memcached\_touch\_by\_key(memcached\_st \<#\_CPPv412memcached\_st\> \*ptr, const char \*group\_key, size\_t group\_key\_length, const char \*key, size\_t key\_length, time\_t expiration)**

  - **Parameters**

    - •

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

    - •

      **group\_key** -- the **key** namespace

    - •

      **group\_key\_length** -- the length of **group\_key** without any terminating zero

    - •

      **key** -- the key to touch

    - •

      **key\_length** -- the length of **key** without any terminating zero

    - •

      **expiration** -- new expiration as a unix timestamp or as relative expiration time in seconds

  - **Returns**

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

## DESCRIPTION

**memcached\_touch()** is used to update the expiration time on an existing key. **memcached\_touch\_by\_key()** works the same, but it takes a master key to find the given value.

## RETURN VALUE

A value of type **memcached\_return\_t** \<#\_CPPv418memcached\_return\_t\> is returned. On success that value will be **MEMCACHED\_SUCCESS** \<#\_CPPv4N18memcached\_return\_t17MEMCACHED\_SUCCESSE\>. Use **memcached\_strerror()** \<#\_CPPv418memcached\_strerrorP12memcached\_st18memcached\_return\_t\> to translate this value to a printable string.

## 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\>**
