1MEMCACHED_CALLBACK_SET(3)    libmemcached-awesome    MEMCACHED_CALLBACK_SET(3)
2
3
4

NAME

6       memcached_callback_set - libmemcached Documentation
7

SYNOPSIS

9       #include <libmemcached/memcached.h>
10              Compile and link with -lmemcached
11
12       memcached_return_t       memcached_callback_set(memcached_st      *ptr,
13       memcached_callback_t flag, const void *data)
14
15              Parameters
16
17ptr -- pointer to initialized memcached_st struct
18
19flag -- memcached_callback_t flag to set
20
21data -- data corresponding to flag
22
23              Returns
24                     memcached_return_t indicating success
25
26       void  *memcached_callback_get(memcached_st  *ptr,  memcached_callback_t
27       flag, memcached_return_t *error)
28
29              Parameters
30
31ptr -- pointer to initialized memcached_st struct
32
33flag -- memcached_callback_t flag to query
34
35error  -- pointer to memcached_return_t indicating suc‐
36                       cess
37
38              Returns
39                     the data previously set
40
41       typedef enum memcached_callback_t memcached_callback_t
42
43       enum memcached_callback_t
44
45              enumerator MEMCACHED_CALLBACK_CLEANUP_FUNCTION
46                     When memcached_free() or memcached_reset is  called  this
47                     function  will be executed. At the point of its execution
48                     all connections are closed.
49
50                     Its signature is:
51
52                     typedef memcached_return_t  (*memcached_cleanup_fn)(const
53                     memcached_st *ptr)
54
55              enumerator MEMCACHED_CALLBACK_CLONE_FUNCTION
56                     When  memcached_clone()  is  called this function will be
57                     executed.
58
59                     Its signature is:
60
61                     typedef    memcached_return_t     (*memcached_clone_fn)(‐
62                     memcached_st *destination, const memcached_st *source)
63
64              enumerator MEMCACHED_CALLBACK_PREFIX_KEY
65                     See MEMCACHED_CALLBACK_NAMESPACE.
66
67              enumerator MEMCACHED_CALLBACK_NAMESPACE
68                     You can set a value which will be used to create a domain
69                     for your keys.  The value specified here will be prefixed
70                     to  each  of your keys. The value can not be greater then
71                     MEMCACHED_MAX_NAMESPACE   -    1    and    will    reduce
72                     MEMCACHED_MAX_KEY by the value of your key.
73
74                     The  prefix  key  is only applied to the primary key, not
75                     the master key.  MEMCACHED_FAILURE will be returned if no
76                     key  is  set.  In  the  case  of a key which is too long,
77                     MEMCACHED_BAD_KEY_PROVIDED will be returned.
78
79                     If you set a value with the value  being  NULL  then  the
80                     prefix key is disabled.
81
82              enumerator MEMCACHED_CALLBACK_USER_DATA
83                     This allows you to store a pointer to a specific piece of
84                     data.   This   can   be   retrieved   from   inside    of
85                     memcached_fetch_execute().  Cloning  a  memcached_st will
86                     copy the pointer to the clone.
87
88              enumerator MEMCACHED_CALLBACK_MALLOC_FUNCTION
89                     Deprecated      since      version       <0.32:       Use
90                     memcached_set_memory_allocators() instead.
91
92
93              enumerator MEMCACHED_CALLBACK_REALLOC_FUNCTION
94                     Deprecated       since       version      <0.32:      Use
95                     memcached_set_memory_allocators() instead.
96
97
98              enumerator MEMCACHED_CALLBACK_FREE_FUNCTION
99                     Deprecated      since      version       <0.32:       Use
100                     memcached_set_memory_allocators() instead.
101
102
103              enumerator MEMCACHED_CALLBACK_GET_FAILURE
104                     This function implements the read through cache behavior.
105                     On failure of retrieval this callback will be called.
106
107                     You are responsible for populating the result object pro‐
108                     vided.  This  result  object  will  then be stored in the
109                     server and returned to the calling process.
110
111                     You must clone the memcached_st in order to make  use  of
112                     it.   The  value  will  be  stored  only  if  you  return
113                     MEMCACHED_SUCCESS   or   MEMCACHED_BUFFERED.    Returning
114                     MEMCACHED_BUFFERED  will  cause the object to be buffered
115                     and not sent immediately (if this is the default behavior
116                     based on your connection setup this will happen automati‐
117                     cally).
118
119                     The prototype for this is:
120
121                     typedef   memcached_return_t   (*memcached_trigger_key)(‐
122                     memcached_st   *ptr,   char   *key,   size_t  key_length,
123                     memcached_result_st *result)
124
125              enumerator MEMCACHED_CALLBACK_DELETE_TRIGGER
126                     This function implements a trigger upon successful  dele‐
127                     tion  of  a key.  The memcached_st structure will need to
128                     be cloned in order to make use of it.
129
130                     The prototype for this is:
131
132                     typedef                                memcached_return_t
133                     (*memcached_trigger_delete_key)(memcached_st  *ptr,  char
134                     *key, size_t key_length)
135

DESCRIPTION

137       libmemcached can have callbacks set key execution points. These  either
138       provide  function  calls  at  points in the code, or return pointers to
139       structures for particular usages.
140
141       memcached_callback_get() takes a callback flag and returns  the  struc‐
142       ture or function set by memcached_callback_set().
143
144       memcached_callback_set()  changes  the function/structure assigned by a
145       callback flag. No connections are reset.
146
147       You can use MEMCACHED_CALLBACK_USER_DATA to provide custom  context  if
148       required for any of the callbacks.
149

RETURN VALUE

151       memcached_callback_get()  returns  the  function  or structure that was
152       provided.  Upon error, nothing  is  set,  NULL  is  returned,  and  the
153       memcached_return_t argument is set to MEMCACHED_FAILURE.
154
155       memcached_callback_set() returns MEMCACHED_SUCCESS upon successful set‐
156       ting, otherwise MEMCACHED_FAILURE on error.
157

SEE ALSO

159       memcached(1) libmemcached(3) memcached_strerror(3)
160
161
162
163
1641.1                              Jul 20, 2023        MEMCACHED_CALLBACK_SET(3)
Impressum