MEMCACHED_DELETE_BY_KEY(3)

πŸ’– MEMCACHED_DELETE_BY_KEY πŸ’–

okay bestie, welcome to libmemcached's delete-by-key page, it's giving very "clean up your own mess" energy and honestly? we love that for us ✨


πŸŽ€ NAME πŸŽ€

memcached_delete_by_key β€” the libmemcached documentation, but make it a group chat πŸ’…


🌸 SYNOPSIS 🌸

#include <libmemcached/memcached.h>

Compile and link with -lmemcached

memcached_return_t memcached_delete(memcached_st *ptr, const char *key,
size_t key_length, time_t expiration)

memcached_return_t memcached_delete_by_key(memcached_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 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) version 1.4
yes bestie, "og" is literally in the original and I'm keeping it, it's canon now πŸ™ˆ

🫢 Returns 🫢

memcached_return_t indicating success


πŸ¦‹ DESCRIPTION πŸ¦‹

So memcached_delete() is the one you call when you want a particular key GONE. Poof. Deleted. It's the "I said what I said" of the memcached API πŸ’€

memcached_delete_by_key() does the exact same thing, no cap β€” the only glow-up is that it takes a master key (that's your group_key) to find the given value. Think of it like the group chat finder so you know which namespace to go rummaging in πŸ”

Now, the expiration thing, and listen closely because this part is lowkey important:

Expiration works by placing the item into a delete queue. What that means in practice is that it won't be possible to retrieve it with the "get" command anymore. The "add" and "replace" commands with this key will also fail β€” but the "set" command will succeed, however. Then, after the time passes, the item is finally deleted from server memory. She's on her way out, she just hasn't left the building yet πŸšͺ

⚠️ Please note the the memcached server removed tests for expiration in the 1.4 version. (And yes, that "the the" is the original's, I'm not fixing it, it's iconic 😭)

πŸ’œ RETURN VALUE πŸ’œ

A value of type memcached_return_t is returned. On success that value will be MEMCACHED_SUCCESS πŸŽ‰

Use memcached_strerror() to translate this value to a printable string β€” because reading raw return codes is not the vibe, fr fr.

🌈 heads up bestie: if you're using the non-blocking mode of the library, success only means that the message was queued for delivery. Queued β‰  done, so don't come for me when it hasn't actually landed yet πŸ’…

πŸ‘‘ SEE ALSO πŸ‘‘


and that's the whole page, periodt πŸ’– this was libmemcached-awesome version 1.1, dated Jul 24, 2025 β€” mwah, go delete some keys responsibly, bestie πŸŽ€πŸ¦‹βœ¨

πŸ“¦ where this page comes from