=item MEMCACHED_BEHAVIOR_RANDOMIZE_REPLICA_READ
-Allows randomizing the replica reads starting point. Normally the read is
+Allows randomizing the replica reads starting point. Normally the read is
done from primary server and in case of miss the read is done from primary
-+ 1, then primary + 2 all the way to 'n' replicas. If this option is set
++ 1, then primary + 2 all the way to 'n' replicas. If this option is set
on the starting point of the replica reads is randomized between the servers.
-This allows distributing read load to multiple servers with the expense of
+This allows distributing read load to multiple servers with the expense of
more write traffic.
=item MEMCACHED_BEHAVIOR_CORK
MEMCACHED_NO_SERVERS is returned if no servers are available to test with.
MEMCACHED_NOT_SUPPORTED is returned if we were not able to determine
if support was available. All other responses then MEMCACHED_SUCCESS
-report an error of some sort. This behavior also enables
+report an error of some sort. This behavior also enables
MEMCACHED_BEHAVIOR_TCP_NODELAY when set.
+=item MEMCACHED_BEHAVIOR_KEEPALIVE
+
+Enable TCP_KEEPALIVE behavior.
=item MEMCACHED_BEHAVIOR_SOCKET_SEND_SIZE
ptr->flags.tcp_nodelay= set_flag(data);
memcached_quit(ptr);
break;
+ case MEMCACHED_BEHAVIOR_TCP_KEEPALIVE:
+ ptr->flags.tcp_keepalive= set_flag(data);
+ memcached_quit(ptr);
+ break;
case MEMCACHED_BEHAVIOR_DISTRIBUTION:
return memcached_behavior_set_distribution(ptr, (memcached_server_distribution_t)data);
case MEMCACHED_BEHAVIOR_KETAMA:
/**
@note We try to keep the same distribution going. This should be deprecated and rewritten.
*/
- return memcached_behavior_set_distribution(ptr, MEMCACHED_DISTRIBUTION_CONSISTENT_KETAMA);
+ return memcached_behavior_set_distribution(ptr, MEMCACHED_DISTRIBUTION_CONSISTENT_KETAMA);
}
case MEMCACHED_BEHAVIOR_HASH:
return memcached_behavior_set_key_hash(ptr, (memcached_hash_t)(data));
instance= memcached_server_instance_fetch(ptr, 0);
- /**
- @note REFACTOR
+ /**
+ @note REFACTOR
*/
if (instance)
{
return MEMCACHED_FAILURE;
}
+ if (ptr->root->flags.tcp_keepalive)
+ {
+ int flag= 1;
+ int error;
+
+ error= setsockopt(ptr->fd, SOL_SOCKET, SO_KEEPALIVE,
+ &flag, (socklen_t)sizeof(int));
+ WATCHPOINT_ASSERT(error == 0);
+ if (error)
+ return MEMCACHED_FAILURE;
+ }
+
if (ptr->root->send_size > 0)
{
int error;
WATCHPOINT_ASSERT(0);
}
- unlikely ( rc != MEMCACHED_SUCCESS)
+ unlikely ( rc != MEMCACHED_SUCCESS)
{
//@todo create interface around last_discontected_server
memcached_st *root= (memcached_st *)ptr->root;
MEMCACHED_BEHAVIOR_NUMBER_OF_REPLICAS,
MEMCACHED_BEHAVIOR_RANDOMIZE_REPLICA_READ,
MEMCACHED_BEHAVIOR_CORK,
+ MEMCACHED_BEHAVIOR_TCP_KEEPALIVE,
MEMCACHED_BEHAVIOR_MAX
} memcached_behavior_t;
* Use and distribution licensed under the BSD license. See
* the COPYING file in the parent directory for full text.
*
- * Summary:
+ * Summary:
*
*/
.use_cache_lookups= false,
.use_sort_hosts= false,
.use_udp= false,
- .verify_key= false
+ .verify_key= false,
+ .tcp_keepalive= false
}
};
bool use_sort_hosts MEMCACHED_BITFIELD;
bool use_udp MEMCACHED_BITFIELD;
bool verify_key MEMCACHED_BITFIELD;
+ bool tcp_keepalive MEMCACHED_BITFIELD;
} flags;
memcached_server_distribution_t distribution;
hashkit_st hashkit;