.\" Man page generated from reStructuredText. . . .nr rst2man-indent-level 0 . .de1 rstReportMargin \\$1 \\n[an-margin] level \\n[rst2man-indent-level] level margin: \\n[rst2man-indent\\n[rst2man-indent-level]] - \\n[rst2man-indent0] \\n[rst2man-indent1] \\n[rst2man-indent2] .. .de1 INDENT .\" .rstReportMargin pre: . RS \\$1 . nr rst2man-indent\\n[rst2man-indent-level] \\n[an-margin] . nr rst2man-indent-level +1 .\" .rstReportMargin post: .. .de UNINDENT . RE .\" indent \\n[an-margin] .\" old: \\n[rst2man-indent\\n[rst2man-indent-level]] .nr rst2man-indent-level -1 .\" new: \\n[rst2man-indent\\n[rst2man-indent-level]] .in \\n[rst2man-indent\\n[rst2man-indent-level]]u .. .TH "MEMCACHED_AUTO" "3" "Feb 01, 2024" "1.1" "libmemcached-awesome" .SH NAME memcached_auto \- Incrementing and Decrementing Values .SH SYNOPSIS .INDENT 0.0 .TP .B #include Compile and link with \-lmemcached .UNINDENT .INDENT 0.0 .TP .B \fI\%memcached_return_t\fP memcached_increment(\fI\%memcached_st\fP *ptr, const char *key, size_t key_length, uint32_t offset, uint64_t *value) .UNINDENT .INDENT 0.0 .TP .B \fI\%memcached_return_t\fP memcached_decrement(\fI\%memcached_st\fP *ptr, const char *key, size_t key_length, uint32_t offset, uint64_t *value) .UNINDENT .INDENT 0.0 .TP .B \fI\%memcached_return_t\fP memcached_increment_with_initial(\fI\%memcached_st\fP *ptr, const char *key, size_t key_length, uint64_t offset, uint64_t initial, time_t expiration, uint64_t *value) .UNINDENT .INDENT 0.0 .TP .B \fI\%memcached_return_t\fP memcached_decrement_with_initial(\fI\%memcached_st\fP *ptr, const char *key, size_t key_length, uint64_t offset, uint64_t initial, time_t expiration, uint64_t *value) .UNINDENT .INDENT 0.0 .TP .B \fI\%memcached_return_t\fP memcached_increment_by_key(\fI\%memcached_st\fP *ptr, const char *group_key, size_t group_key_length, const char *key, size_t key_length, uint32_t offset, uint64_t *value) .UNINDENT .INDENT 0.0 .TP .B \fI\%memcached_return_t\fP memcached_decrement_by_key(\fI\%memcached_st\fP *ptr, const char *group_key, size_t group_key_length, const char *key, size_t key_length, uint32_t offset, uint64_t *value) .UNINDENT .INDENT 0.0 .TP .B \fI\%memcached_return_t\fP memcached_increment_with_initial_by_key(\fI\%memcached_st\fP *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) .UNINDENT .INDENT 0.0 .TP .B \fI\%memcached_return_t\fP memcached_decrement_with_initial_by_key(\fI\%memcached_st\fP *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) .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBptr\fP \-\- pointer to an initialized \fI\%memcached_st\fP struct .IP \(bu 2 \fBgroup_key\fP \-\- key namespace .IP \(bu 2 \fBgroup_key_length\fP \-\- length of the key namespace without any terminating zero .IP \(bu 2 \fBkey\fP \-\- the key .IP \(bu 2 \fBkey_length\fP \-\- length of the key without any terminating zero .IP \(bu 2 \fBoffset\fP \-\- offset to increment/decrement .IP \(bu 2 \fBinitial\fP \-\- initial value if \fI\%key\fP does not exist and \fI\%expiration\fP is not \fBMEMCACHED_EXPIRATION_NOT_ADD\fP .IP \(bu 2 \fBexpiration\fP \-\- expiration as a unix timestamp or as relative expiration time in seconds .IP \(bu 2 \fBvalue\fP \-\- the resulting value after initialization/increment/decrement .UNINDENT .TP .B Returns \fI\%memcached_return_t\fP indicating success .UNINDENT .UNINDENT .SH DESCRIPTION .sp \fBmemcached(1)\fP servers have the ability to increment and decrement keys (overflow and underflow are not detected). This gives you the ability to use memcached to generate shared sequences of values. .sp \fI\%memcached_increment()\fP takes a \fBkey\fP and \fBkey_length\fP and increments the value by the \fBoffset\fP passed to it. The value is then returned via the uint32_t \fBvalue\fP pointer you pass to it. .sp \fI\%memcached_decrement()\fP takes a \fBkey\fP and \fBkey_length\fP and decrements the value by the \fBoffset\fP passed to it. The value is then returned via the uint32_t \fBvalue\fP pointer you pass to it. .sp \fI\%memcached_increment_with_initial()\fP takes a \fBkey\fP and \fBkey_length\fP and increments the value by the \fBoffset\fP passed to it. If the object specified by \fBkey\fP does not exist, one of two things may happen: If the \fBexpiration\fP value is \fI\%MEMCACHED_EXPIRATION_NOT_ADD\fP, the operation will fail. For all other \fBexpiration\fP values, the operation will succeed by seeding the value for that key with a initial value to expire with the provided expiration time. The \fBflags\fP will be set to zero. The value is then returned via the uint32_t \fBvalue\fP pointer you pass to it. \fBmemcached_increment_with_initial\fP is only available when using the binary protocol. .sp \fI\%memcached_decrement_with_initial()\fP takes a \fBkey\fP and \fBkey_length\fP and decrements the value by the \fBoffset\fP passed to it. If the object specified by \fBkey\fP does not exist, one of two things may happen: If the \fBexpiration\fP value is \fI\%MEMCACHED_EXPIRATION_NOT_ADD\fP, the operation will fail. For all other \fBexpiration\fP values, the operation will succeed by seeding the value for that key with a initial value to expire with the provided expiration time. The \fBflags\fP will be set to zero. The value is then returned via the uint32_t \fBvalue\fP pointer you pass to it. \fI\%memcached_decrement_with_initial()\fP is only available when using the binary protocol. .sp \fI\%memcached_increment_by_key()\fP, \fI\%memcached_decrement_by_key()\fP, \fI\%memcached_increment_with_initial_by_key()\fP, and \fI\%memcached_decrement_with_initial_by_key()\fP are master key equivalents of the above. .SH RETURN VALUE .sp A value of type \fI\%memcached_return_t\fP is returned. On success that value will be \fI\%MEMCACHED_SUCCESS\fP\&. Use \fI\%memcached_strerror()\fP to translate this value to a printable string. .SH SEE ALSO .sp \fBmemcached(1)\fP \fBlibmemcached(3)\fP \fBmemcached_strerror(3)\fP .\" Generated by docutils manpage writer. .