add rightPopLeftPush to list operations

This commit is contained in:
Costin Leau
2010-12-08 22:34:25 +02:00
parent 2a397015d2
commit 69fb3a996b
2 changed files with 13 additions and 1 deletions

View File

@@ -49,7 +49,7 @@ public interface ListOperations<K, V> {
V rightPop(K key, long timeout, TimeUnit unit);
void rightPopAndLeftPush(K sourceKey, K destinationKey);
V rightPopAndLeftPush(K sourceKey, K destinationKey);
RedisOperations<K, V> getOperations();
}

View File

@@ -890,6 +890,18 @@ public class RedisTemplate<K, V> extends RedisAccessor implements RedisOperation
}, true);
}
@Override
public V rightPopAndLeftPush(K sourceKey, K destinationKey) {
final byte[] rawDestKey = rawKey(destinationKey);
return execute(new ValueDeserializingRedisCallback(sourceKey) {
@Override
protected byte[] inRedis(byte[] rawSourceKey, RedisConnection connection) {
return connection.rPopLPush(rawSourceKey, rawDestKey);
}
}, true);
}
@Override
public void set(K key, final long index, V value) {
final byte[] rawValue = rawValue(value);