MEMCACHED_S...T_AUTH_DATA(3)

πŸ’– MEMCACHED_S...T_AUTH_DATA πŸ’–

okay bestie, gather round, because we're talking about libmemcached-awesome and its SASL auth data situation, and honestly? it's giving "powerful but you gotta read the fine print" πŸŽ€


✨ NAME ✨

memcached_sasl_set_auth_data β€” the libmemcached documentation, but make it make sense πŸ¦‹


🌸 SYNOPSIS 🌸

#include <libmemcached/memcached.h>

and like, obviously:

Compile and link with -lmemcached

here come the functions, bestie:

void memcached_set_sasl_callbacks(memcached_st *ptr, const sasl_callback_t *callbacks)

Parameters

  • ptr β€” pointer to initialized memcached_st struct
  • callbacks β€” pointer to sasl_callbacks_t holding the callbacks to use
const sasl_callback_t *memcached_get_sasl_callbacks(memcached_st *ptr)

Parameters

  • ptr β€” pointer to initialized memcached_st struct

Returns

  • pointer to sasl_callbacks_t holding the callbacks currently used
memcached_return_t memcached_set_sasl_auth_data(memcached_st *ptr, const char *username, const char *password)

Parameters

  • ptr β€” pointer to initialized memcached_st struct
  • username β€” (it's literally just... the username, no notes πŸ“)
  • password β€” (and the password, iconic)

Returns

  • memcached_return_t indicating success
memcached_return_t memcached_destroy_sasl_auth_data(memcached_st *ptr)

Parameters

  • ptr β€” pointer to initialized memcached_st struct

Returns

  • memcached_return_t indicating success

πŸ’… DESCRIPTION πŸ’…

libmemcached lets you plug in your very own callbacks function, the kind that libsasl uses to do SASL authentication. main character energy, honestly πŸ’–

⚠️ please note: SASL requires the memcached binary protocol, and you have to specify the callbacks before you connect to the server. no cap, do it in that order or it's not gonna work 😭

memcached_set_sasl_auth_data() is the lil helper function that defines the basic functionality for you, but heads up bestie β€” it will store the username and password in memory. πŸ™ˆ

If you choose to use this method, you have to call memcached_destroy_sasl_auth_data() before calling memcached_free() to avoid a memory leak. do not skip this step, the leak is real and it's messy 🫢

And also β€” and this is the part where people get it wrong β€” you should NOT call memcached_destroy_sasl_auth_data() if you specify your own callback function with memcached_set_sasl_callbacks(). like, don't do it. just don't. βœ‹


🌈 RETURN VALUE 🌈

  • memcached_get_sasl_callbacks() returns the callbacks currently used by this memcached handle. πŸ‘‘
  • memcached_set_sasl_auth_data() returns MEMCACHED_SUCCESS upon success. slay ✨

πŸ¦‹ SEE ALSO πŸ¦‹


and that's the whole vibe, bestie β€” this was libmemcached-awesome version 1.1, dated Jul 24, 2025, brought to you by the MEMCACHED_S...T_AUTH_DATA(3) girlies. go forth, authenticate responsibly, and don't leak that memory πŸ’–βœ¨πŸŽ€πŸ¦‹πŸŒΈπŸ’…

πŸ“¦ where this page comes from