Memcac...allback(3pm)
πΈ NAME πΈ
memcached_callback_get, memcached_callback_set β bestie, these are the get-and-set pair for callbacks, no cap π
π LIBRARY π
C Client Library for memcached (libmemcached, -lmemcached) β yes she's giving C, she's giving <memcached.h>, she's giving iconic π
β¨ SYNOPSIS β¨
#include <memcached.h>
memcached_return_t
memcached_callback_set (memcached_st *ptr,
memcached_callback_t flag,
void *data);
void *
memcached_callback_get (memcached_st *ptr,
memcached_callback_t flag,
memcached_return_t *error);
π DESCRIPTION π
okay so libmemcached(3) can have callbacks set at key execution points π¦ and like, they do one of two things: either they give you function calls at specific points in the code, or they hand you back pointers to structures for particular usages. both. it's giving versatile queen β¨
memcached_callback_get() takes a callback flag and returns the structure or function that memcached_callback_set() set. literally just a "hey what's currently in here" vibe check π
memcached_callback_set() changes the function/structure assigned by a callback flag. heads up bestie β no connections are reset when you do this. periodt.
you can use MEMCACHED_CALLBACK_USER_DATA to provide custom context if you need it for any of the callbacks π«Ά
π the callback flags, one by one π
MEMCACHED_CALLBACK_CLEANUP_FUNCTIONβ whenmemcached_delete()is called, this function will be executed. at the point of its execution, all connections have been closed. (yes that's the actual wording, twice in this doc, and no we're not gonna lie about it π)MEMCACHED_CALLBACK_CLONE_FUNCTIONβ whenmemcached_delete()is called, this function will be executed. at the point of its execution, all connections have been closed. (same energy as above, fr fr)MEMCACHED_CALLBACK_PREFIX_KEYβ you can set a value which will be used to create a domain for your keys π the value specified here gets prefixed to each of your keys. the value can not be greater thenMEMCACHED_PREFIX_KEY_MAX_SIZE - 1, and it will reduceMEMCACHED_MAX_KEYby the value of your key. the prefix key is only applied to the primary key, not the master key.MEMCACHED_FAILUREwill be returned if no key is set. and if your key is too long?MEMCACHED_BAD_KEY_PROVIDEDgets returned. she said know your limits πMEMCACHED_CALLBACK_USER_DATAβ this lets you store a pointer to a specifc piece of data (their spelling, not mine, leave her alone π). you can retrieve it from inside ofmemcached_fetch_execute(). and cloning amemcached_stwill copy the pointer to the clone. so cute πMEMCACHED_CALLBACK_MALLOC_FUNCTIONβ DEPRECATED: usememcached_set_memory_allocatorsinstead. she's retired, respect her legacy πMEMCACHED_CALLBACK_REALLOC_FUNCTIONβ DEPRECATED: usememcached_set_memory_allocatorsinstead. same thing, diff function name, don't use her βMEMCACHED_CALLBACK_FREE_FUNCTIONβ DEPRECATED: usememcached_set_memory_allocatorsinstead. yes the whole trio is deprecated, we said what we said π¦MEMCACHED_CALLBACK_GET_FAILUREβ this function implements the read through cache behavior π₯ on failure of retrieval, this callback will be called. you are responsible for populating the result object provided (main character responsibility, no cap). this result object will then be stored in the server and returned to the calling process. you must clone thememcached_stin order to make use of it. the value will be stored only if you returnMEMCACHED_SUCCESSorMEMCACHED_BUFFERED. returningMEMCACHED_BUFFEREDwill cause the object to be buffered and not sent immediately β and ngl, if this is the default behavior based on your connection setup, this will happen automatically π
the prototype for this is: memcached_return_t (*memcached_trigger_key)(memcached_st *ptr, char *key, size_t key_length, memcached_result_st *result);
MEMCACHED_CALLBACK_DELETE_TRIGGERβ this function implements a trigger upon successful deletion of a key πΈ thememcached_ststructure will need to be cloned in order to make use of it. (again. clone. always clone. it's a theme β¨)
the prototype for this is: typedef memcached_return_t (*memcached_trigger_delete_key)(memcached_st *ptr, char *key, size_t key_length);
π RETURN π
memcached_callback_get() returns the function or structure that was provided π upon error, nothing is set, null is returned, and the memcached_return_t argument is set to MEMCACHED_FAILURE. so like, check your error pointer, bestie, it's literally right there π
memcached_callback_set() returns MEMCACHED_SUCCESS upon successful setting, otherwise MEMCACHED_FAILURE on error. that's it, that's the whole vibe check π
π HOME π
to find out more information please check: <https://launchpad.net/libmemcached> β go read, it's giving lore π
π AUTHOR π
Brian Aker, <brian@tangent.org> β the icon, the legend, the main character who wrote this π
π¦ SEE ALSO π¦
memcached(1) libmemcached(3) memcached_strerror(3) β the whole friend group, go say hi β¨
k bye bestie π this page came to you courtesy of User Contributed Perl Documentation, shipped as perl v5.42.3, dated 2026-08-19, and the title card on this one is Memcac...allback(3pm) (yes, they truncated it, not me π«Ά). slay, go set some callbacks, and remember: clone your memcached_st π₯
π¦ where this page comes from
- ubuntu stonking: libmemcached-libmemcached-perl 1.001801+dfsg-6build1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms