Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
ivowiblo committed Apr 14, 2012
2 parents fb723db + 72ca494 commit be163ac
Show file tree
Hide file tree
Showing 15 changed files with 296 additions and 73 deletions.
8 changes: 4 additions & 4 deletions src/main/java/redis/clients/jedis/BinaryClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -643,12 +643,12 @@ public void slaveofNoOne() {
sendCommand(SLAVEOF, NO.raw, ONE.raw);
}

public void configGet(final String pattern) {
sendCommand(CONFIG, Keyword.GET.name(), pattern);
public void configGet(final byte[] pattern) {
sendCommand(CONFIG, Keyword.GET.raw, pattern);
}

public void configSet(final String parameter, final String value) {
sendCommand(CONFIG, Keyword.SET.name(), parameter, value);
public void configSet(final byte[] parameter, final byte[] value) {
sendCommand(CONFIG, Keyword.SET.raw, parameter, value);
}

public void strlen(final byte[] key) {
Expand Down
18 changes: 9 additions & 9 deletions src/main/java/redis/clients/jedis/BinaryJedis.java
Original file line number Diff line number Diff line change
Expand Up @@ -2822,9 +2822,9 @@ public String slaveofNoOne() {
* @param pattern
* @return Bulk reply.
*/
public List<String> configGet(final String pattern) {
public List<byte[]> configGet(final byte[] pattern) {
client.configGet(pattern);
return client.getMultiBulkReply();
return client.getBinaryMultiBulkReply();
}

/**
Expand Down Expand Up @@ -2871,9 +2871,9 @@ public String configResetStat() {
* @param value
* @return Status code reply
*/
public String configSet(final String parameter, final String value) {
public byte[] configSet(final byte[] parameter, final byte[] value) {
client.configSet(parameter, value);
return client.getStatusCodeReply();
return client.getBinaryBulkReply();
}

public boolean isConnected() {
Expand Down Expand Up @@ -2959,9 +2959,9 @@ public byte[] brpoplpush(byte[] source, byte[] destination, int timeout) {
* @param value
* @return
*/
public Long setbit(byte[] key, long offset, byte[] value) {
public Boolean setbit(byte[] key, long offset, byte[] value) {
client.setbit(key, offset, value);
return client.getIntegerReply();
return client.getIntegerReply() == 1;
}

/**
Expand All @@ -2971,12 +2971,12 @@ public Long setbit(byte[] key, long offset, byte[] value) {
* @param offset
* @return
*/
public Long getbit(byte[] key, long offset) {
public Boolean getbit(byte[] key, long offset) {
client.getbit(key, offset);
return client.getIntegerReply();
return client.getIntegerReply() == 1;
}

public long setrange(byte[] key, long offset, byte[] value) {
public Long setrange(byte[] key, long offset, byte[] value) {
client.setrange(key, offset, value);
return client.getIntegerReply();
}
Expand Down
87 changes: 86 additions & 1 deletion src/main/java/redis/clients/jedis/BinaryTransaction.java
Original file line number Diff line number Diff line change
Expand Up @@ -563,4 +563,89 @@ public Response<byte[]> brpoplpush(byte[] source, byte[] destination,
client.brpoplpush(source, destination, timeout);
return getResponse(BuilderFactory.BYTE_ARRAY);
}
}

public Response<String> select(final int index) {
client.select(index);
return getResponse(BuilderFactory.STRING);
}

public Response<String> flushDB() {
client.flushDB();
return getResponse(BuilderFactory.STRING);
}

public Response<String> flushAll() {
client.flushAll();
return getResponse(BuilderFactory.STRING);
}

public Response<String> save() {
client.save();
return getResponse(BuilderFactory.STRING);
}

public Response<String> info() {
client.info();
return getResponse(BuilderFactory.STRING);
}

public Response<Long> lastsave() {
client.lastsave();
return getResponse(BuilderFactory.LONG);
}

public Response<Long> dbSize() {
client.dbSize();
return getResponse(BuilderFactory.LONG);
}

public Response<List<byte[]>> configGet(final byte[] pattern) {
client.configGet(pattern);
return getResponse(BuilderFactory.BYTE_ARRAY_LIST);
}

public Response<byte[]> configSet(final byte[] parameter, final byte[] value) {
client.configSet(parameter, value);
return getResponse(BuilderFactory.BYTE_ARRAY);
}

public Response<String> configResetStat() {
client.configResetStat();
return getResponse(BuilderFactory.STRING);
}

public Response<String> shutdown() {
client.shutdown();
return getResponse(BuilderFactory.STRING);
}

public Response<Boolean> getbit(final byte[] key, final long offset) {
client.getbit(key, offset);
return getResponse(BuilderFactory.BOOLEAN);
}

public Response<Boolean> setbit(final byte[] key, final long offset, final byte[] value) {
client.setbit(key, offset, value);
return getResponse(BuilderFactory.BOOLEAN);
}

public Response<String> ping() {
client.ping();
return getResponse(BuilderFactory.STRING);
}

public Response<Long> setrange(byte[] key, long offset, byte[] value) {
client.setrange(key, offset, value);
return getResponse(BuilderFactory.LONG);
}

public Response<String> randomKey() {
client.randomKey();
return getResponse(BuilderFactory.STRING);
}

public Response<Long> publish(byte[] channel, byte[] message) {
client.publish(channel, message);
return getResponse(BuilderFactory.LONG);
}
}
8 changes: 8 additions & 0 deletions src/main/java/redis/clients/jedis/Client.java
Original file line number Diff line number Diff line change
Expand Up @@ -587,4 +587,12 @@ public void subscribe(final String... channels) {
}
subscribe(cs);
}

public void configSet(String parameter, String value) {
configSet(SafeEncoder.encode(parameter), SafeEncoder.encode(value));
}

public void configGet(String pattern) {
configGet(SafeEncoder.encode(pattern));
}
}
98 changes: 83 additions & 15 deletions src/main/java/redis/clients/jedis/Jedis.java
Original file line number Diff line number Diff line change
Expand Up @@ -226,18 +226,6 @@ public Long renamenx(final String oldkey, final String newkey) {
return client.getIntegerReply();
}

/**
* Return the number of keys in the currently selected database.
*
* @return Integer reply
*/

public Long dbSize() {
checkIsInMulti();
client.dbSize();
return client.getIntegerReply();
}

/**
* Set a timeout on the specified key. After the timeout the key will be
* automatically deleted by the server. A key with an associated timeout is
Expand Down Expand Up @@ -2595,7 +2583,7 @@ public String brpoplpush(String source, String destination, int timeout) {
* @param value
* @return
*/
public boolean setbit(String key, long offset, boolean value) {
public Boolean setbit(String key, long offset, boolean value) {
client.setbit(key, offset, value);
return client.getIntegerReply() == 1;
}
Expand All @@ -2607,12 +2595,12 @@ public boolean setbit(String key, long offset, boolean value) {
* @param offset
* @return
*/
public boolean getbit(String key, long offset) {
public Boolean getbit(String key, long offset) {
client.getbit(key, offset);
return client.getIntegerReply() == 1;
}

public long setrange(String key, long offset, String value) {
public Long setrange(String key, long offset, String value) {
client.setrange(key, offset, value);
return client.getIntegerReply();
}
Expand All @@ -2621,4 +2609,84 @@ public String getrange(String key, long startOffset, long endOffset) {
client.getrange(key, startOffset, endOffset);
return client.getBulkReply();
}

/**
* Retrieve the configuration of a running Redis server. Not all the
* configuration parameters are supported.
* <p>
* CONFIG GET returns the current configuration parameters. This sub command
* only accepts a single argument, that is glob style pattern. All the
* configuration parameters matching this parameter are reported as a list
* of key-value pairs.
* <p>
* <b>Example:</b>
*
* <pre>
* $ redis-cli config get '*'
* 1. "dbfilename"
* 2. "dump.rdb"
* 3. "requirepass"
* 4. (nil)
* 5. "masterauth"
* 6. (nil)
* 7. "maxmemory"
* 8. "0\n"
* 9. "appendfsync"
* 10. "everysec"
* 11. "save"
* 12. "3600 1 300 100 60 10000"
*
* $ redis-cli config get 'm*'
* 1. "masterauth"
* 2. (nil)
* 3. "maxmemory"
* 4. "0\n"
* </pre>
*
* @param pattern
* @return Bulk reply.
*/
public List<String> configGet(final String pattern) {
client.configGet(pattern);
return client.getMultiBulkReply();
}

/**
* Alter the configuration of a running Redis server. Not all the
* configuration parameters are supported.
* <p>
* The list of configuration parameters supported by CONFIG SET can be
* obtained issuing a {@link #configGet(String) CONFIG GET *} command.
* <p>
* The configuration set using CONFIG SET is immediately loaded by the Redis
* server that will start acting as specified starting from the next
* command.
* <p>
*
* <b>Parameters value format</b>
* <p>
* The value of the configuration parameter is the same as the one of the
* same parameter in the Redis configuration file, with the following
* exceptions:
* <p>
* <ul>
* <li>The save paramter is a list of space-separated integers. Every pair
* of integers specify the time and number of changes limit to trigger a
* save. For instance the command CONFIG SET save "3600 10 60 10000" will
* configure the server to issue a background saving of the RDB file every
* 3600 seconds if there are at least 10 changes in the dataset, and every
* 60 seconds if there are at least 10000 changes. To completely disable
* automatic snapshots just set the parameter as an empty string.
* <li>All the integer parameters representing memory are returned and
* accepted only using bytes as unit.
* </ul>
*
* @param parameter
* @param value
* @return Status code reply
*/
public String configSet(final String parameter, final String value) {
client.configSet(parameter, value);
return client.getStatusCodeReply();
}
}
6 changes: 3 additions & 3 deletions src/main/java/redis/clients/jedis/JedisCommands.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ public interface JedisCommands {

Long ttl(String key);

boolean setbit(String key, long offset, boolean value);
Boolean setbit(String key, long offset, boolean value);

boolean getbit(String key, long offset);
Boolean getbit(String key, long offset);

long setrange(String key, long offset, String value);
Long setrange(String key, long offset, String value);

String getrange(String key, long startOffset, long endOffset);

Expand Down
55 changes: 45 additions & 10 deletions src/main/java/redis/clients/jedis/Pipeline.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,11 @@ public List<Object> syncAndReturnAll() {
List<Object> unformatted = client.getAll();
List<Object> formatted = new ArrayList<Object>();
for (Object o : unformatted) {
try{
formatted.add(generateResponse(o).get());
}catch(JedisDataException e){
formatted.add(e);
}
try {
formatted.add(generateResponse(o).get());
} catch (JedisDataException e) {
formatted.add(e);
}
}
return formatted;
}
Expand Down Expand Up @@ -154,9 +154,9 @@ public Response<String> get(String key) {
return getResponse(BuilderFactory.STRING);
}

public Response<String> get(byte[] key) {
public Response<byte[]> get(byte[] key) {
client.get(key);
return getResponse(BuilderFactory.STRING);
return getResponse(BuilderFactory.BYTE_ARRAY);
}

public Response<Boolean> getbit(String key, long offset) {
Expand All @@ -175,9 +175,9 @@ public Response<String> getSet(String key, String value) {
return getResponse(BuilderFactory.STRING);
}

public Response<String> getSet(byte[] key, byte[] value) {
public Response<byte[]> getSet(byte[] key, byte[] value) {
client.getSet(key, value);
return getResponse(BuilderFactory.STRING);
return getResponse(BuilderFactory.BYTE_ARRAY);
}

public Response<Long> hdel(String key, String field) {
Expand Down Expand Up @@ -1191,4 +1191,39 @@ public Response<Long> publish(byte[] channel, byte[] message) {
client.publish(channel, message);
return getResponse(BuilderFactory.LONG);
}
}

public Response<String> flushDB() {
client.flushDB();
return getResponse(BuilderFactory.STRING);
}

public Response<String> flushAll() {
client.flushAll();
return getResponse(BuilderFactory.STRING);
}

public Response<String> info() {
client.info();
return getResponse(BuilderFactory.STRING);
}

public Response<Long> dbSize() {
client.dbSize();
return getResponse(BuilderFactory.LONG);
}

public Response<String> shutdown() {
client.shutdown();
return getResponse(BuilderFactory.STRING);
}

public Response<String> ping() {
client.ping();
return getResponse(BuilderFactory.STRING);
}

public Response<String> randomKey() {
client.randomKey();
return getResponse(BuilderFactory.STRING);
}
}
Loading

0 comments on commit be163ac

Please sign in to comment.