+ add support for the new list index command
This commit is contained in:
@@ -25,6 +25,10 @@ import java.util.List;
|
||||
*/
|
||||
public interface RedisListCommands {
|
||||
|
||||
public enum POSITION {
|
||||
BEFORE, AFTER
|
||||
}
|
||||
|
||||
Long rPush(byte[] key, byte[] value);
|
||||
|
||||
Long lPush(byte[] key, byte[] value);
|
||||
@@ -37,6 +41,8 @@ public interface RedisListCommands {
|
||||
|
||||
byte[] lIndex(byte[] key, long index);
|
||||
|
||||
Long lInsert(byte[] key, POSITION where, byte[] pivot, byte[] value);
|
||||
|
||||
void lSet(byte[] key, long index, byte[] value);
|
||||
|
||||
Long lRem(byte[] key, long count, byte[] value);
|
||||
|
||||
@@ -671,6 +671,18 @@ public class JedisConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long lInsert(byte[] key, POSITION where, byte[] pivot, byte[] value) {
|
||||
try {
|
||||
if (isQueueing()) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
return jedis.linsert(key, JedisUtils.convertPosition(where), pivot, value);
|
||||
} catch (Exception ex) {
|
||||
throw convertJedisAccessException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long lLen(byte[] key) {
|
||||
try {
|
||||
|
||||
@@ -30,12 +30,15 @@ import org.springframework.data.keyvalue.redis.RedisConnectionFailureException;
|
||||
import org.springframework.data.keyvalue.redis.UncategorizedRedisException;
|
||||
import org.springframework.data.keyvalue.redis.connection.DefaultTuple;
|
||||
import org.springframework.data.keyvalue.redis.connection.SortParameters;
|
||||
import org.springframework.data.keyvalue.redis.connection.RedisListCommands.POSITION;
|
||||
import org.springframework.data.keyvalue.redis.connection.RedisZSetCommands.Tuple;
|
||||
import org.springframework.data.keyvalue.redis.connection.SortParameters.Order;
|
||||
import org.springframework.data.keyvalue.redis.connection.SortParameters.Range;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
import redis.clients.jedis.JedisException;
|
||||
import redis.clients.jedis.SortingParams;
|
||||
import redis.clients.jedis.BinaryClient.LIST_POSITION;
|
||||
|
||||
/**
|
||||
* Helper class featuring methods for Jedis connection handling, providing support for exception translation.
|
||||
@@ -169,4 +172,9 @@ public abstract class JedisUtils {
|
||||
static byte[] asBit(boolean value) {
|
||||
return (value ? ONE : ZERO);
|
||||
}
|
||||
|
||||
static LIST_POSITION convertPosition(POSITION where) {
|
||||
Assert.notNull("list positions are mandatory");
|
||||
return (POSITION.AFTER.equals(where) ? LIST_POSITION.AFTER : LIST_POSITION.BEFORE);
|
||||
}
|
||||
}
|
||||
@@ -511,6 +511,12 @@ public class JredisConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long lInsert(byte[] key, POSITION where, byte[] pivot, byte[] value) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Set commands
|
||||
//
|
||||
|
||||
Reference in New Issue
Block a user