Distributed and concurrent implementation of java.util.Set @author Nikita Koksharov @param value
| 48 | * @param <V> value |
| 49 | */ |
| 50 | public class RedissonSet<V> extends RedissonExpirable implements RSet<V>, ScanIterator { |
| 51 | |
| 52 | RedissonClient redisson; |
| 53 | |
| 54 | public RedissonSet(CommandAsyncExecutor commandExecutor, String name, RedissonClient redisson) { |
| 55 | super(commandExecutor, name); |
| 56 | this.redisson = redisson; |
| 57 | } |
| 58 | |
| 59 | public RedissonSet(Codec codec, CommandAsyncExecutor commandExecutor, String name, RedissonClient redisson) { |
| 60 | super(codec, commandExecutor, name); |
| 61 | this.redisson = redisson; |
| 62 | } |
| 63 | |
| 64 | @Override |
| 65 | public <KOut, VOut> RCollectionMapReduce<V, KOut, VOut> mapReduce() { |
| 66 | return new RedissonCollectionMapReduce<V, KOut, VOut>(this, redisson, commandExecutor); |
| 67 | } |
| 68 | |
| 69 | @Override |
| 70 | public int size() { |
| 71 | return get(sizeAsync()); |
| 72 | } |
| 73 | |
| 74 | @Override |
| 75 | public RFuture<Integer> sizeAsync() { |
| 76 | return commandExecutor.readAsync(getRawName(), codec, RedisCommands.SCARD_INT, getRawName()); |
| 77 | } |
| 78 | |
| 79 | @Override |
| 80 | public boolean isEmpty() { |
| 81 | return size() == 0; |
| 82 | } |
| 83 | |
| 84 | @Override |
| 85 | public boolean contains(Object o) { |
| 86 | return get(containsAsync(o)); |
| 87 | } |
| 88 | |
| 89 | @Override |
| 90 | public RFuture<Boolean> containsAsync(Object o) { |
| 91 | String name = getRawName(o); |
| 92 | return commandExecutor.readAsync(name, codec, RedisCommands.SISMEMBER, name, encode(o)); |
| 93 | } |
| 94 | |
| 95 | @Override |
| 96 | public ScanResult<Object> scanIterator(String name, RedisClient client, String startPos, String pattern, int count) { |
| 97 | return get(scanIteratorAsync(name, client, startPos, pattern, count)); |
| 98 | } |
| 99 | |
| 100 | @Override |
| 101 | public Iterator<V> iterator(int count) { |
| 102 | return iterator(null, count); |
| 103 | } |
| 104 | |
| 105 | @Override |
| 106 | public Iterator<V> iterator(String pattern) { |
| 107 | return iterator(pattern, 10); |
nothing calls this directly
no outgoing calls
no test coverage detected
searching dependent graphs…