.\" 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_BEHAVIOR_SET" "3" "Feb 01, 2024" "1.1" "libmemcached-awesome" .SH NAME memcached_behavior_set \- libmemcached Documentation .sp Manipulate the behavior of a memcached_st structure. .SH SYNOPSIS .INDENT 0.0 .TP .B #include Compile and link with \-lmemcached .UNINDENT .INDENT 0.0 .TP .B uint64_t memcached_behavior_get(\fI\%memcached_st\fP *ptr, \fI\%memcached_behavior_t\fP flag) .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBptr\fP \-\- pointer to initialized \fI\%memcached_st\fP struct .IP \(bu 2 \fBflag\fP \-\- \fI\%memcached_behavior_t\fP to query .UNINDENT .TP .B Returns the vaue set for \fI\%flag\fP .UNINDENT .UNINDENT .INDENT 0.0 .TP .B \fI\%memcached_return_t\fP memcached_behavior_set(\fI\%memcached_st\fP *ptr, \fI\%memcached_behavior_t\fP flag, uint64_t data) .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBptr\fP \-\- pointer to initialized \fI\%memcached_st\fP struct .IP \(bu 2 \fBflag\fP \-\- \fI\%memcached_behavior_t\fP to set .IP \(bu 2 \fBdata\fP \-\- the value to set for \fI\%flag\fP .UNINDENT .TP .B Returns \fI\%memcached_return_t\fP indicating success .UNINDENT .sp Changed in version 0.17: The \fI\%data\fP argument of \fI\%memcached_behavior_set()\fP was changed from taking a pointer to data value, to taking a uin64_t. .UNINDENT .INDENT 0.0 .TP .B typedef enum \fI\%memcached_behavior_t\fP memcached_behavior_t .UNINDENT .INDENT 0.0 .TP .B enum memcached_behavior_t .INDENT 7.0 .TP .B enumerator MEMCACHED_BEHAVIOR_USE_UDP Causes \fBlibmemcached\fP to use the UDP transport when communicating with a memcached server. Not all I/O operations are tested when this behavior is enabled. .sp The following operations will return \fI\%MEMCACHED_NOT_SUPPORTED\fP when executed with \fI\%MEMCACHED_BEHAVIOR_USE_UDP\fP enabled: .INDENT 7.0 .IP \(bu 2 \fI\%memcached_version()\fP, .IP \(bu 2 \fI\%memcached_stat()\fP, .IP \(bu 2 \fI\%memcached_get()\fP, .IP \(bu 2 \fI\%memcached_get_by_key()\fP, .IP \(bu 2 \fI\%memcached_mget()\fP, .IP \(bu 2 \fI\%memcached_mget_by_key()\fP, .IP \(bu 2 \fI\%memcached_fetch()\fP, .IP \(bu 2 \fI\%memcached_fetch_result()\fP, .IP \(bu 2 \fI\%memcached_fetch_execute()\fP\&. .UNINDENT .sp All other operations are tested but are executed in a \(aqfire\-and\-forget\(aq mode, in which once the client has executed the operation, no attempt will be made to ensure the operation has been received and acted on by the server. .sp \fBlibmemcached\fP does not allow TCP and UDP servers to be shared within the same \fBlibmemcached\fP client \(aqinstance\(aq. An attempt to add a TCP server when this behavior is enabled will result in a \fI\%MEMCACHED_INVALID_HOST_PROTOCOL\fP, as will attempting to add a UDP server when this behavior has not been enabled. .UNINDENT .INDENT 7.0 .TP .B enumerator MEMCACHED_BEHAVIOR_NO_BLOCK This enables \fBSO_LINGER\fP only, so the \fBclose(2)\fP call on the socket returns immediately. I/O is always handled asynchronously in recent versions of \fBlibmemcached\fP\&. .UNINDENT .INDENT 7.0 .TP .B enumerator MEMCACHED_BEHAVIOR_SND_TIMEOUT This sets the microsecond behavior of the socket against the SO_SNDTIMEO flag. .UNINDENT .INDENT 7.0 .TP .B enumerator MEMCACHED_BEHAVIOR_RCV_TIMEOUT This sets the microsecond behavior of the socket against the SO_RCVTIMEO flag. .UNINDENT .INDENT 7.0 .TP .B enumerator MEMCACHED_BEHAVIOR_TCP_NODELAY Disables Nagle\(aqs algorithm. See \fI\%RFC 896\fP\&. .UNINDENT .INDENT 7.0 .TP .B enumerator MEMCACHED_BEHAVIOR_HASH Set the \fI\%hash algorithm\fP used for keys. .sp Each hash has its advantages and its weaknesses. If you don\(aqt know or don\(aqt care, just go with the default. .UNINDENT .INDENT 7.0 .TP .B enumerator MEMCACHED_BEHAVIOR_DISTRIBUTION Setting a \fI\%memcached_server_distribution_t\fP you can enable different means of distributing values to servers. .sp The default method is \fI\%MEMCACHED_DISTRIBUTION_MODULA\fP (hash of the key modulo number of servers). .sp You can enable consistent hashing by setting \fI\%MEMCACHED_DISTRIBUTION_CONSISTENT\fP\&. Consistent hashing delivers better distribution and allows servers to be added to the cluster with minimal cache losses. .sp Currently \fI\%MEMCACHED_DISTRIBUTION_CONSISTENT\fP is an alias for the value \fI\%MEMCACHED_DISTRIBUTION_CONSISTENT_KETAMA\fP\&. .UNINDENT .INDENT 7.0 .TP .B enumerator MEMCACHED_BEHAVIOR_CACHE_LOOKUPS .INDENT 7.0 .INDENT 3.5 Deprecated since version 0.46(?): DNS lookups are now always cached until an error occurs with the server. .UNINDENT .UNINDENT .sp Memcached can cache named lookups so that DNS lookups are made only once. .UNINDENT .INDENT 7.0 .TP .B enumerator MEMCACHED_BEHAVIOR_SUPPORT_CAS Support CAS operations (this is not enabled by default at this point in the server since it imposes a slight performance penalty). .UNINDENT .INDENT 7.0 .TP .B enumerator MEMCACHED_BEHAVIOR_KETAMA Sets the default distribution to \fI\%MEMCACHED_DISTRIBUTION_CONSISTENT_KETAMA\fP and the hash to \fI\%MEMCACHED_HASH_MD5\fP\&. .UNINDENT .INDENT 7.0 .TP .B enumerator MEMCACHED_BEHAVIOR_KETAMA_WEIGHTED Sets the default distribution to \fI\%MEMCACHED_DISTRIBUTION_CONSISTENT_KETAMA\fP with the weighted tests. Makes the default hashing algorithm for keys use \fI\%MEMCACHED_HASH_MD5\fP\&. .UNINDENT .INDENT 7.0 .TP .B enumerator MEMCACHED_BEHAVIOR_KETAMA_HASH Sets the \fI\%hashing algorithm\fP for host mapping on continuum. .UNINDENT .INDENT 7.0 .TP .B enumerator MEMCACHED_BEHAVIOR_KETAMA_COMPAT Sets the compatibility mode. The value can be set to either \fBMEMCACHED_KETAMA_COMPAT_LIBMEMCACHED\fP (this is the default) or \fBMEMCACHED_KETAMA_COMPAT_SPY\fP to be compatible with the SPY Memcached client for Java. .UNINDENT .INDENT 7.0 .TP .B enumerator MEMCACHED_BEHAVIOR_POLL_TIMEOUT Modify the timeout in milliseconds value that is used by poll. The default value is \-1. An signed int must be passed to \fI\%memcached_behavior_set()\fP to change this value (this requires casting). For \fI\%memcached_behavior_get()\fP a \(aqsigned int\(aq value will be cast and returned as \(aqunsigned long long\(aq. .UNINDENT .INDENT 7.0 .TP .B enumerator MEMCACHED_BEHAVIOR_USER_DATA Deprecated since version <: 0.30 .UNINDENT .INDENT 7.0 .TP .B enumerator MEMCACHED_BEHAVIOR_BUFFER_REQUESTS Enabling buffered IO causes commands to \(dqbuffer\(dq instead of being sent. Any action that gets data causes this buffer to be be sent to the remote connection. Quiting the connection or closing down the connection will also cause the buffered data to be pushed to the remote connection. .UNINDENT .INDENT 7.0 .TP .B enumerator MEMCACHED_BEHAVIOR_VERIFY_KEY Enabling this will cause \fBlibmemcached\fP to test all keys to verify that they are valid keys. .UNINDENT .INDENT 7.0 .TP .B enumerator MEMCACHED_BEHAVIOR_SORT_HOSTS Enabling this will cause hosts that are added to be placed in the host list in sorted order. This will defeat consistent hashing. .UNINDENT .INDENT 7.0 .TP .B enumerator MEMCACHED_BEHAVIOR_CONNECT_TIMEOUT Set the timeout during socket connection in milliseconds. Specifying \-1 means an infinite timeā€out. .UNINDENT .INDENT 7.0 .TP .B enumerator MEMCACHED_BEHAVIOR_BINARY_PROTOCOL Enable the use of the binary protocol. Please note that you cannot toggle this flag on an open connection. .UNINDENT .INDENT 7.0 .TP .B enumerator MEMCACHED_BEHAVIOR_IO_MSG_WATERMARK Set this value to tune the number of messages that may be sent before \fBlibmemcached\fP should start to automatically drain the input queue. .sp Setting this value to high, may cause \fBlibmemcached\fP to deadlock (trying to send data, but the send will block because the input buffer in the kernel is full). .UNINDENT .INDENT 7.0 .TP .B enumerator MEMCACHED_BEHAVIOR_IO_BYTES_WATERMARK Set this value to tune the number of bytes that may be sent before \fBlibmemcached\fP should start to automatically drain the input queue (need at least 10 IO requests sent without reading the input buffer). .sp Setting this value to high, may cause libmemcached to deadlock (trying to send data, but the send will block because the input buffer in the kernel is full). .UNINDENT .INDENT 7.0 .TP .B enumerator MEMCACHED_BEHAVIOR_IO_KEY_PREFETCH The binary protocol works a bit different than the textual protocol in that a multiget is implemented as a pipe of single get\-operations which are sent to the server in a chunk. .sp If you are using large multigets from your application, you may improve the latency of the gets by setting this value so you send out the first chunk of requests when you hit the specified limit. It allows the servers to start processing the requests to send the data back while the rest of the requests are created and sent to the server. .UNINDENT .INDENT 7.0 .TP .B enumerator MEMCACHED_BEHAVIOR_NOREPLY Set this value to specify that you really don\(aqt care about the result from your storage commands (set, add, replace, append, prepend). .UNINDENT .INDENT 7.0 .TP .B enumerator MEMCACHED_BEHAVIOR_NUMBER_OF_REPLICAS Specify the number of replicas \fBlibmemcached\fP should store of each item (on different servers). .sp This replication does not dedicate certain memcached servers to store the replicas in, but instead it will store the replicas together with all of the other objects (on the \(aqn\(aq next servers specified in your server list). .sp Requires the binary protocol and only supports (M)GET/SET/DELETE. .sp \fBNOTE\fP: \fBlibmemcached\fP does not guarantee nor enforce any consistency. .UNINDENT .INDENT 7.0 .TP .B enumerator MEMCACHED_BEHAVIOR_RANDOMIZE_REPLICA_READ Allows randomizing the replica reads starting point. Normally the read is done from primary server and in case of failure the read is done from primary + 1, then primary + 2 all the way to \(aqn\(aq replicas. .sp This allows distributing read load to multiple servers with the expense of more write traffic. .sp \fBNOTE\fP: Only errors to communicate with a server are considered failures, so \fI\%MEMCACHED_NOTFOUND\fP does \fInot\fP account for failure. .UNINDENT .INDENT 7.0 .TP .B enumerator MEMCACHED_BEHAVIOR_CORK Deprecated since version ?: This option has been deprecated with the behavior now built in and used appropriately on selected platforms. .UNINDENT .INDENT 7.0 .TP .B enumerator MEMCACHED_BEHAVIOR_KEEPALIVE Enable TCP_KEEPALIVE behavior. .UNINDENT .INDENT 7.0 .TP .B enumerator MEMCACHED_BEHAVIOR_KEEPALIVE_IDLE Specify time, in seconds, to mark a connection as idle. This is only available as an option on Linux. .UNINDENT .INDENT 7.0 .TP .B enumerator MEMCACHED_BEHAVIOR_SOCKET_SEND_SIZE Find the current size of SO_SNDBUF. A value of 0 means either an error occurred or no hosts were available. It is safe to assume system default if this occurs. .sp If an error occurs you can check the last cached errno to find the specific error. .UNINDENT .INDENT 7.0 .TP .B enumerator MEMCACHED_BEHAVIOR_SOCKET_RECV_SIZE Find the current size of SO_RCVBUF. A value of 0 means either an error occurred or no hosts were available. It is safe to assume system default if this occurs. .sp If an error occurs you can check the last cached errno to find the specific error. .UNINDENT .INDENT 7.0 .TP .B enumerator MEMCACHED_BEHAVIOR_SERVER_FAILURE_LIMIT Deprecated since version 0.48: See \fI\%MEMCACHED_BEHAVIOR_REMOVE_FAILED_SERVERS\fP .sp Set this value to enable the server be removed after continuous \fI\%MEMCACHED_BEHAVIOR_SERVER_FAILURE_LIMIT\fP times connection failure. .UNINDENT .INDENT 7.0 .TP .B enumerator MEMCACHED_BEHAVIOR_AUTO_EJECT_HOSTS Deprecated since version 0.48: See \fI\%MEMCACHED_BEHAVIOR_REMOVE_FAILED_SERVERS\fP .sp If enabled any hosts which have been flagged as disabled will be removed from the list of servers in the \fI\%memcached_st\fP structure. This must be used in combination with \fI\%MEMCACHED_BEHAVIOR_SERVER_FAILURE_LIMIT\fP\&. .UNINDENT .INDENT 7.0 .TP .B enumerator MEMCACHED_BEHAVIOR_REMOVE_FAILED_SERVERS If enabled any hosts which have been flagged as disabled will be removed from the list of servers in the \fI\%memcached_st\fP structure. .UNINDENT .INDENT 7.0 .TP .B enumerator MEMCACHED_BEHAVIOR_RETRY_TIMEOUT When enabled a host which is problematic will only be checked for usage based on the amount of time set by this behavior. The value is in seconds. .UNINDENT .INDENT 7.0 .TP .B enumerator MEMCACHED_BEHAVIOR_HASH_WITH_PREFIX_KEY When enabled the prefix key will be added to the key when determining server by hash. See \fI\%MEMCACHED_CALLBACK_NAMESPACE\fP for additional information. .UNINDENT .UNINDENT .INDENT 0.0 .TP .B typedef enum \fI\%memcached_server_distribution_t\fP memcached_server_distribution_t .UNINDENT .INDENT 0.0 .TP .B enum memcached_server_distribution_t .INDENT 7.0 .TP .B enumerator MEMCACHED_DISTRIBUTION_MODULA Distribute keys by hash modulo number of servers. .UNINDENT .INDENT 7.0 .TP .B enumerator MEMCACHED_DISTRIBUTION_CONSISTENT Alias for \fI\%MEMCACHED_DISTRIBUTION_CONSISTENT_KETAMA\fP\&. .UNINDENT .INDENT 7.0 .TP .B enumerator MEMCACHED_DISTRIBUTION_CONSISTENT_KETAMA Unweighted consistent key distribution. .UNINDENT .INDENT 7.0 .TP .B enumerator MEMCACHED_DISTRIBUTION_RANDOM Distribute keys by \fBrand(3)\fP modulo number of servers. .UNINDENT .INDENT 7.0 .TP .B enumerator MEMCACHED_DISTRIBUTION_CONSISTENT_KETAMA_SPY Unweighted consistent key distribution compatible with the SPY client. .UNINDENT .INDENT 7.0 .TP .B enumerator MEMCACHED_DISTRIBUTION_CONSISTENT_WEIGHTED Weighted consistent key distribution. .UNINDENT .INDENT 7.0 .TP .B enumerator MEMCACHED_DISTRIBUTION_VIRTUAL_BUCKET Consistent key distribution by virtual buckets. .UNINDENT .UNINDENT .SH DESCRIPTION .sp \fBlibmemcached\fP behavior can be modified by using \fI\%memcached_behavior_set()\fP\&. Default behavior is the library strives to be quick and accurate. Some behavior, while being faster, can also result in not entirely accurate behavior (for instance, \fI\%memcached_set()\fP will always respond with \fI\%MEMCACHED_SUCCESS\fP). .sp \fI\%memcached_behavior_get()\fP takes a behavior \fBflag\fP and returns whether or not that behavior is currently enabled in the client. .sp \fI\%memcached_behavior_set()\fP changes the value of a particular option of the client. It takes both a \fBflag\fP and a \fBvalue\fP\&. For simple on or off options you just need to pass in a value of 1. Calls to \fI\%memcached_behavior_set()\fP will flush and reset all connections. .SH RETURN VALUE .sp \fI\%memcached_behavior_get()\fP returns either the current value of the key, or 0 or 1 on simple flag behaviors (1 being enabled). \fI\%memcached_behavior_set()\fP returns failure or success. .SH NOTES .sp The \fBdata\fP argument of \fI\%memcached_behavior_set()\fP was changed in version 0.17 from taking a pointer to data value, to taking a uin64_t. .SH SEE ALSO .sp \fBmemcached(1)\fP \fBsetsockopt(3)\fP \fBlibmemcached(3)\fP \fBmemcached_strerror(3)\fP .\" Generated by docutils manpage writer. .