docs: sanitize
[awesomized/libmemcached] / docs / source / libmemcached / memcached_cas.rst
1 Working with data on the server in an atomic fashion
2 ====================================================
3
4 SYNOPSIS
5 --------
6
7 #include <libmemcached/memcached.h>
8 Compile and link with -lmemcached
9
10 .. function:: memcached_return_t memcached_cas(memcached_st *ptr, const char *key, size_t key_length, const char *value, size_t value_length, time_t expiration, uint32_t flags, uint64_t cas)
11
12 .. function:: memcached_return_t memcached_cas_by_key(memcached_st *ptr, const char *group_key, size_t group_key_length, const char *key, size_t key_length, const char *value, size_t value_length, time_t expiration, uint32_t flags, uint64_t cas)
13
14
15 DESCRIPTION
16 -----------
17
18 `memcached_cas` overwrites data in the server as long as the ``cas`` value is
19 still the same in the server. You can get the ``cas`` value of a result by
20 calling `memcached_result_cas` on a `memcached_result_st` structure.
21
22 At the point that this note was written cas is still buggy in memcached. Turning
23 on tests for it in `libmemcached` is optional. Please see `memcached_set` for
24 information on how to do this.
25
26 `memcached_cas_by_key` method behaves in a similar way as the non key methods.
27 The difference is that it uses the ``group_key`` parameter to map objects to
28 particular servers.
29
30 `memcached_cas` is tested with the `MEMCACHED_BEHAVIOR_USE_UDP` behavior
31 enabled. However, when using these operations with this behavior on, there are
32 limits to the size of the payload being sent to the server. The reason for
33 these limits is that the Memcached Server does not allow multi-datagram requests
34 and the current server implementation sets a datagram size to 1400 bytes. Due to
35 protocol overhead, the actual limit of the user supplied data is less than 1400
36 bytes and depends on the protocol in use as, well as the operation being
37 executed. When running with the binary protocol,
38 `MEMCACHED_BEHAVIOR_BINARY_PROTOCOL`, the size of the key,value, flags and
39 expiry combined may not exceed 1368 bytes. When running with the ASCII protocol,
40 the exact limit fluctuates depending on which function is being executed and
41 whether the function is a cas operation or not. For non-cas ASCII set
42 operations, there are at least 1335 bytes available to split among the key,
43 key_prefix, and value; for cas ASCII operations there are at least 1318 bytes
44 available to split among the key, key_prefix and value. If the total size of the
45 command, including overhead, exceeds 1400 bytes, a `MEMCACHED_WRITE_FAILURE`
46 will be returned.
47
48 RETURN VALUE
49 ------------
50
51 All methods return a value of type `memcached_return_t`.
52 On success the value will be `MEMCACHED_SUCCESS`.
53 Use `memcached_strerror` to translate this value to a printable
54 string.
55
56 SEE ALSO
57 --------
58
59 .. only:: man
60
61 :manpage:`memcached(1)`
62 :manpage:`libmemcached(3)`
63 :manpage:`memcached_strerror(3)`
64 :manpage:`memcached_set(3)`
65 :manpage:`memcached_append(3)`
66 :manpage:`memcached_add(3)`
67 :manpage:`memcached_prepend(3)`
68 :manpage:`memcached_replace(3)`
69
70 .. only:: html
71
72 * :manpage:`memcached(1)`
73 * :doc:`../libmemcached`
74 * :doc:`memcached_set`
75 * :doc:`memcached_append`
76 * :doc:`memcached_strerror`