@@ -319,6 +319,104 @@ public int getDB() {
319319 return this .db ;
320320 }
321321
322+ /**
323+ * @return <code>PONG</code>
324+ */
325+ @ Override
326+ public String ping () {
327+ checkIsInMultiOrPipeline ();
328+ connection .sendCommand (Command .PING );
329+ return connection .getStatusCodeReply ();
330+ }
331+
332+ /**
333+ * Works same as {@link Jedis#ping()} but returns argument message instead of <code>PONG</code>.
334+ * @param message
335+ * @return message
336+ */
337+ public byte [] ping (final byte [] message ) {
338+ checkIsInMultiOrPipeline ();
339+ connection .sendCommand (Command .PING , message );
340+ return connection .getBinaryBulkReply ();
341+ }
342+
343+ /**
344+ * Select the DB with having the specified zero-based numeric index. For default every new
345+ * connection connection is automatically selected to DB 0.
346+ * @param index
347+ * @return OK
348+ */
349+ @ Override
350+ public String select (final int index ) {
351+ checkIsInMultiOrPipeline ();
352+ connection .sendCommand (SELECT , toByteArray (index ));
353+ String statusCodeReply = connection .getStatusCodeReply ();
354+ this .db = index ;
355+ return statusCodeReply ;
356+ }
357+
358+ @ Override
359+ public String swapDB (final int index1 , final int index2 ) {
360+ checkIsInMultiOrPipeline ();
361+ connection .sendCommand (SWAPDB , toByteArray (index1 ), toByteArray (index2 ));
362+ return connection .getStatusCodeReply ();
363+ }
364+
365+ /**
366+ * Delete all the keys of the currently selected DB. This command never fails.
367+ * @return OK
368+ */
369+ @ Override
370+ public String flushDB () {
371+ checkIsInMultiOrPipeline ();
372+ return connection .executeCommand (commandObjects .flushDB ());
373+ }
374+
375+ /**
376+ * Delete all the keys of the currently selected DB. This command never fails.
377+ * @param flushMode
378+ * @return OK
379+ */
380+ @ Override
381+ public String flushDB (FlushMode flushMode ) {
382+ checkIsInMultiOrPipeline ();
383+ connection .sendCommand (FLUSHDB , flushMode .getRaw ());
384+ return connection .getStatusCodeReply ();
385+ }
386+
387+ /**
388+ * Delete all the keys of all the existing databases, not just the currently selected one. This
389+ * command never fails.
390+ * @return OK
391+ */
392+ @ Override
393+ public String flushAll () {
394+ checkIsInMultiOrPipeline ();
395+ return connection .executeCommand (commandObjects .flushAll ());
396+ }
397+
398+ /**
399+ * Delete all the keys of all the existing databases, not just the currently selected one. This
400+ * command never fails.
401+ * @param flushMode
402+ * @return OK
403+ */
404+ @ Override
405+ public String flushAll (FlushMode flushMode ) {
406+ checkIsInMultiOrPipeline ();
407+ connection .sendCommand (FLUSHALL , flushMode .getRaw ());
408+ return connection .getStatusCodeReply ();
409+ }
410+
411+ /**
412+ * Ask the server to silently close the connection.
413+ */
414+ @ Override
415+ public String quit () {
416+ checkIsInMultiOrPipeline ();
417+ return connection .quit ();
418+ }
419+
322420 /**
323421 * COPY source destination [DB destination-db] [REPLACE]
324422 *
@@ -346,27 +444,6 @@ public boolean copy(byte[] srcKey, byte[] dstKey, boolean replace) {
346444 return connection .executeCommand (commandObjects .copy (srcKey , dstKey , replace ));
347445 }
348446
349- /**
350- * @return <code>PONG</code>
351- */
352- @ Override
353- public String ping () {
354- checkIsInMultiOrPipeline ();
355- connection .sendCommand (Command .PING );
356- return connection .getStatusCodeReply ();
357- }
358-
359- /**
360- * Works same as {@link Jedis#ping()} but returns argument message instead of <code>PONG</code>.
361- * @param message
362- * @return message
363- */
364- public byte [] ping (final byte [] message ) {
365- checkIsInMultiOrPipeline ();
366- connection .sendCommand (Command .PING , message );
367- return connection .getBinaryBulkReply ();
368- }
369-
370447 /**
371448 * Set the string value as value of the key. The string can't be longer than 1073741824 bytes (1
372449 * GB).
@@ -440,15 +517,6 @@ public byte[] getEx(final byte[] key, final GetExParams params) {
440517 return connection .executeCommand (commandObjects .getEx (key , params ));
441518 }
442519
443- /**
444- * Ask the server to silently close the connection.
445- */
446- @ Override
447- public String quit () {
448- checkIsInMultiOrPipeline ();
449- return connection .quit ();
450- }
451-
452520 /**
453521 * Test if the specified keys exist. The command returns the number of keys exist.
454522 * Time complexity: O(N)
@@ -531,29 +599,6 @@ public String type(final byte[] key) {
531599 return connection .executeCommand (commandObjects .type (key ));
532600 }
533601
534- /**
535- * Delete all the keys of the currently selected DB. This command never fails.
536- * @return OK
537- */
538- @ Override
539- public String flushDB () {
540- checkIsInMultiOrPipeline ();
541- connection .sendCommand (FLUSHDB );
542- return connection .getStatusCodeReply ();
543- }
544-
545- /**
546- * Delete all the keys of the currently selected DB. This command never fails.
547- * @param flushMode
548- * @return OK
549- */
550- @ Override
551- public String flushDB (FlushMode flushMode ) {
552- checkIsInMultiOrPipeline ();
553- connection .sendCommand (FLUSHDB , flushMode .getRaw ());
554- return connection .getStatusCodeReply ();
555- }
556-
557602 /**
558603 * Returns all the keys matching the glob-style pattern as space separated strings. For example if
559604 * you have in the database the keys "foo" and "foobar" the command "KEYS foo*" will return
@@ -714,7 +759,6 @@ public long pexpireTime(final byte[] key) {
714759 return connection .executeCommand (commandObjects .pexpireTime (key ));
715760 }
716761
717-
718762 /**
719763 * EXPIREAT works exactly like {@link Jedis#expire(byte[], long) EXPIRE} but instead to get the
720764 * number of seconds representing the Time To Live of the key as a second argument (that is a
@@ -793,28 +837,6 @@ public long touch(final byte[] key) {
793837 return connection .executeCommand (commandObjects .touch (key ));
794838 }
795839
796- /**
797- * Select the DB with having the specified zero-based numeric index. For default every new
798- * connection connection is automatically selected to DB 0.
799- * @param index
800- * @return OK
801- */
802- @ Override
803- public String select (final int index ) {
804- checkIsInMultiOrPipeline ();
805- connection .sendCommand (SELECT , toByteArray (index ));
806- String statusCodeReply = connection .getStatusCodeReply ();
807- this .db = index ;
808- return statusCodeReply ;
809- }
810-
811- @ Override
812- public String swapDB (final int index1 , final int index2 ) {
813- checkIsInMultiOrPipeline ();
814- connection .sendCommand (SWAPDB , toByteArray (index1 ), toByteArray (index2 ));
815- return connection .getStatusCodeReply ();
816- }
817-
818840 /**
819841 * Move the specified key from the currently selected DB to the specified destination DB. Note
820842 * that this command returns 1 only if the key was successfully moved, and 0 if the target key was
@@ -832,31 +854,6 @@ public long move(final byte[] key, final int dbIndex) {
832854 return connection .getIntegerReply ();
833855 }
834856
835- /**
836- * Delete all the keys of all the existing databases, not just the currently selected one. This
837- * command never fails.
838- * @return OK
839- */
840- @ Override
841- public String flushAll () {
842- checkIsInMultiOrPipeline ();
843- connection .sendCommand (FLUSHALL );
844- return connection .getStatusCodeReply ();
845- }
846-
847- /**
848- * Delete all the keys of all the existing databases, not just the currently selected one. This
849- * command never fails.
850- * @param flushMode
851- * @return OK
852- */
853- @ Override
854- public String flushAll (FlushMode flushMode ) {
855- checkIsInMultiOrPipeline ();
856- connection .sendCommand (FLUSHALL , flushMode .getRaw ());
857- return connection .getStatusCodeReply ();
858- }
859-
860857 /**
861858 * GETSET is an atomic set this value and return the old value command. Set key to the string
862859 * value and return the old value stored at key. The string can't be longer than 1073741824 bytes
@@ -3887,14 +3884,12 @@ public byte[] scriptLoad(final byte[] script) {
38873884
38883885 @ Override
38893886 public String scriptKill () {
3890- connection .sendCommand (SCRIPT , KILL );
3891- return connection .getStatusCodeReply ();
3887+ return connection .executeCommand (commandObjects .scriptKill ());
38923888 }
38933889
38943890 @ Override
38953891 public String slowlogReset () {
3896- connection .sendCommand (SLOWLOG , Keyword .RESET );
3897- return connection .getBulkReply ();
3892+ return connection .executeCommand (commandObjects .slowlogReset ());
38983893 }
38993894
39003895 @ Override
0 commit comments