MEMCACHED_SET_USER_DATA(3)

✨ MEMCACHED_SET_USER_DATA ✨

okay bestie, welcome to the libmemcached-awesome corner of the manual, section 3, and today's main character is memcached_set_user_data πŸ’… this one's from the MEMCACHED_SET_USER_DATA(3) page and it's literally just about stashing your own little pointer inside a memcached_st. cute, right? πŸŽ€


🌸 NAME 🌸

memcached_set_user_data β€” libmemcached Documentation


πŸ¦‹ SYNOPSIS πŸ¦‹

#include <libmemcached/memcached.h>

Compile and link with -lmemcached

void *memcached_get_user_data(memcached_st *ptr)

Parameters

  • ptr β€” pointer to initialized memcached_st struct

Returns

  • opaque pointer to the user supplied data
void *memcached_set_user_data(memcached_st *ptr, void *data)

Parameters

  • ptr β€” pointer to initialized memcached_st struct
  • data β€” opaque pointer to user supplied data

Returns

  • opaque pointer to the previously set data

πŸ’– DESCRIPTION πŸ’–

so here's the tea β˜• libmemcached lets you store a pointer to your own user specific data right inside the memcached_st structure. like, a little pocket in there that's all yours 🫢

memcached_set_user_data() is the one that sets the user specific data in the memcached_st structure.

memcached_get_user_data() is the one that gets the user specific data back out of the memcached_st structure.

set it, get it, slay it. periodt. πŸ’…


πŸ‘‘ RETURN VALUE πŸ‘‘

memcached_set_user_data() returns the previous value of the user specific data.

memcached_get_user_data() returns the current value of the user specific data.

ngl the "previous value" thing is the iconic part β€” you're not getting nothing back, you're getting what was there before you swapped it in. iykyk πŸ”₯

🌈 SEE ALSO 🌈


version 1.1 🌸 dated Jul 24, 2025 β€” that's the whole page bestie, go set some user data and be the main character of your own memcached_st πŸ’–βœ¨πŸŽ€πŸ¦‹

πŸ“¦ where this page comes from