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