Merge pull request #140 from hussainnaqvee/patch-1
[awesomized/libmemcached] / source / memcached_result_st.rst
1 ========================
2 Working with result sets
3 ========================
4
5 --------
6 SYNOPSIS
7 --------
8
9 #include <libmemcached/memcached_pool.h>
10
11 .. c:type:: memcached_result_st
12
13 .. c:function:: memcached_result_st * memcached_result_create (memcached_st *ptr, memcached_result_st *result)
14
15 .. c:function:: void memcached_result_free (memcached_result_st *result)
16
17 .. c:function:: const char * memcached_result_key_value (memcached_result_st *result)
18
19 .. c:function:: size_t memcached_result_key_length (const memcached_result_st *result)
20
21 .. c:function:: const char *memcached_result_value (memcached_result_st *ptr)
22
23 .. c:function:: char *memcached_result_take_value (memcached_result_st *ptr)
24
25 .. c:function:: size_t memcached_result_length (const memcached_result_st *ptr)
26
27 .. c:function:: uint32_t memcached_result_flags (const memcached_result_st *result)
28
29 .. c:function:: uint64_t memcached_result_cas (const memcached_result_st *result)
30
31 .. c:function:: memcached_return_t memcached_result_set_value (memcached_result_st *ptr, const char *value, size_t length)
32
33 .. c:function:: void memcached_result_set_flags (memcached_result_st *ptr, uint32_t flags)
34
35 .. c:function:: void memcached_result_set_expiration (memcached_result_st *ptr, time_t)
36
37 Compile and link with -lmemcachedutil -lmemcached
38
39
40
41 -----------
42 DESCRIPTION
43 -----------
44
45
46 libmemcached(3) can optionally return a :c:type:`memcached_result_st` which
47 acts as a result object. The result objects have added benefits over the
48 character pointer returns, in that they are forward compatible with new
49 return items that future memcached servers may implement (the best current
50 example of this is the CAS return item). The structures can also be reused,
51 which will save on calls to malloc(3). It is suggested that you use result
52 objects over char \* return functions.
53
54 The structure of :c:type:`memcached_result_st` has been encapsulated, you should
55 not write code to directly access members of the structure.
56
57 :c:func:`memcached_result_create` will either allocate memory for a
58 :c:type:`memcached_result_st` or will initialize a structure passed to it.
59
60 :c:func:`memcached_result_free` will deallocate any memory attached to the
61 structure. If the structure was also allocated, it will deallocate it.
62
63 :c:func:`memcached_result_key_value` returns the key value associated with the
64 current result object.
65
66 :c:func:`memcached_result_key_length` returns the key length associated with
67 the current result object.
68
69 :c:func:`memcached_result_value` returns the result value associated with the
70 current result object.
71
72 :c:func:`memcached_result_take_value` returns and hands over the result value
73 associated with the current result object. You must call free() to release this
74 value, unless you have made use of a custom allocator. Use of a custom
75 allocator requires that you create your own custom free() to release it.
76
77 :c:func:`memcached_result_length` returns the result length associated with
78 the current result object.
79
80 :c:func:`memcached_result_flags` returns the flags associated with the
81 current result object.
82
83 :c:func:`memcached_result_cas` returns the cas associated with the
84 current result object. This value will only be available if the server
85 tests it.
86
87 :c:func:`memcached_result_set_value` takes a byte array and a size and sets
88 the result to this value. This function is used for trigger responses.
89
90 :c:func:`memcached_result_set_flags` takes a result structure and stores a new
91 value for the flags field.
92
93 :c:func:`memcached_result_set_expiration` takes a result structure and stores
94 a new value for the expiration field (this is only used by read through
95 triggers).
96
97 You may wish to avoid using memcached_result_create(3) with a
98 stack based allocation. The most common issues related to ABI safety involve
99 heap allocated structures.
100
101
102 ------
103 RETURN
104 ------
105
106
107 Varies, see particular functions. All structures must have
108 :c:func:`memcached_result_free` called on them for cleanup purposes. Failure
109 to do this will result in leaked memory.
110
111
112 ----
113 HOME
114 ----
115
116
117 To find out more information please check:
118 `http://libmemcached.org/ <http://libmemcached.org/>`_
119
120
121 --------
122 SEE ALSO
123 --------
124
125 :manpage:`memcached(1)` :manpage:`libmemcached(3)` :manpage:`memcached_strerror(3)`