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