Permalink
Browse files

- Client

  • Loading branch information...
1 parent 3b5ac6a commit fe0b1f7cde86532f7bcc2f4e2b44a80d1fbad8f5 @e-mzungu committed May 1, 2011

Large diffs are not rendered by default.

Oops, something went wrong.
@@ -0,0 +1,24 @@
+/*
+ * Copyright 2010-2011. Evgeny Dolgov
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.idevlab.rjc;
+
+/**
+* @author Evgeny Dolgov
+*/
+public enum ListPosition {
+ BEFORE, AFTER
+}
@@ -1,34 +0,0 @@
-/*
- * Copyright 2010-2011. Evgeny Dolgov
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.idevlab.rjc;
-
-/**
- * <description>
- *
- * @author Evgeny Dolgov
- */
-public interface MultiExecCommands {
- void watch(String... keys);
-
- void unwatch();
-
- void multi();
-
- void discard();
-
- void exec();
-}
@@ -18,5 +18,5 @@
public interface Pipeline {
- void execute(RedisCommands commands);
+ void execute(RedisClient redis);
}
@@ -23,41 +23,91 @@
/**
* @author Evgeny Dolgov
*/
-public interface Redis {
+public interface RedisClient {
+
String getStatusReply(RedisCommand command);
+
String getStatusReply(RedisCommand command, String... args);
+
String getStatusReply(RedisCommand command, byte[]... args);
Long getIntegerReply(RedisCommand command);
+
Long getIntegerReply(RedisCommand command, String... args);
+
Long getIntegerReply(RedisCommand command, byte[]... args);
+ String getBulkReply();
+
String getBulkReply(RedisCommand command);
+
String getBulkReply(RedisCommand command, String... args);
- byte[] getBulkReply(RedisCommand command, byte[]... args);
+
+ byte[] getBinaryBulkReply(RedisCommand command, byte[]... args);
byte[] getBinaryBulkReply(RedisCommand command);
/**
- * Reply may contains Long and String objects
+ * Reply may contain Long and String objects
+ *
+ * @return Long and String objects
+ */
+ List<Object> getMultiBulkReply();
+
+ /**
+ * Reply may contain Long and String objects
+ *
+ * @param command redis command
+ * @return Long and String objects
+ */
+ List<Object> getMultiBulkReply(RedisCommand command);
+
+ /**
+ * Reply may contain Long and String objects
*
* @param command redis command
- * @param args command arguments
+ * @param args command arguments
* @return Long and String objects
*/
List<Object> getMultiBulkReply(RedisCommand command, String... args);
List<String> getStringMultiBulkReply(RedisCommand command, String... args);
/**
- * Reply may contains Long and byte[] objects
+ * Reply may contain Long and byte[] objects
*
* @param command redis command
- * @param args command arguments
+ * @param args command arguments
* @return Long and byte[] objects
*/
List<Object> getBinaryMultiBulkReply(RedisCommand command, byte[]... args);
+ /**
+ * Reply may contain Long and byte[] objects
+ *
+ * @param command redis command
+ * @return Long and byte[] objects
+ */
+ List<Object> getBinaryMultiBulkReply(RedisCommand command);
+
+ /**
+ * May contain Long and String objects
+ *
+ * @return Long and String objects
+ */
+ List<Object> getAll();
+
+ /**
+ * May contain Long and byte[] objects
+ *
+ * @return Long and byte[] objects
+ */
+ List<Object> getBinaryAll();
+
void noReply(RedisCommand command);
+
+ void noReply(RedisCommand command, String... args);
+
+ void noReply(RedisCommand command, byte[]... args);
}
@@ -24,14 +24,14 @@
/**
* @author Evgeny Dolgov
*/
-public class RedissImpl implements Redis {
+public class RedisClientImpl implements RedisClient {
private RedisConnection connection;
- public RedissImpl() {
+ public RedisClientImpl() {
}
- public RedissImpl(RedisConnection connection) {
+ public RedisClientImpl(RedisConnection connection) {
this.connection = connection;
}
@@ -73,6 +73,10 @@ public Long getIntegerReply(RedisCommand command, byte[]... args) {
return connection.getIntegerReply();
}
+ public String getBulkReply() {
+ return connection.getBulkReply();
+ }
+
public String getBulkReply(RedisCommand command) {
connection.sendCommand(command);
return connection.getBulkReply();
@@ -83,7 +87,7 @@ public String getBulkReply(RedisCommand command, String... args) {
return connection.getBulkReply();
}
- public byte[] getBulkReply(RedisCommand command, byte[]... args) {
+ public byte[] getBinaryBulkReply(RedisCommand command, byte[]... args) {
connection.sendCommand(command, args);
return connection.getBinaryBulkReply();
}
@@ -93,26 +97,68 @@ public String getBulkReply(RedisCommand command, String... args) {
return connection.getBinaryBulkReply();
}
+ public List<Object> getMultiBulkReply() {
+ return connection.getObjectMultiBulkReply();
+ }
+
public List<Object> getMultiBulkReply(RedisCommand command, String... args) {
connection.sendCommand(command, args);
return connection.getObjectMultiBulkReply();
}
+ public List<Object> getMultiBulkReply(RedisCommand command) {
+ connection.sendCommand(command);
+ return connection.getObjectMultiBulkReply();
+ }
+
public List<String> getStringMultiBulkReply(RedisCommand command, String... args) {
connection.sendCommand(command, args);
return connection.getMultiBulkReply();
}
public List<Object> getBinaryMultiBulkReply(RedisCommand command, byte[]... args) {
connection.sendCommand(command, args);
- return connection.getObjectMultiBulkReply();
+ return connection.getBinaryObjectMultiBulkReply();
+ }
+
+ public List<Object> getBinaryMultiBulkReply(RedisCommand command) {
+ connection.sendCommand(command);
+ return connection.getBinaryObjectMultiBulkReply();
+ }
+
+ public List<Object> getAll() {
+ return connection.getAll();
+ }
+
+ public List<Object> getBinaryAll() {
+ return connection.getBinaryAll();
}
public void noReply(RedisCommand command) {
connection.sendCommand(command);
}
+ public void noReply(RedisCommand command, String... args) {
+ connection.sendCommand(command, args);
+ }
+
+ public void noReply(RedisCommand command, byte[]... args) {
+ connection.sendCommand(command, args);
+ }
+
public void close() {
connection.close();
}
+
+ public boolean isConnected() {
+ return connection.isConnected();
+ }
+
+ public void setTimeoutInfinite() {
+ connection.setTimeoutInfinite();
+ }
+
+ public void rollbackTimeout() {
+ connection.rollbackTimeout();
+ }
}
Oops, something went wrong.

0 comments on commit fe0b1f7

Please sign in to comment.