+ add new Redis 2.2 String operations on ValueOperations and RedisTemplate (bit operations still not added)
This commit is contained in:
@@ -40,6 +40,9 @@ public interface BoundValueOperations<K, V> extends KeyBound<K> {
|
||||
|
||||
Integer append(String value);
|
||||
|
||||
String substract(int start, int end);
|
||||
String get(int start, int end);
|
||||
|
||||
void set(int start, int end);
|
||||
|
||||
Long size();
|
||||
}
|
||||
|
||||
@@ -56,8 +56,8 @@ class DefaultBoundValueOperations<K, V> extends DefaultKeyBound<K> implements Bo
|
||||
}
|
||||
|
||||
@Override
|
||||
public String substract(int start, int end) {
|
||||
return ops.substract(getKey(), start, end);
|
||||
public String get(int start, int end) {
|
||||
return ops.get(getKey(), start, end);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -75,6 +75,16 @@ class DefaultBoundValueOperations<K, V> extends DefaultKeyBound<K> implements Bo
|
||||
return ops.setIfAbsent(getKey(), value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void set(int start, int end) {
|
||||
ops.set(getKey(), start, end);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long size() {
|
||||
return ops.size(getKey());
|
||||
}
|
||||
|
||||
@Override
|
||||
public RedisOperations<K, V> getOperations() {
|
||||
return ops.getOperations();
|
||||
|
||||
@@ -212,7 +212,7 @@ public class RedisTemplate<K, V> extends RedisAccessor implements RedisOperation
|
||||
* Sets the string value serializer to be used by this template (when the arguments or return types
|
||||
* are always strings). Defaults to {@link StringRedisSerializer}.
|
||||
*
|
||||
* @see ValueOperations#substract(Object, int, int)
|
||||
* @see ValueOperations#get(Object, int, int)
|
||||
* @param stringSerializer The stringValueSerializer to set.
|
||||
*/
|
||||
public void setStringSerializer(RedisSerializer<String> stringSerializer) {
|
||||
@@ -713,7 +713,7 @@ public class RedisTemplate<K, V> extends RedisAccessor implements RedisOperation
|
||||
}
|
||||
|
||||
@Override
|
||||
public String substract(K key, final int start, final int end) {
|
||||
public String get(K key, final int start, final int end) {
|
||||
final byte[] rawKey = rawKey(key);
|
||||
|
||||
byte[] rawReturn = execute(new RedisCallback<byte[]>() {
|
||||
@@ -831,6 +831,32 @@ public class RedisTemplate<K, V> extends RedisAccessor implements RedisOperation
|
||||
}, true);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void set(K key, final int start, final int end) {
|
||||
final byte[] rawKey = rawKey(key);
|
||||
|
||||
execute(new RedisCallback<Object>() {
|
||||
@Override
|
||||
public Object doInRedis(RedisConnection connection) {
|
||||
connection.setRange(rawKey, start, end);
|
||||
return null;
|
||||
}
|
||||
}, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long size(K key) {
|
||||
final byte[] rawKey = rawKey(key);
|
||||
|
||||
return execute(new RedisCallback<Long>() {
|
||||
@Override
|
||||
public Long doInRedis(RedisConnection connection) {
|
||||
return connection.strLen(rawKey);
|
||||
}
|
||||
}, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public RedisOperations<K, V> getOperations() {
|
||||
return RedisTemplate.this;
|
||||
|
||||
@@ -46,7 +46,11 @@ public interface ValueOperations<K, V> {
|
||||
|
||||
Integer append(K key, String value);
|
||||
|
||||
String substract(K key, int start, int end);
|
||||
String get(K key, int start, int end);
|
||||
|
||||
void set(K key, int start, int end);
|
||||
|
||||
Long size(K key);
|
||||
|
||||
RedisOperations<K, V> getOperations();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user