8
.. index:: object: memcached_st
15
#include <libmemcached/memcached.h>
17
.. c:type:: memcached_callback_t
19
.. c:function:: memcached_return_t memcached_callback_set (memcached_st *ptr, memcached_callback_t flag, const void *data)
21
.. c:function:: void * memcached_callback_get (memcached_st *ptr, memcached_callback_t flag, memcached_return_t *error)
23
Compile and link with -lmemcached
31
libmemcached(3) can have callbacks set key execution points. These either
32
provide function calls at points in the code, or return pointers to
33
structures for particular usages.
35
:c:func:`memcached_callback_get` takes a callback flag and returns the
36
structure or function set by :c:func:`memcached_callback_set`.
38
:c:func:`memcached_callback_set` changes the function/structure assigned by a
39
callback flag. No connections are reset.
41
You can use :c:type:`MEMCACHED_CALLBACK_USER_DATA` to provide custom context
42
if required for any of the callbacks.
45
.. c:type:: MEMCACHED_CALLBACK_CLEANUP_FUNCTION
47
When :c:func:`memcached_delete` is called this function will be excuted. At
48
the point of its execution all connections are closed.
52
.. c:type:: MEMCACHED_CALLBACK_CLONE_FUNCTION
54
When :c:func:`memcached_delete` is called this function will be excuted.
55
At the point of its execution all connections are closed.
57
.. c:type:: MEMCACHED_CALLBACK_PREFIX_KEY
59
See :c:type:`MEMCACHED_CALLBACK_NAMESPACE`
61
.. c:type:: MEMCACHED_CALLBACK_NAMESPACE
63
You can set a value which will be used to create a domain for your keys.
64
The value specified here will be prefixed to each of your keys. The value can
65
not be greater then :c:macro:`MEMCACHED_PREFIX_KEY_MAX_SIZE` - 1 and will
66
reduce :c:macro:`MEMCACHED_MAX_KEY` by the value of your key.
68
The prefix key is only applied to the primary key, not the master key.
69
:c:type:`MEMCACHED_FAILURE` will be returned if no key is set. In the case of
70
a key which is too long, :c:type:`MEMCACHED_BAD_KEY_PROVIDED` will be returned.
72
If you set a value with the value being NULL then the prefix key is disabled.
74
.. c:type:: MEMCACHED_CALLBACK_USER_DATA
76
This allows you to store a pointer to a specifc piece of data. This can be
77
retrieved from inside of :c:func:`memcached_fetch_execute`. Cloning a
78
:c:type:`memcached_st` will copy the pointer to the clone.
80
.. c:type:: MEMCACHED_CALLBACK_MALLOC_FUNCTION
82
Use :c:type:`memcached_set_memory_allocators` instead.
84
.. c:type:: MEMCACHED_CALLBACK_REALLOC_FUNCTION
86
Use :c:type:`memcached_set_memory_allocators` instead.
88
.. c:type:: MEMCACHED_CALLBACK_FREE_FUNCTION
90
Use :c:type:`memcached_set_memory_allocators` instead.
92
.. c:type:: MEMCACHED_CALLBACK_GET_FAILURE
94
This function implements the read through cache behavior. On failure of retrieval this callback will be called.
96
You are responsible for populating the result object provided. This result object will then be stored in the server and returned to the calling process.
98
You must clone the :c:type:`memcached_st` in order to
99
make use of it. The value will be stored only if you return
100
:c:type:`MEMCACHED_SUCCESS` or :c:type:`MEMCACHED_BUFFERED`. Returning
101
:c:type:`MEMCACHED_BUFFERED` will cause the object to be buffered and not sent
102
immediatly (if this is the default behavior based on your connection setup
103
this will happen automatically).
105
The prototype for this is:
107
.. c:function:: memcached_return_t (\*memcached_trigger_key)(memcached_st \*ptr, char \*key, size_t key_length, memcached_result_st \*result);
111
.. c:type:: MEMCACHED_CALLBACK_DELETE_TRIGGER
113
This function implements a trigger upon successful deletion of a key. The memcached_st structure will need to be cloned in order to make use of it.
115
The prototype for this is:
117
.. c:function:: typedef memcached_return_t (\*memcached_trigger_delete_key)(memcached_st \*ptr, char \*key, size_t key_length);
127
:c:func:`memcached_callback_get` return the function or structure that was
128
provided. Upon error, nothing is set, null is returned, and the
129
:c:type:`memcached_return_t` argument is set to :c:type:`MEMCACHED_FAILURE`.
131
:c:func:`memcached_callback_set` returns :c:type:`MEMCACHED_SUCCESS` upon
132
successful setting, otherwise :c:type:`MEMCACHED_FAILURE` on error.
140
To find out more information please check:
141
`http://libmemcached.org/ <http://libmemcached.org/>`_
149
Brian Aker, <brian@tangent.org>
157
:manpage:`memcached(1)` :manpage:`libmemcached(3)` :manpage:`memcached_strerror(3)`