diff --git a/src/main/java/net/spy/memcached/ConnectionFactory.java b/src/main/java/net/spy/memcached/ConnectionFactory.java
index 1c09cb5a7..20d18757f 100644
--- a/src/main/java/net/spy/memcached/ConnectionFactory.java
+++ b/src/main/java/net/spy/memcached/ConnectionFactory.java
@@ -107,6 +107,15 @@ MemcachedNode createMemcachedNode(String name,
*/
boolean useNagleAlgorithm();
+ /**
+ * If true, keep alive will be used on connected sockets.
+ *
+ *
+ * See {@link java.net.Socket#setKeepAlive(boolean)} for more information.
+ *
+ */
+ boolean getKeepAlive();
+
/**
* Observers that should be established at the time of connection
* instantiation.
diff --git a/src/main/java/net/spy/memcached/ConnectionFactoryBuilder.java b/src/main/java/net/spy/memcached/ConnectionFactoryBuilder.java
index 62a68998f..a6a210132 100644
--- a/src/main/java/net/spy/memcached/ConnectionFactoryBuilder.java
+++ b/src/main/java/net/spy/memcached/ConnectionFactoryBuilder.java
@@ -59,6 +59,7 @@ public class ConnectionFactoryBuilder {
private boolean isDaemon = true;
private boolean shouldOptimize = false;
private boolean useNagle = false;
+ protected boolean keepAlive = false;
//private long maxReconnectDelay =
//DefaultConnectionFactory.DEFAULT_MAX_RECONNECT_DELAY;
private long maxReconnectDelay = 1;
@@ -467,6 +468,9 @@ public Map getAPIReadPriority() {
}
/* ENABLE_REPLICATION end */
+ public void setKeepAlive(boolean on) {
+ keepAlive = on;
+ }
/**
* Get the ConnectionFactory set up with the provided parameters.
*/
@@ -591,6 +595,11 @@ public boolean useNagleAlgorithm() {
return useNagle;
}
+ @Override
+ public boolean getKeepAlive() {
+ return keepAlive;
+ }
+
@Override
public long getMaxReconnectDelay() {
return maxReconnectDelay;
diff --git a/src/main/java/net/spy/memcached/DefaultConnectionFactory.java b/src/main/java/net/spy/memcached/DefaultConnectionFactory.java
index 1a055ea3a..dbe2b05ff 100644
--- a/src/main/java/net/spy/memcached/DefaultConnectionFactory.java
+++ b/src/main/java/net/spy/memcached/DefaultConnectionFactory.java
@@ -318,7 +318,10 @@ public Transcoder