+ add pop to set operations

This commit is contained in:
Costin Leau
2010-12-08 22:39:53 +02:00
parent 69fb3a996b
commit 48d31da0fd
4 changed files with 19 additions and 0 deletions

View File

@@ -48,5 +48,7 @@ public interface BoundSetOperations<K, V> extends KeyBound<K> {
Boolean remove(Object o);
V pop();
Long size();
}

View File

@@ -85,6 +85,11 @@ class DefaultBoundSetOperations<K, V> extends DefaultKeyBound<K> implements Boun
return ops.remove(getKey(), o);
}
@Override
public V pop() {
return ops.pop(getKey());
}
@Override
public Long size() {
return ops.size(getKey());

View File

@@ -1053,6 +1053,16 @@ public class RedisTemplate<K, V> extends RedisAccessor implements RedisOperation
}, true);
}
@Override
public V pop(K key) {
return execute(new ValueDeserializingRedisCallback(key) {
@Override
protected byte[] inRedis(byte[] rawKey, RedisConnection connection) {
return connection.sPop(rawKey);
}
}, true);
}
@Override
public Long size(K key) {
final byte[] rawKey = rawKey(key);

View File

@@ -46,6 +46,8 @@ public interface SetOperations<K, V> {
Boolean remove(K key, Object o);
V pop(K key);
Long size(K key);
RedisOperations<K, V> getOperations();