---
name: "memcached_delete"
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_delete"
---

# memcached\_delete(3)

libmemcached Documentation

## NAME

memcached\_delete - libmemcached Documentation

## SYNOPSIS

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

  Compile and link with -lmemcached

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

  - **memcached\_return\_t \<#\_CPPv418memcached\_return\_t\> memcached\_delete\_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** -- key namespace

    - •

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

    - •

      **key** -- the key to delete

    - •

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

    - •

      **expiration** -- obsolete since **[memcached(1)](/memcached/1.md) \<https://linux.die.net/man/1/memcached\>** version 1.4

  - **Returns**

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

## DESCRIPTION

**memcached\_delete()** is used to delete a particular key. **memcached\_delete\_by\_key()** works the same, but it takes a master key to find the given value.

Expiration works by placing the item into a delete queue, which means that it won't be possible to retrieve it by the "get" command. The "add" and "replace" commands with this key will also fail (the "set" command will succeed, however). After the time passes, the item is finally deleted from server memory.

Please note the the memcached server removed tests for expiration in the 1.4 version.

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

If you are using the non-blocking mode of the library, success only means that the message was queued for delivery.

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