1414import static redis .clients .jedis .Protocol .Keyword .WITHSCORES ;
1515import static redis .clients .jedis .Protocol .Keyword .FREQ ;
1616import static redis .clients .jedis .Protocol .Keyword .HELP ;
17- import static redis .clients .jedis .Protocol .Keyword .COUNT ;
1817
1918import java .util .ArrayList ;
2019import java .util .Collections ;
@@ -41,8 +40,8 @@ public class BinaryClient extends Connection {
4140
4241 private boolean isInMulti ;
4342
44- private String user ;
45- private String password ;
43+ @ Deprecated private String user ;
44+ @ Deprecated private String password ;
4645
4746 private int db ;
4847
@@ -72,8 +71,8 @@ public BinaryClient(final String host, final int port, final boolean ssl,
7271 super (host , port , ssl , sslSocketFactory , sslParameters , hostnameVerifier );
7372 }
7473
75- public BinaryClient (final String host , final int port , final JedisSocketConfig jedisSocketConfig ) {
76- super (host , port , jedisSocketConfig );
74+ public BinaryClient (final HostAndPort hostPort , final JedisClientConfig clientConfig ) {
75+ super (hostPort , clientConfig );
7776 }
7877
7978 public BinaryClient (final JedisSocketFactory jedisSocketFactory ) {
@@ -88,25 +87,12 @@ public boolean isInWatch() {
8887 return isInWatch ;
8988 }
9089
91- private byte [][] joinParameters (byte [] first , byte [][] rest ) {
92- byte [][] result = new byte [rest .length + 1 ][];
93- result [0 ] = first ;
94- System .arraycopy (rest , 0 , result , 1 , rest .length );
95- return result ;
96- }
97-
98- private byte [][] joinParameters (byte [] first , byte [] second , byte [][] rest ) {
99- byte [][] result = new byte [rest .length + 2 ][];
100- result [0 ] = first ;
101- result [1 ] = second ;
102- System .arraycopy (rest , 0 , result , 2 , rest .length );
103- return result ;
104- }
105-
90+ @ Deprecated
10691 public void setUser (final String user ) {
10792 this .user = user ;
10893 }
10994
95+ @ Deprecated
11096 public void setPassword (final String password ) {
11197 this .password = password ;
11298 }
@@ -115,6 +101,10 @@ public void setDb(int db) {
115101 this .db = db ;
116102 }
117103
104+ public int getDB () {
105+ return db ;
106+ }
107+
118108 @ Override
119109 public void connect () {
120110 if (!isConnected ()) {
@@ -133,6 +123,25 @@ public void connect() {
133123 }
134124 }
135125
126+ @ Override
127+ public void disconnect () {
128+ db = 0 ;
129+ super .disconnect ();
130+ }
131+
132+ @ Override
133+ public void close () {
134+ db = 0 ;
135+ super .close ();
136+ }
137+
138+ public void resetState () {
139+ if (isInWatch ()) {
140+ unwatch ();
141+ getStatusCodeReply ();
142+ }
143+ }
144+
136145 public void ping () {
137146 sendCommand (PING );
138147 }
@@ -962,29 +971,6 @@ public void getrange(final byte[] key, final long startOffset, final long endOff
962971 sendCommand (GETRANGE , key , toByteArray (startOffset ), toByteArray (endOffset ));
963972 }
964973
965- public int getDB () {
966- return db ;
967- }
968-
969- @ Override
970- public void disconnect () {
971- db = 0 ;
972- super .disconnect ();
973- }
974-
975- @ Override
976- public void close () {
977- db = 0 ;
978- super .close ();
979- }
980-
981- public void resetState () {
982- if (isInWatch ()) {
983- unwatch ();
984- getStatusCodeReply ();
985- }
986- }
987-
988974 public void eval (final byte [] script , final byte [] keyCount , final byte [][] params ) {
989975 sendCommand (EVAL , joinParameters (script , keyCount , params ));
990976 }
@@ -1619,4 +1605,19 @@ public void xinfoConsumers (byte[] key, byte[] group) {
16191605 sendCommand (XINFO ,Keyword .CONSUMERS .raw ,key ,group );
16201606 }
16211607
1608+ private static byte [][] joinParameters (byte [] first , byte [][] rest ) {
1609+ byte [][] result = new byte [rest .length + 1 ][];
1610+ result [0 ] = first ;
1611+ System .arraycopy (rest , 0 , result , 1 , rest .length );
1612+ return result ;
1613+ }
1614+
1615+ private static byte [][] joinParameters (byte [] first , byte [] second , byte [][] rest ) {
1616+ byte [][] result = new byte [rest .length + 2 ][];
1617+ result [0 ] = first ;
1618+ result [1 ] = second ;
1619+ System .arraycopy (rest , 0 , result , 2 , rest .length );
1620+ return result ;
1621+ }
1622+
16221623}
0 commit comments