MEMCACHED_SASL(3)

πŸ’– MEMCACHED_SASL πŸ’–

okay bestie, so this is a page from libmemcached-awesome (the libmemcached manual, section 3), and it's all about SASL auth, like, plugging in your own callbacks so libsasl can do its lil authentication moment. it's giving "security but make it customizable" and we're obsessed. πŸŽ€


✨ NAME ✨

memcached_sasl β€” the libmemcached Documentation, but make it cute πŸ¦‹


🌸 SYNOPSIS 🌸

first things first, you gotta pull in the header and link the library:

#include <libmemcached/memcached.h>

Compile and link with -lmemcached

then boom, four functions, here's the whole roster:

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 β€”
  • password β€”

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 πŸ’…

so libmemcached lets you plug in your own callbacks function that libsasl uses to do SASL authentication. it's fully your show, your rules, your callback. main character energy fr. πŸ‘‘

⚠️ okay important, listen up: SASL requires the memcached binary protocol, and you have to specify the callbacks before you connect to the server. no cap. don't come crying to me later if you didn't. 😭

memcached_set_sasl_auth_data() is that helper function that defines the basic functionality for you β€” super convenient, lowkey iconic β€” but heads up, 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. like, that's the assignment, do not skip it. 🫢

and bestie, you should NOT call memcached_destroy_sasl_auth_data() if you specify your own callback function with memcached_set_sasl_callbacks(). that's the rules, periodt. βœ‹


🌈 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 page, bestie! this was libmemcached-awesome version 1.1, dated Jul 24, 2025 β€” go forth and authenticate responsibly πŸ’–βœ¨πŸŽ€πŸ¦‹

πŸ“¦ where this page comes from