6d1acc882ffb54db7d9fae5932769901081ed88f
[awesomized/libmemcached] / docs / source / libmemcached / memcached_auto.rst
1 Incrementing and Decrementing Values
2 ====================================
3
4 SYNOPSIS
5 --------
6
7 #include <libmemcached/memcached.h>
8 Compile and link with -lmemcached
9
10 .. function:: memcached_return_t memcached_increment (memcached_st *ptr, const char *key, size_t key_length, uint32_t offset, uint64_t *value)
11
12 .. function:: memcached_return_t memcached_decrement (memcached_st *ptr, const char *key, size_t key_length, uint32_t offset, uint64_t *value)
13
14 .. function:: memcached_return_t memcached_increment_with_initial (memcached_st *ptr, const char *key, size_t key_length, uint64_t offset, uint64_t initial, time_t expiration, uint64_t *value)
15
16 .. function:: memcached_return_t memcached_decrement_with_initial (memcached_st *ptr, const char *key, size_t key_length, uint64_t offset, uint64_t initial, time_t expiration, uint64_t *value)
17
18 .. function:: memcached_return_t memcached_increment_by_key (memcached_st *ptr, const char *group_key, size_t group_key_length, const char *key, size_t key_length, uint32_t offset, uint64_t *value)
19
20 .. function:: memcached_return_t memcached_decrement_by_key (memcached_st *ptr, const char *group_key, size_t group_key_length, const char *key, size_t key_length, uint32_t offset, uint64_t *value)
21
22 .. function:: memcached_return_t memcached_increment_with_initial_by_key (memcached_st *ptr, const char *group_key, size_t group_key_length, const char *key, size_t key_length, uint64_t offset, uint64_t initial, time_t expiration, uint64_t *value)
23
24 .. function:: memcached_return_t memcached_decrement_with_initial_by_key (memcached_st *ptr, const char *group_key, size_t group_key_length, const char *key, size_t key_length, uint64_t offset, uint64_t initial, time_t expiration, uint64_t *value)
25
26
27 DESCRIPTION
28 -----------
29
30 :manpage:`memcached(1)` servers have the ability to increment and decrement keys
31 (overflow and underflow are not detected). This gives you the ability to use
32 memcached to generate shared sequences of values.
33
34 `memcached_increment` takes a ``key`` and ``key_length`` and increments the
35 value by the ``offset`` passed to it. The value is then returned via the
36 uint32_t ``value`` pointer you pass to it.
37
38 `memcached_decrement` takes a ``key`` and ``key_length`` and decrements the
39 value by the ``offset`` passed to it. The value is then returned via the
40 uint32_t ``value`` pointer you pass to it.
41
42 `memcached_increment_with_initial` takes a ``key`` and ``key_length`` and
43 increments the value by the ``offset`` passed to it. If the object specified by
44 ``key`` does not exist, one of two things may happen: If the ``expiration``
45 value is :c:macro:`MEMCACHED_EXPIRATION_NOT_ADD`, the operation will fail. For
46 all other ``expiration`` values, the operation will succeed by seeding the value
47 for that key with a initial value to expire with the provided expiration time.
48 The ``flags`` will be set to zero. The value is then returned via the uint32_t
49 ``value`` pointer you pass to it. ``memcached_increment_with_initial`` is only
50 available when using the binary protocol.
51
52 `memcached_decrement_with_initial` takes a ``key`` and ``key_length`` and
53 decrements the value by the ``offset`` passed to it. If the object specified by
54 ``key`` does not exist, one of two things may happen: If the ``expiration``
55 value is :c:macro:`MEMCACHED_EXPIRATION_NOT_ADD`, the operation will fail. For
56 all other ``expiration`` values, the operation will succeed by seeding the value
57 for that key with a initial value to expire with the provided expiration time.
58 The ``flags`` will be set to zero. The value is then returned via the uint32_t
59 ``value`` pointer you pass to it. `memcached_decrement_with_initial` is only
60 available when using the binary protocol.
61
62 `memcached_increment_by_key`, `memcached_decrement_by_key`,
63 `memcached_increment_with_initial_by_key`, and
64 `memcached_decrement_with_initial_by_key` are master key equivalents of the
65 above.
66
67 RETURN VALUE
68 ------------
69
70 A value of type `memcached_return_t` is returned.
71 On success that value will be `MEMCACHED_SUCCESS`.
72 Use `memcached_strerror` to translate this value to a printable string.
73
74 SEE ALSO
75 --------
76
77 .. only:: man
78
79 :manpage:`memcached(1)`
80 :manpage:`libmemcached(3)`
81 :manpage:`memcached_strerror(3)`
82
83 .. only:: html
84
85 * :manpage:`memcached(1)`
86 * :doc:`../libmemcached`
87 * :doc:`memcached_strerror`