RLexSortedSet object introduced. #135

pull/255/head
Nikita 10 years ago
parent 3ab7e1afc8
commit 1bfc3a7a13

@ -33,6 +33,8 @@ import io.netty.util.concurrent.Future;
//TODO ping support
public interface CommandExecutor {
<T, R> R read(RedisClient client, String key, Codec codec, RedisCommand<T> command, Object ... params);
<T, R> R read(RedisClient client, String key, RedisCommand<T> command, Object ... params);
<T, R> Future<R> evalWriteAllAsync(RedisCommand<T> command, SlotCallback<T, R> callback, String script, List<Object> keys, Object ... params);

@ -201,6 +201,12 @@ public class CommandExecutorService implements CommandExecutor {
return get(res);
}
public <T, R> R read(RedisClient client, String key, Codec codec, RedisCommand<T> command, Object ... params) {
Future<R> res = readAsync(client, key, codec, command, params);
return get(res);
}
public <T, R> Future<R> readAsync(RedisClient client, String key, Codec codec, RedisCommand<T> command, Object ... params) {
Promise<R> mainPromise = connectionManager.newPromise();
int slot = connectionManager.calcSlot(key);

@ -39,6 +39,7 @@ import org.redisson.core.RCountDownLatch;
import org.redisson.core.RDeque;
import org.redisson.core.RHyperLogLog;
import org.redisson.core.RKeys;
import org.redisson.core.RLexSortedSet;
import org.redisson.core.RList;
import org.redisson.core.RLock;
import org.redisson.core.RMap;
@ -221,6 +222,10 @@ public class Redisson implements RedissonClient {
return new RedissonScoredSortedSet<V>(commandExecutor, name);
}
public RLexSortedSet getLexSortedSet(String name) {
return new RedissonLexSortedSet(commandExecutor, name);
}
/**
* Returns topic instance by name.
*

@ -29,11 +29,13 @@ import org.redisson.core.RCountDownLatch;
import org.redisson.core.RDeque;
import org.redisson.core.RHyperLogLog;
import org.redisson.core.RKeys;
import org.redisson.core.RLexSortedSet;
import org.redisson.core.RList;
import org.redisson.core.RLock;
import org.redisson.core.RMap;
import org.redisson.core.RPatternTopic;
import org.redisson.core.RQueue;
import org.redisson.core.RScoredSortedSet;
import org.redisson.core.RScript;
import org.redisson.core.RSet;
import org.redisson.core.RSortedSet;
@ -104,6 +106,10 @@ public interface RedissonClient {
*/
<V> RSortedSet<V> getSortedSet(String name);
<V> RScoredSortedSet<V> getScoredSortedSet(String name);
RLexSortedSet getLexSortedSet(String name);
/**
* Returns topic instance by name.
*

@ -18,6 +18,7 @@ package org.redisson;
import java.util.Date;
import java.util.concurrent.TimeUnit;
import org.redisson.client.codec.Codec;
import org.redisson.client.codec.StringCodec;
import org.redisson.client.protocol.RedisCommands;
import org.redisson.core.RExpirable;
@ -30,6 +31,10 @@ abstract class RedissonExpirable extends RedissonObject implements RExpirable {
super(connectionManager, name);
}
RedissonExpirable(Codec codec, CommandExecutor connectionManager, String name) {
super(codec, connectionManager, name);
}
@Override
public boolean expire(long timeToLive, TimeUnit timeUnit) {
return commandExecutor.get(expireAsync(timeToLive, timeUnit));

@ -0,0 +1,142 @@
/**
* Copyright 2014 Nikita Koksharov, Nickolay Borbit
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.redisson;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import org.redisson.client.codec.StringCodec;
import org.redisson.client.protocol.RedisCommands;
import org.redisson.core.RLexSortedSet;
import io.netty.util.concurrent.Future;
public class RedissonLexSortedSet extends RedissonScoredSortedSet<String> implements RLexSortedSet {
public RedissonLexSortedSet(CommandExecutor commandExecutor, String name) {
super(StringCodec.INSTANCE, commandExecutor, name);
}
@Override
public Collection<String> lexRange(String fromElement, boolean fromInclusive, String toElement, boolean toInclusive) {
return get(lexRangeAsync(fromElement, fromInclusive, toElement, toInclusive));
}
@Override
public Collection<String> lexRangeHead(String toElement, boolean toInclusive) {
return get(lexRangeHeadAsync(toElement, toInclusive));
}
@Override
public Future<Collection<String>> lexRangeHeadAsync(String toElement, boolean toInclusive) {
String toValue = value(toElement, toInclusive);
return commandExecutor.readAsync(getName(), StringCodec.INSTANCE, RedisCommands.ZRANGEBYLEX, getName(), "-", toValue);
}
@Override
public Collection<String> lexRangeTail(String fromElement, boolean fromInclusive) {
return get(lexRangeTailAsync(fromElement, fromInclusive));
}
@Override
public Future<Collection<String>> lexRangeTailAsync(String fromElement, boolean fromInclusive) {
String fromValue = value(fromElement, fromInclusive);
return commandExecutor.readAsync(getName(), StringCodec.INSTANCE, RedisCommands.ZRANGEBYLEX, getName(), fromValue, "+");
}
@Override
public Future<Collection<String>> lexRangeAsync(String fromElement, boolean fromInclusive, String toElement, boolean toInclusive) {
String fromValue = value(fromElement, fromInclusive);
String toValue = value(toElement, toInclusive);
return commandExecutor.readAsync(getName(), StringCodec.INSTANCE, RedisCommands.ZRANGEBYLEX, getName(), fromValue, toValue);
}
@Override
public Integer lexCountTail(String fromElement, boolean fromInclusive) {
return get(lexCountTailAsync(fromElement, fromInclusive));
}
@Override
public Future<Integer> lexCountTailAsync(String fromElement, boolean fromInclusive) {
String fromValue = value(fromElement, fromInclusive);
return commandExecutor.readAsync(getName(), RedisCommands.ZLEXCOUNT, getName(), fromValue, "+");
}
@Override
public Integer lexCountHead(String toElement, boolean toInclusive) {
return get(lexCountHeadAsync(toElement, toInclusive));
}
@Override
public Future<Integer> lexCountHeadAsync(String toElement, boolean toInclusive) {
String toValue = value(toElement, toInclusive);
return commandExecutor.readAsync(getName(), RedisCommands.ZLEXCOUNT, getName(), "-", toValue);
}
@Override
public Integer lexCount(String fromElement, boolean fromInclusive, String toElement, boolean toInclusive) {
return get(lexCountAsync(fromElement, fromInclusive, toElement, toInclusive));
}
@Override
public Future<Integer> lexCountAsync(String fromElement, boolean fromInclusive, String toElement, boolean toInclusive) {
String fromValue = value(fromElement, fromInclusive);
String toValue = value(toElement, toInclusive);
return commandExecutor.readAsync(getName(), RedisCommands.ZLEXCOUNT, getName(), fromValue, toValue);
}
private String value(String fromElement, boolean fromInclusive) {
String fromValue = fromElement.toString();
if (fromInclusive) {
fromValue = "[" + fromValue;
} else {
fromValue = "(" + fromValue;
}
return fromValue;
}
@Override
public Future<Boolean> addAsync(String e) {
return addAsync(0, e);
}
@Override
public Future<Boolean> addAllAsync(Collection<? extends String> c) {
List<Object> params = new ArrayList<Object>(2*c.size());
for (Object param : c) {
params.add(0);
params.add(param);
}
return commandExecutor.writeAsync(getName(), codec, RedisCommands.ZADD, getName(), params.toArray());
}
@Override
public boolean add(String e) {
return get(addAsync(e));
}
@Override
public boolean addAll(Collection<? extends String> c) {
return get(addAllAsync(c));
}
}

@ -92,8 +92,7 @@ public class RedissonList<V> extends RedissonExpirable implements RList<V> {
return (List<V>) get(readAllAsync());
}
@Override
public Future<Collection<V>> readAllAsync() {
private Future<Collection<V>> readAllAsync() {
return commandExecutor.readAsync(getName(), LRANGE, getName(), 0, -1);
}

@ -15,6 +15,7 @@
*/
package org.redisson;
import org.redisson.client.codec.Codec;
import org.redisson.client.protocol.RedisCommands;
import org.redisson.core.RObject;
@ -31,10 +32,16 @@ abstract class RedissonObject implements RObject {
final CommandExecutor commandExecutor;
private final String name;
final Codec codec;
public RedissonObject(CommandExecutor commandExecutor, String name) {
this.commandExecutor = commandExecutor;
public RedissonObject(Codec codec, CommandExecutor commandExecutor, String name) {
this.codec = codec;
this.name = name;
this.commandExecutor = commandExecutor;
}
public RedissonObject(CommandExecutor commandExecutor, String name) {
this(commandExecutor.getConnectionManager().getCodec(), commandExecutor, name);
}
protected <V> V get(Future<V> future) {

@ -23,6 +23,7 @@ import java.util.List;
import java.util.NoSuchElementException;
import org.redisson.client.RedisClient;
import org.redisson.client.codec.Codec;
import org.redisson.client.codec.StringCodec;
import org.redisson.client.protocol.RedisCommand;
import org.redisson.client.protocol.RedisCommands;
@ -39,6 +40,10 @@ public class RedissonScoredSortedSet<V> extends RedissonExpirable implements RSc
super(commandExecutor, name);
}
public RedissonScoredSortedSet(Codec codec, CommandExecutor commandExecutor, String name) {
super(codec, commandExecutor, name);
}
@Override
public boolean add(double score, V object) {
return get(addAsync(score, object));
@ -46,11 +51,7 @@ public class RedissonScoredSortedSet<V> extends RedissonExpirable implements RSc
@Override
public Future<Boolean> addAsync(double score, V object) {
// String should be encoded as String to let lex functions work properly
if (object instanceof String) {
return commandExecutor.writeAsync(getName(), StringCodec.INSTANCE, RedisCommands.ZADD, getName(), BigDecimal.valueOf(score).toPlainString(), object);
}
return commandExecutor.writeAsync(getName(), RedisCommands.ZADD, getName(), BigDecimal.valueOf(score).toPlainString(), object);
return commandExecutor.writeAsync(getName(), codec, RedisCommands.ZADD, getName(), BigDecimal.valueOf(score).toPlainString(), object);
}
@Override
@ -65,7 +66,7 @@ public class RedissonScoredSortedSet<V> extends RedissonExpirable implements RSc
@Override
public Future<Boolean> removeAsync(Object object) {
return commandExecutor.writeAsync(getName(), RedisCommands.ZREM, getName(), object);
return commandExecutor.writeAsync(getName(), codec, RedisCommands.ZREM, getName(), object);
}
@Override
@ -80,7 +81,7 @@ public class RedissonScoredSortedSet<V> extends RedissonExpirable implements RSc
@Override
public Future<Integer> sizeAsync() {
return commandExecutor.readAsync(getName(), RedisCommands.ZCARD, getName());
return commandExecutor.readAsync(getName(), codec, RedisCommands.ZCARD, getName());
}
@Override
@ -90,7 +91,7 @@ public class RedissonScoredSortedSet<V> extends RedissonExpirable implements RSc
@Override
public Future<Boolean> containsAsync(Object o) {
return commandExecutor.readAsync(getName(), RedisCommands.ZSCORE_CONTAINS, getName(), o);
return commandExecutor.readAsync(getName(), codec, RedisCommands.ZSCORE_CONTAINS, getName(), o);
}
@Override
@ -100,7 +101,7 @@ public class RedissonScoredSortedSet<V> extends RedissonExpirable implements RSc
@Override
public Future<Double> getScoreAsync(V o) {
return commandExecutor.readAsync(getName(), RedisCommands.ZSCORE, getName(), o);
return commandExecutor.readAsync(getName(), codec, RedisCommands.ZSCORE, getName(), o);
}
@Override
@ -110,11 +111,11 @@ public class RedissonScoredSortedSet<V> extends RedissonExpirable implements RSc
@Override
public Future<Integer> rankAsync(V o) {
return commandExecutor.readAsync(getName(), RedisCommands.ZRANK, getName(), o);
return commandExecutor.readAsync(getName(), codec, RedisCommands.ZRANK, getName(), o);
}
private ListScanResult<V> scanIterator(RedisClient client, long startPos) {
return commandExecutor.read(client, getName(), RedisCommands.ZSCAN, getName(), startPos);
return commandExecutor.read(client, getName(), codec, RedisCommands.ZSCAN, getName(), startPos);
}
@Override
@ -187,7 +188,7 @@ public class RedissonScoredSortedSet<V> extends RedissonExpirable implements RSc
@Override
public Future<Boolean> containsAllAsync(Collection<?> c) {
return commandExecutor.evalReadAsync(getName(), new RedisCommand<Boolean>("EVAL", new BooleanReplayConvertor(), 4),
return commandExecutor.evalReadAsync(getName(), codec, new RedisCommand<Boolean>("EVAL", new BooleanReplayConvertor(), 4),
"local s = redis.call('zrange', KEYS[1], 0, -1);" +
"for i = 0, table.getn(s), 1 do " +
"for j = 0, table.getn(ARGV), 1 do "
@ -201,7 +202,7 @@ public class RedissonScoredSortedSet<V> extends RedissonExpirable implements RSc
@Override
public Future<Boolean> removeAllAsync(Collection<?> c) {
return commandExecutor.evalWriteAsync(getName(), new RedisCommand<Boolean>("EVAL", new BooleanReplayConvertor(), 4),
return commandExecutor.evalWriteAsync(getName(), codec, new RedisCommand<Boolean>("EVAL", new BooleanReplayConvertor(), 4),
"local v = false " +
"for i = 0, table.getn(ARGV), 1 do "
+ "if redis.call('zrem', KEYS[1], ARGV[i]) == 1 "
@ -223,7 +224,7 @@ public class RedissonScoredSortedSet<V> extends RedissonExpirable implements RSc
@Override
public Future<Boolean> retainAllAsync(Collection<?> c) {
return commandExecutor.evalWriteAsync(getName(), new RedisCommand<Boolean>("EVAL", new BooleanReplayConvertor(), 4),
return commandExecutor.evalWriteAsync(getName(), codec, new RedisCommand<Boolean>("EVAL", new BooleanReplayConvertor(), 4),
"local changed = false " +
"local s = redis.call('zrange', KEYS[1], 0, -1) "
+ "local i = 0 "
@ -264,7 +265,7 @@ public class RedissonScoredSortedSet<V> extends RedissonExpirable implements RSc
@Override
public Future<Collection<V>> valueRangeAsync(int startIndex, int endIndex) {
return commandExecutor.readAsync(getName(), RedisCommands.ZRANGE, getName(), startIndex, endIndex);
return commandExecutor.readAsync(getName(), codec, RedisCommands.ZRANGE, getName(), startIndex, endIndex);
}
@Override
@ -274,90 +275,7 @@ public class RedissonScoredSortedSet<V> extends RedissonExpirable implements RSc
@Override
public Future<Collection<ScoredEntry<V>>> entryRangeAsync(int startIndex, int endIndex) {
return commandExecutor.readAsync(getName(), RedisCommands.ZRANGE_ENTRY, getName(), startIndex, endIndex, "WITHSCORES");
}
@Override
public Collection<V> lexRange(V fromElement, boolean fromInclusive, V toElement, boolean toInclusive) {
return get(lexRangeAsync(fromElement, fromInclusive, toElement, toInclusive));
}
@Override
public Collection<V> lexRangeHead(V toElement, boolean toInclusive) {
return get(lexRangeHeadAsync(toElement, toInclusive));
}
@Override
public Future<Collection<V>> lexRangeHeadAsync(V toElement, boolean toInclusive) {
String toValue = value(toElement, toInclusive);
return commandExecutor.readAsync(getName(), StringCodec.INSTANCE, RedisCommands.ZRANGEBYLEX, getName(), "-", toValue);
}
@Override
public Collection<V> lexRangeTail(V fromElement, boolean fromInclusive) {
return get(lexRangeTailAsync(fromElement, fromInclusive));
}
@Override
public Future<Collection<V>> lexRangeTailAsync(V fromElement, boolean fromInclusive) {
String fromValue = value(fromElement, fromInclusive);
return commandExecutor.readAsync(getName(), StringCodec.INSTANCE, RedisCommands.ZRANGEBYLEX, getName(), fromValue, "+");
}
@Override
public Future<Collection<V>> lexRangeAsync(V fromElement, boolean fromInclusive, V toElement, boolean toInclusive) {
String fromValue = value(fromElement, fromInclusive);
String toValue = value(toElement, toInclusive);
return commandExecutor.readAsync(getName(), StringCodec.INSTANCE, RedisCommands.ZRANGEBYLEX, getName(), fromValue, toValue);
}
@Override
public Integer lexCountTail(V fromElement, boolean fromInclusive) {
return get(lexCountTailAsync(fromElement, fromInclusive));
}
@Override
public Future<Integer> lexCountTailAsync(V fromElement, boolean fromInclusive) {
String fromValue = value(fromElement, fromInclusive);
return commandExecutor.readAsync(getName(), RedisCommands.ZLEXCOUNT, getName(), fromValue, "+");
}
@Override
public Integer lexCountHead(V toElement, boolean toInclusive) {
return get(lexCountHeadAsync(toElement, toInclusive));
}
@Override
public Future<Integer> lexCountHeadAsync(V toElement, boolean toInclusive) {
String toValue = value(toElement, toInclusive);
return commandExecutor.readAsync(getName(), RedisCommands.ZLEXCOUNT, getName(), "-", toValue);
}
@Override
public Integer lexCount(V fromElement, boolean fromInclusive, V toElement, boolean toInclusive) {
return get(lexCountAsync(fromElement, fromInclusive, toElement, toInclusive));
}
@Override
public Future<Integer> lexCountAsync(V fromElement, boolean fromInclusive, V toElement, boolean toInclusive) {
String fromValue = value(fromElement, fromInclusive);
String toValue = value(toElement, toInclusive);
return commandExecutor.readAsync(getName(), RedisCommands.ZLEXCOUNT, getName(), fromValue, toValue);
}
private String value(V fromElement, boolean fromInclusive) {
String fromValue = fromElement.toString();
if (fromInclusive) {
fromValue = "[" + fromValue;
} else {
fromValue = "(" + fromValue;
}
return fromValue;
return commandExecutor.readAsync(getName(), codec, RedisCommands.ZRANGE_ENTRY, getName(), startIndex, endIndex, "WITHSCORES");
}
}

@ -127,8 +127,7 @@ public class RedissonSet<V> extends RedissonExpirable implements RSet<V> {
};
}
@Override
public Future<Collection<V>> readAllAsync() {
private Future<Collection<V>> readAllAsync() {
return commandExecutor.readAsync(getName(), RedisCommands.SMEMBERS, getName());
}

@ -54,7 +54,7 @@ public interface RedisCommands {
RedisStrictCommand<Integer> ZLEXCOUNT = new RedisStrictCommand<Integer>("ZLEXCOUNT", new IntegerReplayConvertor());
RedisCommand<Boolean> ZSCORE_CONTAINS = new RedisCommand<Boolean>("ZSCORE", new BooleanNotNullReplayConvertor(), 2);
RedisStrictCommand<Double> ZSCORE = new RedisStrictCommand<Double>("ZSCORE", new DoubleReplayConvertor());
RedisStrictCommand<Integer> ZRANK = new RedisStrictCommand<Integer>("ZRANK", new IntegerReplayConvertor());
RedisCommand<Integer> ZRANK = new RedisCommand<Integer>("ZRANK", new IntegerReplayConvertor(), 2);
RedisCommand<List<Object>> ZRANGE = new RedisCommand<List<Object>>("ZRANGE", new ObjectListReplayDecoder<Object>());
RedisCommand<List<Object>> ZRANGEBYLEX = new RedisCommand<List<Object>>("ZRANGEBYLEX", new ObjectListReplayDecoder<Object>());
RedisCommand<List<ScoredEntry<Object>>> ZRANGE_ENTRY = new RedisCommand<List<ScoredEntry<Object>>>("ZRANGE", new ScoredSortedSetReplayDecoder<Object>());

@ -19,6 +19,9 @@ public class IntegerReplayConvertor extends SingleConvertor<Integer> {
@Override
public Integer convert(Object obj) {
if (obj == null) {
return null;
}
return ((Long) obj).intValue();
}

@ -31,8 +31,6 @@ public interface RCollectionAsync<V> extends RExpirableAsync {
Future<Boolean> removeAsync(Object o);
Future<Collection<V>> readAllAsync();
Future<Integer> sizeAsync();
Future<Boolean> addAsync(V e);

@ -0,0 +1,39 @@
/**
* Copyright 2014 Nikita Koksharov, Nickolay Borbit
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.redisson.core;
import java.util.Collection;
import java.util.Set;
public interface RLexSortedSet extends RLexSortedSetAsync, Set<String>, RExpirable {
Integer lexCountTail(String fromElement, boolean fromInclusive);
Integer lexCountHead(String toElement, boolean toInclusive);
Collection<String> lexRangeTail(String fromElement, boolean fromInclusive);
Collection<String> lexRangeHead(String toElement, boolean toInclusive);
Collection<String> lexRange(String fromElement, boolean fromInclusive, String toElement, boolean toInclusive);
Integer lexCount(String fromElement, boolean fromInclusive, String toElement, boolean toInclusive);
Integer rank(String o);
Collection<String> valueRange(int startIndex, int endIndex);
}

@ -0,0 +1,40 @@
/**
* Copyright 2014 Nikita Koksharov, Nickolay Borbit
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.redisson.core;
import java.util.Collection;
import io.netty.util.concurrent.Future;
public interface RLexSortedSetAsync extends RCollectionAsync<String> {
Future<Integer> lexCountTailAsync(String fromElement, boolean fromInclusive);
Future<Integer> lexCountHeadAsync(String toElement, boolean toInclusive);
Future<Collection<String>> lexRangeTailAsync(String fromElement, boolean fromInclusive);
Future<Collection<String>> lexRangeHeadAsync(String toElement, boolean toInclusive);
Future<Collection<String>> lexRangeAsync(String fromElement, boolean fromInclusive, String toElement, boolean toInclusive);
Future<Integer> lexCountAsync(String fromElement, boolean fromInclusive, String toElement, boolean toInclusive);
Future<Integer> rankAsync(String o);
Future<Collection<String>> valueRangeAsync(int startIndex, int endIndex);
}

@ -21,18 +21,6 @@ import org.redisson.client.protocol.ScoredEntry;
public interface RScoredSortedSet<V> extends RScoredSortedSetAsync<V>, Iterable<V>, RExpirable {
Integer lexCountTail(V fromElement, boolean fromInclusive);
Integer lexCountHead(V toElement, boolean toInclusive);
Collection<V> lexRangeTail(V fromElement, boolean fromInclusive);
Collection<V> lexRangeHead(V toElement, boolean toInclusive);
Collection<V> lexRange(V fromElement, boolean fromInclusive, V toElement, boolean toInclusive);
Integer lexCount(V fromElement, boolean fromInclusive, V toElement, boolean toInclusive);
Integer rank(V o);
Double getScore(V o);

@ -23,18 +23,6 @@ import io.netty.util.concurrent.Future;
public interface RScoredSortedSetAsync<V> extends RExpirableAsync {
Future<Integer> lexCountTailAsync(V fromElement, boolean fromInclusive);
Future<Integer> lexCountHeadAsync(V toElement, boolean toInclusive);
Future<Collection<V>> lexRangeTailAsync(V fromElement, boolean fromInclusive);
Future<Collection<V>> lexRangeHeadAsync(V toElement, boolean toInclusive);
Future<Collection<V>> lexRangeAsync(V fromElement, boolean fromInclusive, V toElement, boolean toInclusive);
Future<Integer> lexCountAsync(V fromElement, boolean fromInclusive, V toElement, boolean toInclusive);
Future<Integer> rankAsync(V o);
Future<Double> getScoreAsync(V o);

@ -21,52 +21,6 @@ import io.netty.util.concurrent.Future;
public class RedissonScoredSortedSetTest extends BaseTest {
@Test
public void testLexRangeTail() {
RScoredSortedSet<String> set = redisson.getScoredSortedSet("simple");
set.add(0, "a");
set.add(0, "b");
set.add(0, "c");
set.add(0, "d");
set.add(0, "e");
set.add(0, "f");
set.add(0, "g");
MatcherAssert.assertThat(set.lexRangeTail("c", false), Matchers.contains("d", "e", "f", "g"));
MatcherAssert.assertThat(set.lexRangeTail("c", true), Matchers.contains("c", "d", "e", "f", "g"));
}
@Test
public void testLexRangeHead() {
RScoredSortedSet<String> set = redisson.getScoredSortedSet("simple");
set.add(0, "a");
set.add(0, "b");
set.add(0, "c");
set.add(0, "d");
set.add(0, "e");
set.add(0, "f");
set.add(0, "g");
MatcherAssert.assertThat(set.lexRangeHead("c", false), Matchers.contains("a", "b"));
MatcherAssert.assertThat(set.lexRangeHead("c", true), Matchers.contains("a", "b", "c"));
}
@Test
public void testLexRange() {
RScoredSortedSet<String> set = redisson.getScoredSortedSet("simple");
set.add(0, "a");
set.add(0, "b");
set.add(0, "c");
set.add(0, "d");
set.add(0, "e");
set.add(0, "f");
set.add(0, "g");
MatcherAssert.assertThat(set.lexRange("aaa", true, "g", false), Matchers.contains("b", "c", "d", "e", "f"));
}
@Test
public void testRank() {
RScoredSortedSet<String> set = redisson.getScoredSortedSet("simple");
@ -81,21 +35,6 @@ public class RedissonScoredSortedSetTest extends BaseTest {
Assert.assertEquals(3, (int)set.rank("d"));
}
@Test
public void testLexCount() {
RScoredSortedSet<String> set = redisson.getScoredSortedSet("simple");
set.add(0, "a");
set.add(0, "b");
set.add(0, "c");
set.add(0, "d");
set.add(0, "e");
set.add(0, "f");
set.add(0, "g");
Assert.assertEquals(5, (int)set.lexCount("b", true, "f", true));
Assert.assertEquals(3, (int)set.lexCount("b", false, "f", false));
}
@Test
public void testAddAsync() throws InterruptedException, ExecutionException {
RScoredSortedSet<Integer> set = redisson.getScoredSortedSet("simple");

Loading…
Cancel
Save