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