+ add pop to set operations
This commit is contained in:
@@ -48,5 +48,7 @@ public interface BoundSetOperations<K, V> extends KeyBound<K> {
|
||||
|
||||
Boolean remove(Object o);
|
||||
|
||||
V pop();
|
||||
|
||||
Long size();
|
||||
}
|
||||
|
||||
@@ -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());
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user