From a688c610ae6d4927e9778833921950b7c04ff01a Mon Sep 17 00:00:00 2001 From: wjw465150 Date: Tue, 30 Aug 2011 17:23:49 +0800 Subject: [PATCH] wjw465150 add socket performance --- src/main/java/redis/clients/jedis/Connection.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/main/java/redis/clients/jedis/Connection.java b/src/main/java/redis/clients/jedis/Connection.java index be5e664566..64e8de93d4 100644 --- a/src/main/java/redis/clients/jedis/Connection.java +++ b/src/main/java/redis/clients/jedis/Connection.java @@ -116,6 +116,13 @@ public void connect() { if (!isConnected()) { try { socket = new Socket(); + //->@wjw_add + socket.setReuseAddress(true); + socket.setKeepAlive(true); //Will monitor the TCP connection is valid + socket.setTcpNoDelay(true); //Socket buffer Whetherclosed, to ensure timely delivery of data + socket.setSoLinger(true,0); //Control calls close () method, the underlying socket is closed immediately + //<-@wjw_add + socket.connect(new InetSocketAddress(host, port), timeout); socket.setSoTimeout(timeout); outputStream = new RedisOutputStream(socket.getOutputStream());