Revert "Merge branch 'mrniko/master' into feature/travis-ci"

This reverts commit 290362246a, reversing
changes made to d8189a1338.
pull/509/head
Rui Gu 9 years ago
parent 290362246a
commit 1e27329ff1

@ -47,7 +47,6 @@ import org.redisson.core.RBlockingDeque;
import org.redisson.core.RBlockingQueue;
import org.redisson.core.RBloomFilter;
import org.redisson.core.RBucket;
import org.redisson.core.RBuckets;
import org.redisson.core.RCountDownLatch;
import org.redisson.core.RDeque;
import org.redisson.core.RGeo;
@ -203,16 +202,6 @@ public class Redisson implements RedissonClient {
return new RedissonBucket<V>(codec, commandExecutor, name);
}
@Override
public RBuckets getBuckets() {
return new RedissonBuckets(this, commandExecutor);
}
@Override
public RBuckets getBuckets(Codec codec) {
return new RedissonBuckets(this, codec, commandExecutor);
}
@Override
public <V> List<RBucket<V>> findBuckets(String pattern) {
Collection<String> keys = commandExecutor.get(commandExecutor.<List<String>, String>readAllAsync(RedisCommands.KEYS, pattern));
@ -271,6 +260,11 @@ public class Redisson implements RedissonClient {
commandExecutor.write(params.get(0).toString(), RedisCommands.MSET, params.toArray());
}
@Override
public <V> List<RBucket<V>> getBuckets(String pattern) {
return findBuckets(pattern);
}
@Override
public <V> RHyperLogLog<V> getHyperLogLog(String name) {
return new RedissonHyperLogLog<V>(commandExecutor, name);
@ -543,6 +537,16 @@ public class Redisson implements RedissonClient {
return new RedisNodes<ClusterNode>(connectionManager);
}
@Override
public void flushdb() {
commandExecutor.get(commandExecutor.writeAllAsync(RedisCommands.FLUSHDB));
}
@Override
public void flushall() {
commandExecutor.get(commandExecutor.writeAllAsync(RedisCommands.FLUSHALL));
}
@Override
public boolean isShutdown() {
return connectionManager.isShutdown();

@ -1,118 +0,0 @@
/**
* 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.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import org.redisson.client.codec.Codec;
import org.redisson.client.codec.DelegateDecoderCodec;
import org.redisson.client.protocol.RedisCommand;
import org.redisson.client.protocol.RedisCommand.ValueType;
import org.redisson.client.protocol.RedisCommands;
import org.redisson.command.CommandExecutor;
import org.redisson.connection.decoder.MapGetAllDecoder;
import org.redisson.core.RBucket;
import org.redisson.core.RBuckets;
import io.netty.util.concurrent.Future;
public class RedissonBuckets implements RBuckets {
private final Codec codec;
private final CommandExecutor commandExecutor;
private final Redisson redisson;
public RedissonBuckets(Redisson redisson, CommandExecutor commandExecutor) {
this(redisson, commandExecutor.getConnectionManager().getCodec(), commandExecutor);
}
public RedissonBuckets(Redisson redisson, Codec codec, CommandExecutor commandExecutor) {
super();
this.codec = codec;
this.commandExecutor = commandExecutor;
this.redisson = redisson;
}
@Override
public <V> List<RBucket<V>> find(String pattern) {
Collection<String> keys = commandExecutor.get(commandExecutor.<List<String>, String>readAllAsync(RedisCommands.KEYS, pattern));
List<RBucket<V>> buckets = new ArrayList<RBucket<V>>(keys.size());
for (String key : keys) {
if(key == null) {
continue;
}
buckets.add(redisson.<V>getBucket(key, codec));
}
return buckets;
}
@Override
public <V> Map<String, V> get(String... keys) {
if (keys.length == 0) {
return Collections.emptyMap();
}
RedisCommand<Map<Object, Object>> command = new RedisCommand<Map<Object, Object>>("MGET", new MapGetAllDecoder(Arrays.asList(keys), 0), ValueType.OBJECTS);
Future<Map<String, V>> future = commandExecutor.readAsync(keys[0], new DelegateDecoderCodec(codec), command, keys);
return commandExecutor.get(future);
}
@Override
public boolean trySet(Map<String, ?> buckets) {
if (buckets.isEmpty()) {
return false;
}
List<Object> params = new ArrayList<Object>(buckets.size());
for (Entry<String, ?> entry : buckets.entrySet()) {
params.add(entry.getKey());
try {
params.add(codec.getValueEncoder().encode(entry.getValue()));
} catch (IOException e) {
throw new IllegalArgumentException(e);
}
}
return commandExecutor.write(params.get(0).toString(), RedisCommands.MSETNX, params.toArray());
}
@Override
public void set(Map<String, ?> buckets) {
if (buckets.isEmpty()) {
return;
}
List<Object> params = new ArrayList<Object>(buckets.size());
for (Entry<String, ?> entry : buckets.entrySet()) {
params.add(entry.getKey());
try {
params.add(codec.getValueEncoder().encode(entry.getValue()));
} catch (IOException e) {
throw new IllegalArgumentException(e);
}
}
commandExecutor.write(params.get(0).toString(), RedisCommands.MSET, params.toArray());
}
}

@ -31,7 +31,6 @@ import org.redisson.core.RBlockingDeque;
import org.redisson.core.RBlockingQueue;
import org.redisson.core.RBloomFilter;
import org.redisson.core.RBucket;
import org.redisson.core.RBuckets;
import org.redisson.core.RCountDownLatch;
import org.redisson.core.RDeque;
import org.redisson.core.RGeo;
@ -152,43 +151,57 @@ public interface RedissonClient {
<V> RBucket<V> getBucket(String name, Codec codec);
/**
* Returns interface for mass operations with Bucket objects.
* <p>Returns a list of object holder instances by a key pattern.
*
* <pre>Supported glob-style patterns:
* h?llo subscribes to hello, hallo and hxllo
* h*llo subscribes to hllo and heeeello
* h[ae]llo subscribes to hello and hallo, but not hillo
* h[^e]llo matches hallo, hbllo, ... but not hello
* h[a-b]llo matches hallo and hbllo</pre>
* <p>Use \ to escape special characters if you want to match them verbatim.
*
* <p>Uses <code>KEYS</code> Redis command.
*
* @param pattern
* @return
*/
RBuckets getBuckets();
<V> List<RBucket<V>> findBuckets(String pattern);
/**
* Returns interface for mass operations with Bucket objects
* using provided codec for object.
* <p>Returns Redis object mapped by key. Result Map is not contains
* key-value entry for null values.
*
* <p>Uses <code>MGET</code> Redis command.
*
* @param keys
* @return
*/
RBuckets getBuckets(Codec codec);
/**
* Use {@link RBuckets#find(String)}
*/
@Deprecated
<V> List<RBucket<V>> findBuckets(String pattern);
<V> Map<String, V> loadBucketValues(Collection<String> keys);
/**
* Use {@link RBuckets#get(String...)}
* <p>Returns Redis object mapped by key. Result Map is not contains
* key-value entry for null values.
*
* <p>Uses <code>MGET</code> Redis command.
*
* @param keys
* @return
*/
@Deprecated
<V> Map<String, V> loadBucketValues(Collection<String> keys);
<V> Map<String, V> loadBucketValues(String ... keys);
/**
* Use {@link RBuckets#get(String...)}
* Saves Redis object mapped by key.
*
* @param buckets
*/
@Deprecated
<V> Map<String, V> loadBucketValues(String ... keys);
void saveBuckets(Map<String, ?> buckets);
/**
* Use {@link RBuckets#set(Map)}
* Use {@link #findBuckets(String)}
*/
@Deprecated
void saveBuckets(Map<String, ?> buckets);
<V> List<RBucket<V>> getBuckets(String pattern);
/**
* Returns HyperLogLog instance by name.
@ -645,6 +658,18 @@ public interface RedissonClient {
*/
NodesGroup<ClusterNode> getClusterNodesGroup();
/**
* Use {@link RKeys#flushdb()}
*/
@Deprecated
void flushdb();
/**
* Use {@link RKeys#flushall()}
*/
@Deprecated
void flushall();
/**
* Returns {@code true} if this Redisson instance has been shut down.
*

@ -104,7 +104,7 @@ public class RedissonGeo<V> extends RedissonExpirable implements RGeo<V> {
List<Object> params = new ArrayList<Object>(members.length + 1);
params.add(getName());
params.addAll(Arrays.asList(members));
RedisCommand<Map<Object, Object>> command = new RedisCommand<Map<Object, Object>>("GEOHASH", new MapGetAllDecoder(params, 1), 2, ValueType.OBJECTS);
RedisCommand<Map<Object, Object>> command = new RedisCommand<Map<Object, Object>>("GEOHASH", new MapGetAllDecoder(params), 2, ValueType.OBJECTS);
return commandExecutor.readAsync(getName(), new ScoredCodec(codec), command, params.toArray());
}

@ -32,64 +32,33 @@ public class RedissonLexSortedSet extends RedissonScoredSortedSet<String> implem
super(StringCodec.INSTANCE, commandExecutor, name);
}
@Override
public int removeRange(String fromElement, boolean fromInclusive, String toElement, boolean toInclusive) {
return removeRangeByLex(fromElement, fromInclusive, toElement, toInclusive);
}
@Override
public int removeRangeByLex(String fromElement, boolean fromInclusive, String toElement, boolean toInclusive) {
return get(removeRangeAsync(fromElement, fromInclusive, toElement, toInclusive));
return get(removeRangeByLexAsync(fromElement, fromInclusive, toElement, toInclusive));
}
@Override
public int removeRangeHead(String toElement, boolean toInclusive) {
return removeRangeHeadByLex(toElement, toInclusive);
}
@Override
public int removeRangeHeadByLex(String toElement, boolean toInclusive) {
return get(removeRangeHeadAsync(toElement, toInclusive));
return get(removeRangeHeadByLexAsync(toElement, toInclusive));
}
@Override
public Future<Integer> removeRangeHeadAsync(String toElement, boolean toInclusive) {
return removeRangeHeadByLexAsync(toElement, toInclusive);
}
@Override
public Future<Integer> removeRangeHeadByLexAsync(String toElement, boolean toInclusive) {
String toValue = value(toElement, toInclusive);
return commandExecutor.writeAsync(getName(), StringCodec.INSTANCE, RedisCommands.ZREMRANGEBYLEX, getName(), "-", toValue);
}
@Override
public int removeRangeTail(String fromElement, boolean fromInclusive) {
return removeRangeTailByLex(fromElement, fromInclusive);
}
@Override
public int removeRangeTailByLex(String fromElement, boolean fromInclusive) {
return get(removeRangeTailAsync(fromElement, fromInclusive));
return get(removeRangeTailByLexAsync(fromElement, fromInclusive));
}
@Override
public Future<Integer> removeRangeTailAsync(String fromElement, boolean fromInclusive) {
return removeRangeTailByLexAsync(fromElement, fromInclusive);
}
@Override
public Future<Integer> removeRangeTailByLexAsync(String fromElement, boolean fromInclusive) {
String fromValue = value(fromElement, fromInclusive);
return commandExecutor.writeAsync(getName(), StringCodec.INSTANCE, RedisCommands.ZREMRANGEBYLEX, getName(), fromValue, "+");
}
@Override
public Future<Integer> removeRangeAsync(String fromElement, boolean fromInclusive, String toElement,
boolean toInclusive) {
return removeRangeByLexAsync(fromElement, fromInclusive, toElement, toInclusive);
}
@Override
public Future<Integer> removeRangeByLexAsync(String fromElement, boolean fromInclusive, String toElement, boolean toInclusive) {
String fromValue = value(fromElement, fromInclusive);
@ -98,63 +67,33 @@ public class RedissonLexSortedSet extends RedissonScoredSortedSet<String> implem
return commandExecutor.writeAsync(getName(), StringCodec.INSTANCE, RedisCommands.ZREMRANGEBYLEX, getName(), fromValue, toValue);
}
@Override
public Collection<String> range(String fromElement, boolean fromInclusive, String toElement, boolean toInclusive) {
return lexRange(fromElement, fromInclusive, toElement, toInclusive);
}
@Override
public Collection<String> lexRange(String fromElement, boolean fromInclusive, String toElement, boolean toInclusive) {
return get(rangeAsync(fromElement, fromInclusive, toElement, toInclusive));
return get(lexRangeAsync(fromElement, fromInclusive, toElement, toInclusive));
}
@Override
public Collection<String> rangeHead(String toElement, boolean toInclusive) {
return lexRangeHead(toElement, toInclusive);
}
@Override
public Collection<String> lexRangeHead(String toElement, boolean toInclusive) {
return get(rangeHeadAsync(toElement, toInclusive));
return get(lexRangeHeadAsync(toElement, toInclusive));
}
@Override
public Future<Collection<String>> rangeHeadAsync(String toElement, boolean toInclusive) {
return 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> rangeTail(String fromElement, boolean fromInclusive) {
return lexRangeTail(fromElement, fromInclusive);
}
@Override
public Collection<String> lexRangeTail(String fromElement, boolean fromInclusive) {
return get(rangeTailAsync(fromElement, fromInclusive));
return get(lexRangeTailAsync(fromElement, fromInclusive));
}
@Override
public Future<Collection<String>> rangeTailAsync(String fromElement, boolean fromInclusive) {
return 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>> rangeAsync(String fromElement, boolean fromInclusive, String toElement,
boolean toInclusive) {
return lexRangeAsync(fromElement, fromInclusive, toElement, toInclusive);
}
@Override
public Future<Collection<String>> lexRangeAsync(String fromElement, boolean fromInclusive, String toElement, boolean toInclusive) {
@ -164,65 +103,33 @@ public class RedissonLexSortedSet extends RedissonScoredSortedSet<String> implem
return commandExecutor.readAsync(getName(), StringCodec.INSTANCE, RedisCommands.ZRANGEBYLEX, getName(), fromValue, toValue);
}
@Override
public Collection<String> range(String fromElement, boolean fromInclusive, String toElement, boolean toInclusive,
int offset, int count) {
return lexRange(fromElement, fromInclusive, toElement, toInclusive, offset, count);
}
@Override
public Collection<String> lexRange(String fromElement, boolean fromInclusive, String toElement, boolean toInclusive, int offset, int count) {
return get(rangeAsync(fromElement, fromInclusive, toElement, toInclusive, offset, count));
return get(lexRangeAsync(fromElement, fromInclusive, toElement, toInclusive, offset, count));
}
@Override
public Collection<String> rangeHead(String toElement, boolean toInclusive, int offset, int count) {
return lexRangeHead(toElement, toInclusive, offset, count);
}
@Override
public Collection<String> lexRangeHead(String toElement, boolean toInclusive, int offset, int count) {
return get(rangeHeadAsync(toElement, toInclusive, offset, count));
return get(lexRangeHeadAsync(toElement, toInclusive, offset, count));
}
@Override
public Future<Collection<String>> rangeHeadAsync(String toElement, boolean toInclusive, int offset, int count) {
return lexRangeHeadAsync(toElement, toInclusive, offset, count);
}
@Override
public Future<Collection<String>> lexRangeHeadAsync(String toElement, boolean toInclusive, int offset, int count) {
String toValue = value(toElement, toInclusive);
return commandExecutor.readAsync(getName(), StringCodec.INSTANCE, RedisCommands.ZRANGEBYLEX, getName(), "-", toValue, "LIMIT", offset, count);
}
@Override
public Collection<String> rangeTail(String fromElement, boolean fromInclusive, int offset, int count) {
return lexRangeTail(fromElement, fromInclusive, offset, count);
}
@Override
public Collection<String> lexRangeTail(String fromElement, boolean fromInclusive, int offset, int count) {
return get(rangeTailAsync(fromElement, fromInclusive, offset, count));
return get(lexRangeTailAsync(fromElement, fromInclusive, offset, count));
}
@Override
public Future<Collection<String>> rangeTailAsync(String fromElement, boolean fromInclusive, int offset, int count) {
return lexRangeTailAsync(fromElement, fromInclusive, offset, count);
}
@Override
public Future<Collection<String>> lexRangeTailAsync(String fromElement, boolean fromInclusive, int offset, int count) {
String fromValue = value(fromElement, fromInclusive);
return commandExecutor.readAsync(getName(), StringCodec.INSTANCE, RedisCommands.ZRANGEBYLEX, getName(), fromValue, "+", "LIMIT", offset, count);
}
@Override
public Future<Collection<String>> rangeAsync(String fromElement, boolean fromInclusive, String toElement,
boolean toInclusive, int offset, int count) {
return lexRangeAsync(fromElement, fromInclusive, toElement, toInclusive, offset, count);
}
@Override
public Future<Collection<String>> lexRangeAsync(String fromElement, boolean fromInclusive, String toElement, boolean toInclusive, int offset, int count) {
String fromValue = value(fromElement, fromInclusive);
@ -230,20 +137,10 @@ public class RedissonLexSortedSet extends RedissonScoredSortedSet<String> implem
return commandExecutor.readAsync(getName(), StringCodec.INSTANCE, RedisCommands.ZRANGEBYLEX, getName(), fromValue, toValue, "LIMIT", offset, count);
}
@Override
public int countTail(String fromElement, boolean fromInclusive) {
return lexCountTail(fromElement, fromInclusive);
}
@Override
public int lexCountTail(String fromElement, boolean fromInclusive) {
return get(countTailAsync(fromElement, fromInclusive));
}
@Override
public Future<Integer> countTailAsync(String fromElement, boolean fromInclusive) {
return lexCountTailAsync(fromElement, fromInclusive);
return get(lexCountTailAsync(fromElement, fromInclusive));
}
@Override
@ -252,20 +149,10 @@ public class RedissonLexSortedSet extends RedissonScoredSortedSet<String> implem
return commandExecutor.readAsync(getName(), StringCodec.INSTANCE, RedisCommands.ZLEXCOUNT, getName(), fromValue, "+");
}
@Override
public int countHead(String toElement, boolean toInclusive) {
return lexCountHead(toElement, toInclusive);
}
@Override
public int lexCountHead(String toElement, boolean toInclusive) {
return get(countHeadAsync(toElement, toInclusive));
}
@Override
public Future<Integer> countHeadAsync(String toElement, boolean toInclusive) {
return lexCountHeadAsync(toElement, toInclusive);
return get(lexCountHeadAsync(toElement, toInclusive));
}
@Override
@ -275,22 +162,11 @@ public class RedissonLexSortedSet extends RedissonScoredSortedSet<String> implem
return commandExecutor.readAsync(getName(), StringCodec.INSTANCE, RedisCommands.ZLEXCOUNT, getName(), "-", toValue);
}
@Override
public int count(String fromElement, boolean fromInclusive, String toElement, boolean toInclusive) {
return lexCount(fromElement, fromInclusive, toElement, toInclusive);
}
@Override
public int lexCount(String fromElement, boolean fromInclusive, String toElement, boolean toInclusive) {
return get(countAsync(fromElement, fromInclusive, toElement, toInclusive));
return get(lexCountAsync(fromElement, fromInclusive, toElement, toInclusive));
}
@Override
public Future<Integer> countAsync(String fromElement, boolean fromInclusive, String toElement,
boolean toInclusive) {
return lexCountAsync(fromElement, fromInclusive, toElement, toInclusive);
}
@Override
public Future<Integer> lexCountAsync(String fromElement, boolean fromInclusive, String toElement, boolean toInclusive) {
String fromValue = value(fromElement, fromInclusive);
@ -316,9 +192,6 @@ public class RedissonLexSortedSet extends RedissonScoredSortedSet<String> implem
@Override
public Future<Boolean> addAllAsync(Collection<? extends String> c) {
if (c.isEmpty()) {
return newSucceededFuture(false);
}
List<Object> params = new ArrayList<Object>(2*c.size());
for (Object param : c) {
params.add(0);
@ -337,14 +210,4 @@ public class RedissonLexSortedSet extends RedissonScoredSortedSet<String> implem
return get(addAllAsync(c));
}
@Override
public Collection<String> range(int startIndex, int endIndex) {
return valueRange(startIndex, endIndex);
}
@Override
public Future<Collection<String>> rangeAsync(int startIndex, int endIndex) {
return valueRangeAsync(startIndex, endIndex);
}
}

@ -130,7 +130,7 @@ public class RedissonMap<K, V> extends RedissonExpirable implements RMap<K, V> {
List<Object> args = new ArrayList<Object>(keys.size() + 1);
args.add(getName());
args.addAll(keys);
return commandExecutor.readAsync(getName(), codec, new RedisCommand<Map<Object, Object>>("HMGET", new MapGetAllDecoder(args, 1), 2, ValueType.MAP_KEY, ValueType.MAP_VALUE), args.toArray());
return commandExecutor.readAsync(getName(), codec, new RedisCommand<Map<Object, Object>>("HMGET", new MapGetAllDecoder(args), 2, ValueType.MAP_KEY, ValueType.MAP_VALUE), args.toArray());
}
@Override

@ -162,11 +162,11 @@ public class RedissonMapCache<K, V> extends RedissonMap<K, V> implements RMapCac
return newSucceededFuture(Collections.<K, V>emptyMap());
}
List<Object> args = new ArrayList<Object>(keys.size() + 1);
List<Object> args = new ArrayList<Object>(keys.size() + 2);
args.add(System.currentTimeMillis());
args.addAll(keys);
return commandExecutor.evalWriteAsync(getName(), codec, new RedisCommand<Map<Object, Object>>("EVAL", new MapGetAllDecoder(args, 1), 7, ValueType.MAP_KEY, ValueType.MAP_VALUE),
return commandExecutor.evalWriteAsync(getName(), codec, new RedisCommand<Map<Object, Object>>("EVAL", new MapGetAllDecoder(args), 7, ValueType.MAP_KEY, ValueType.MAP_VALUE),
"local expireHead = redis.call('zrange', KEYS[2], 0, 0, 'withscores');" +
"local expireIdleHead = redis.call('zrange', KEYS[3], 0, 0, 'withscores');" +
"local maxDate = table.remove(ARGV, 1); " // index is the first parameter

@ -121,9 +121,6 @@ public class RedissonScoredSortedSet<V> extends RedissonExpirable implements RSc
@Override
public Future<Long> addAllAsync(Map<V, Double> objects) {
if (objects.isEmpty()) {
return newSucceededFuture(0L);
}
List<Object> params = new ArrayList<Object>(objects.size()*2+1);
params.add(getName());
try {

@ -1,34 +0,0 @@
/**
* 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.client.codec;
import org.redisson.client.protocol.Decoder;
public class DelegateDecoderCodec extends StringCodec {
private final Codec delegate;
public DelegateDecoderCodec(Codec delegate) {
super();
this.delegate = delegate;
}
@Override
public Decoder<Object> getValueDecoder() {
return delegate.getValueDecoder();
}
}

@ -196,7 +196,6 @@ public interface RedisCommands {
RedisStrictCommand<List<String>> KEYS = new RedisStrictCommand<List<String>>("KEYS", new StringListReplayDecoder());
RedisCommand<List<Object>> MGET = new RedisCommand<List<Object>>("MGET", new ObjectListReplayDecoder<Object>());
RedisStrictCommand<Void> MSET = new RedisStrictCommand<Void>("MSET", new VoidReplayConvertor());
RedisStrictCommand<Boolean> MSETNX = new RedisStrictCommand<Boolean>("MSETNX", new BooleanReplayConvertor());
RedisCommand<Boolean> HSETNX = new RedisCommand<Boolean>("HSETNX", new BooleanReplayConvertor(), 2, ValueType.MAP);
RedisCommand<Boolean> HSET = new RedisCommand<Boolean>("HSET", new BooleanReplayConvertor(), 2, ValueType.MAP);

@ -25,6 +25,7 @@ import org.redisson.client.codec.DoubleCodec;
import org.redisson.client.handler.State;
import io.netty.buffer.ByteBuf;
import io.netty.util.CharsetUtil;
public class GeoDistanceMapDecoder implements MultiDecoder<Map<Object, Object>> {
@ -39,6 +40,7 @@ public class GeoDistanceMapDecoder implements MultiDecoder<Map<Object, Object>>
@Override
public Object decode(ByteBuf buf, State state) throws IOException {
System.out.println("1 " + buf.toString(CharsetUtil.UTF_8));
if (pos.get() % 2 == 0) {
return codec.getValueDecoder().decode(buf, state);
}
@ -53,6 +55,7 @@ public class GeoDistanceMapDecoder implements MultiDecoder<Map<Object, Object>>
@Override
public Map<Object, Object> decode(List<Object> parts, State state) {
System.out.println(parts);
Map<Object, Object> result = new HashMap<Object, Object>(parts.size()/2);
for (int i = 0; i < parts.size(); i++) {
if (i % 2 != 0) {

@ -28,12 +28,10 @@ import io.netty.buffer.ByteBuf;
public class MapGetAllDecoder implements MultiDecoder<Map<Object, Object>> {
private final int shiftIndex;
private final List<Object> args;
public MapGetAllDecoder(List<Object> args, int shiftIndex) {
public MapGetAllDecoder(List<Object> args) {
this.args = args;
this.shiftIndex = shiftIndex;
}
@Override
@ -52,12 +50,12 @@ public class MapGetAllDecoder implements MultiDecoder<Map<Object, Object>> {
return Collections.emptyMap();
}
Map<Object, Object> result = new HashMap<Object, Object>(parts.size());
for (int index = 0; index < args.size()-shiftIndex; index++) {
for (int index = 0; index < args.size()-1; index++) {
Object value = parts.get(index);
if (value == null) {
continue;
}
result.put(args.get(index+shiftIndex), value);
result.put(args.get(index+1), value);
}
return result;
}

@ -1,64 +0,0 @@
/**
* 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.List;
import java.util.Map;
public interface RBuckets {
/**
* <p>Returns a list of object holder instances by a key pattern.
*
* <pre>Supported glob-style patterns:
* h?llo subscribes to hello, hallo and hxllo
* h*llo subscribes to hllo and heeeello
* h[ae]llo subscribes to hello and hallo, but not hillo
* h[^e]llo matches hallo, hbllo, ... but not hello
* h[a-b]llo matches hallo and hbllo</pre>
* <p>Use \ to escape special characters if you want to match them verbatim.
*
* @param pattern
* @return
*/
<V> List<RBucket<V>> find(String pattern);
/**
* Returns Redis object mapped by key. Result Map is not contains
* key-value entry for null values.
*
* @param keys
* @return
*/
<V> Map<String, V> get(String ... keys);
/**
* Try to save objects mapped by Redis key.
* If at least one of them is already exist then
* don't set none of them.
*
* @param buckets
*/
boolean trySet(Map<String, ?> buckets);
/**
* Saves objects mapped by Redis key.
*
* @param buckets
*/
void set(Map<String, ?> buckets);
}

@ -20,110 +20,32 @@ import java.util.Set;
public interface RLexSortedSet extends RLexSortedSetAsync, Set<String>, RExpirable {
int removeRangeTail(String fromElement, boolean fromInclusive);
/**
* Use {@link RLexSortedSet#removeRangeTail(String, boolean)}
*/
@Deprecated
int removeRangeTailByLex(String fromElement, boolean fromInclusive);
int removeRangeHead(String toElement, boolean toInclusive);
/**
* Use {@link RLexSortedSet#removeRangeHead(String, boolean)}
*/
@Deprecated
int removeRangeHeadByLex(String toElement, boolean toInclusive);
int removeRange(String fromElement, boolean fromInclusive, String toElement, boolean toInclusive);
/**
* Use {@link RLexSortedSet#removeRange(String, boolean)}
*/
@Deprecated
int removeRangeByLex(String fromElement, boolean fromInclusive, String toElement, boolean toInclusive);
int countTail(String fromElement, boolean fromInclusive);
/**
* Use {@link RLexSortedSet#countTail(String, boolean)}
*/
@Deprecated
int lexCountTail(String fromElement, boolean fromInclusive);
int countHead(String toElement, boolean toInclusive);
/**
* Use {@link RLexSortedSet#countHead(String, boolean)}
*/
@Deprecated
int lexCountHead(String toElement, boolean toInclusive);
Collection<String> rangeTail(String fromElement, boolean fromInclusive);
/**
* Use {@link RLexSortedSet#rangeTail(String, boolean)}
*/
@Deprecated
Collection<String> lexRangeTail(String fromElement, boolean fromInclusive);
Collection<String> rangeHead(String toElement, boolean toInclusive);
/**
* Use {@link RLexSortedSet#rangeHead(String, boolean)}
*/
@Deprecated
Collection<String> lexRangeHead(String toElement, boolean toInclusive);
Collection<String> range(String fromElement, boolean fromInclusive, String toElement, boolean toInclusive);
/**
* Use {@link RLexSortedSet#range(String, boolean, String, boolean)}
*/
@Deprecated
Collection<String> lexRange(String fromElement, boolean fromInclusive, String toElement, boolean toInclusive);
Collection<String> rangeTail(String fromElement, boolean fromInclusive, int offset, int count);
/**
* Use {@link RLexSortedSet#rangeTail(String, boolean, int, int)}
*/
@Deprecated
Collection<String> lexRangeTail(String fromElement, boolean fromInclusive, int offset, int count);
Collection<String> rangeHead(String toElement, boolean toInclusive, int offset, int count);
/**
* Use {@link RLexSortedSet#rangeHead(String, boolean, int, int)}
*/
@Deprecated
Collection<String> lexRangeHead(String toElement, boolean toInclusive, int offset, int count);
Collection<String> range(String fromElement, boolean fromInclusive, String toElement, boolean toInclusive, int offset, int count);
/**
* Use {@link RLexSortedSet#range(String, boolean, String, boolean, int, int)}
*/
@Deprecated
Collection<String> lexRange(String fromElement, boolean fromInclusive, String toElement, boolean toInclusive, int offset, int count);
int count(String fromElement, boolean fromInclusive, String toElement, boolean toInclusive);
/**
* Use {@link RLexSortedSet#count(String, boolean, String, boolean)}
*/
@Deprecated
int lexCount(String fromElement, boolean fromInclusive, String toElement, boolean toInclusive);
int rank(String o);
Collection<String> range(int startIndex, int endIndex);
/**
* Use {@link RLexSortedSet#range(int, int)}
*/
@Deprecated
Collection<String> valueRange(int startIndex, int endIndex);
}

@ -21,110 +21,32 @@ import io.netty.util.concurrent.Future;
public interface RLexSortedSetAsync extends RCollectionAsync<String> {
Future<Integer> removeRangeAsync(String fromElement, boolean fromInclusive, String toElement, boolean toInclusive);
/**
* Use {@link RLexSortedSetAsync#removeRangeAsync(String, boolean, String, boolean)}
*/
@Deprecated
Future<Integer> removeRangeByLexAsync(String fromElement, boolean fromInclusive, String toElement, boolean toInclusive);
Future<Integer> removeRangeTailAsync(String fromElement, boolean fromInclusive);
/**
* Use {@link RLexSortedSetAsync#removeRangeTailAsync(String, boolean, String, boolean)}
*/
@Deprecated
Future<Integer> removeRangeTailByLexAsync(String fromElement, boolean fromInclusive);
Future<Integer> removeRangeHeadAsync(String toElement, boolean toInclusive);
/**
* Use {@link RLexSortedSetAsync#removeRangeHeadAsync(String, boolean)}
*/
@Deprecated
Future<Integer> removeRangeHeadByLexAsync(String toElement, boolean toInclusive);
Future<Integer> countTailAsync(String fromElement, boolean fromInclusive);
/**
* Use {@link RLexSortedSetAsync#countTailAsync(String, boolean)}
*/
@Deprecated
Future<Integer> lexCountTailAsync(String fromElement, boolean fromInclusive);
Future<Integer> countHeadAsync(String toElement, boolean toInclusive);
/**
* Use {@link RLexSortedSetAsync#countHeadAsync(String, boolean)}
*/
@Deprecated
Future<Integer> lexCountHeadAsync(String toElement, boolean toInclusive);
Future<Collection<String>> rangeTailAsync(String fromElement, boolean fromInclusive);
/**
* Use {@link RLexSortedSetAsync#rangeTailAsync(String, boolean)}
*/
@Deprecated
Future<Collection<String>> lexRangeTailAsync(String fromElement, boolean fromInclusive);
Future<Collection<String>> rangeHeadAsync(String toElement, boolean toInclusive);
/**
* Use {@link RLexSortedSetAsync#rangeHeadAsync(String, boolean)}
*/
@Deprecated
Future<Collection<String>> lexRangeHeadAsync(String toElement, boolean toInclusive);
Future<Collection<String>> rangeAsync(String fromElement, boolean fromInclusive, String toElement, boolean toInclusive);
/**
* Use {@link RLexSortedSetAsync#rangeAsync(String, boolean, String, boolean)}
*/
@Deprecated
Future<Collection<String>> lexRangeAsync(String fromElement, boolean fromInclusive, String toElement, boolean toInclusive);
Future<Collection<String>> rangeTailAsync(String fromElement, boolean fromInclusive, int offset, int count);
/**
* Use {@link RLexSortedSetAsync#rangeTailAsync(String, boolean, int, int)}
*/
@Deprecated
Future<Collection<String>> lexRangeTailAsync(String fromElement, boolean fromInclusive, int offset, int count);
Future<Collection<String>> rangeHeadAsync(String toElement, boolean toInclusive, int offset, int count);
/**
* Use {@link RLexSortedSetAsync#rangeHeadAsync(String, boolean, int, int)}
*/
@Deprecated
Future<Collection<String>> lexRangeHeadAsync(String toElement, boolean toInclusive, int offset, int count);
Future<Collection<String>> rangeAsync(String fromElement, boolean fromInclusive, String toElement, boolean toInclusive, int offset, int count);
/**
* Use {@link RLexSortedSetAsync#rangeAsync(String, boolean, String, boolean, int, int)}
*/
@Deprecated
Future<Collection<String>> lexRangeAsync(String fromElement, boolean fromInclusive, String toElement, boolean toInclusive, int offset, int count);
Future<Integer> countAsync(String fromElement, boolean fromInclusive, String toElement, boolean toInclusive);
/**
* Use {@link RLexSortedSetAsync#countAsync(String, boolean, String, boolean)}
*/
@Deprecated
Future<Integer> lexCountAsync(String fromElement, boolean fromInclusive, String toElement, boolean toInclusive);
Future<Integer> rankAsync(String o);
Future<Collection<String>> rangeAsync(int startIndex, int endIndex);
/**
* Use {@link RLexSortedSetAsync#rangeAsync(int, int)}
*/
@Deprecated
Future<Collection<String>> valueRangeAsync(int startIndex, int endIndex);
}

@ -59,11 +59,40 @@ public class RedissonBucketTest extends BaseTest {
assertThat(r1.trySet("4", 500, TimeUnit.MILLISECONDS)).isFalse();
assertThat(r1.get()).isEqualTo("3");
Thread.sleep(1000);
Thread.sleep(500);
assertThat(r1.get()).isNull();
}
@Test
public void testSaveBuckets() {
Map<String, Integer> buckets = new HashMap<String, Integer>();
buckets.put("12", 1);
buckets.put("41", 2);
redisson.saveBuckets(buckets);
RBucket<Object> r1 = redisson.getBucket("12");
assertThat(r1.get()).isEqualTo(1);
RBucket<Object> r2 = redisson.getBucket("41");
assertThat(r2.get()).isEqualTo(2);
}
@Test
public void testLoadBucketValues() {
RBucket<String> bucket1 = redisson.getBucket("test1");
bucket1.set("someValue1");
RBucket<String> bucket3 = redisson.getBucket("test3");
bucket3.set("someValue3");
Map<String, String> result = redisson.loadBucketValues("test1", "test2", "test3", "test4");
Map<String, String> expected = new HashMap<String, String>();
expected.put("test1", "someValue1");
expected.put("test3", "someValue3");
Assert.assertEquals(expected, result);
}
@Test
public void testExpire() throws InterruptedException {
RBucket<String> bucket = redisson.getBucket("test1");
@ -146,4 +175,20 @@ public class RedissonBucketTest extends BaseTest {
Assert.assertFalse(bucket.isExists());
}
@Test
public void testGetPattern() {
Collection<String> names = Arrays.asList("test:testGetPattern:one", "test:testGetPattern:two");
Collection<String> vals = Arrays.asList("one-val", "two-val");
redisson.getBucket("test:testGetPattern:one").set("one-val");
redisson.getBucket("test:testGetPattern:two").set("two-val");
List<RBucket<String>> buckets = redisson.getBuckets("test:testGetPattern:*");
Assert.assertEquals(2, buckets.size());
Assert.assertTrue(names.contains(buckets.get(0).getName()));
Assert.assertTrue(names.contains(buckets.get(1).getName()));
Assert.assertTrue(vals.contains(buckets.get(0).get()));
Assert.assertTrue(vals.contains(buckets.get(1).get()));
for (RBucket<String> bucket : buckets) {
bucket.delete();
}
}
}

@ -1,91 +0,0 @@
package org.redisson;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import static org.assertj.core.api.Assertions.*;
import org.junit.Assert;
import org.junit.Test;
import org.redisson.core.RBucket;
public class RedissonBucketsTest extends BaseTest {
@Test
public void testGet() {
RBucket<String> bucket1 = redisson.getBucket("test1");
bucket1.set("someValue1");
RBucket<String> bucket3 = redisson.getBucket("test3");
bucket3.set("someValue3");
Map<String, String> result = redisson.getBuckets().get("test1", "test2", "test3", "test4");
Map<String, String> expected = new HashMap<String, String>();
expected.put("test1", "someValue1");
expected.put("test3", "someValue3");
Assert.assertEquals(expected, result);
}
@Test
public void testFind() {
Collection<String> names = Arrays.asList("test:testGetPattern:one", "test:testGetPattern:two");
Collection<String> vals = Arrays.asList("one-val", "two-val");
redisson.getBucket("test:testGetPattern:one").set("one-val");
redisson.getBucket("test:testGetPattern:two").set("two-val");
List<RBucket<String>> buckets = redisson.getBuckets().find("test:testGetPattern:*");
Assert.assertEquals(2, buckets.size());
Assert.assertTrue(names.contains(buckets.get(0).getName()));
Assert.assertTrue(names.contains(buckets.get(1).getName()));
Assert.assertTrue(vals.contains(buckets.get(0).get()));
Assert.assertTrue(vals.contains(buckets.get(1).get()));
for (RBucket<String> bucket : buckets) {
bucket.delete();
}
}
@Test
public void testSet() {
Map<String, Integer> buckets = new HashMap<String, Integer>();
buckets.put("12", 1);
buckets.put("41", 2);
redisson.getBuckets().set(buckets);
RBucket<Object> r1 = redisson.getBucket("12");
assertThat(r1.get()).isEqualTo(1);
RBucket<Object> r2 = redisson.getBucket("41");
assertThat(r2.get()).isEqualTo(2);
}
@Test
public void testTrySet() {
redisson.getBucket("12").set("341");
Map<String, Integer> buckets = new HashMap<String, Integer>();
buckets.put("12", 1);
buckets.put("41", 2);
assertThat(redisson.getBuckets().trySet(buckets)).isFalse();
RBucket<Object> r2 = redisson.getBucket("41");
assertThat(r2.get()).isNull();
Map<String, Integer> buckets2 = new HashMap<String, Integer>();
buckets2.put("61", 1);
buckets2.put("41", 2);
assertThat(redisson.getBuckets().trySet(buckets2)).isTrue();
RBucket<Object> r1 = redisson.getBucket("61");
assertThat(r1.get()).isEqualTo(1);
RBucket<Object> r3 = redisson.getBucket("41");
assertThat(r3.get()).isEqualTo(2);
}
}

@ -94,7 +94,7 @@ public class RedissonConcurrentMapTest extends BaseConcurrentTest {
}
assertMapSize(5, name);
redisson.getKeys().flushdb();
redisson.flushdb();
redisson.shutdown();
}

@ -1,183 +0,0 @@
package org.redisson;
import static org.assertj.core.api.Assertions.assertThat;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;
import org.junit.Test;
import org.redisson.core.GeoEntry;
import org.redisson.core.GeoPosition;
import org.redisson.core.GeoUnit;
import org.redisson.core.RGeo;
public class RedissonGeoTest extends BaseTest {
@Test
public void testAdd() {
RGeo<String> geo = redisson.getGeo("test");
assertThat(geo.add(2.51, 3.12, "city1")).isEqualTo(1);
}
@Test
public void testAddEntries() {
RGeo<String> geo = redisson.getGeo("test");
assertThat(geo.add(new GeoEntry(3.11, 9.10321, "city1"), new GeoEntry(81.1231, 38.65478, "city2"))).isEqualTo(2);
}
@Test
public void testDist() {
RGeo<String> geo = redisson.getGeo("test");
geo.add(new GeoEntry(13.361389, 38.115556, "Palermo"), new GeoEntry(15.087269, 37.502669, "Catania"));
assertThat(geo.dist("Palermo", "Catania", GeoUnit.METERS)).isEqualTo(166274.15156960033D);
}
@Test
public void testDistEmpty() {
RGeo<String> geo = redisson.getGeo("test");
assertThat(geo.dist("Palermo", "Catania", GeoUnit.METERS)).isNull();
}
@Test
public void testHash() {
RGeo<String> geo = redisson.getGeo("test");
geo.add(new GeoEntry(13.361389, 38.115556, "Palermo"), new GeoEntry(15.087269, 37.502669, "Catania"));
Map<String, String> expected = new LinkedHashMap<String, String>();
expected.put("Palermo", "sqc8b49rny0");
expected.put("Catania", "sqdtr74hyu0");
assertThat(geo.hash("Palermo", "Catania")).isEqualTo(expected);
}
@Test
public void testHashEmpty() {
RGeo<String> geo = redisson.getGeo("test");
assertThat(geo.hash("Palermo", "Catania")).isEmpty();
}
@Test
public void testPos() {
RGeo<String> geo = redisson.getGeo("test");
geo.add(new GeoEntry(13.361389, 38.115556, "Palermo"), new GeoEntry(15.087269, 37.502669, "Catania"));
Map<String, GeoPosition> expected = new LinkedHashMap<String, GeoPosition>();
expected.put("Palermo", new GeoPosition(13.361389338970184, 38.115556395496299));
expected.put("Catania", new GeoPosition(15.087267458438873, 37.50266842333162));
assertThat(geo.pos("test2", "Palermo", "test3", "Catania", "test1")).isEqualTo(expected);
}
@Test
public void testPosEmpty() {
RGeo<String> geo = redisson.getGeo("test");
assertThat(geo.pos("test2", "Palermo", "test3", "Catania", "test1")).isEmpty();
}
@Test
public void testRadius() {
RGeo<String> geo = redisson.getGeo("test");
geo.add(new GeoEntry(13.361389, 38.115556, "Palermo"), new GeoEntry(15.087269, 37.502669, "Catania"));
assertThat(geo.radius(15, 37, 200, GeoUnit.KILOMETERS)).containsExactly("Palermo", "Catania");
}
@Test
public void testRadiusEmpty() {
RGeo<String> geo = redisson.getGeo("test");
assertThat(geo.radius(15, 37, 200, GeoUnit.KILOMETERS)).isEmpty();
}
@Test
public void testRadiusWithDistance() {
RGeo<String> geo = redisson.getGeo("test");
geo.add(new GeoEntry(13.361389, 38.115556, "Palermo"), new GeoEntry(15.087269, 37.502669, "Catania"));
Map<String, Double> expected = new HashMap<String, Double>();
expected.put("Palermo", 190.4424);
expected.put("Catania", 56.4413);
assertThat(geo.radiusWithDistance(15, 37, 200, GeoUnit.KILOMETERS)).isEqualTo(expected);
}
@Test
public void testRadiusWithDistanceEmpty() {
RGeo<String> geo = redisson.getGeo("test");
assertThat(geo.radiusWithDistance(15, 37, 200, GeoUnit.KILOMETERS)).isEmpty();
}
@Test
public void testRadiusWithPosition() {
RGeo<String> geo = redisson.getGeo("test");
geo.add(new GeoEntry(13.361389, 38.115556, "Palermo"), new GeoEntry(15.087269, 37.502669, "Catania"));
Map<String, GeoPosition> expected = new HashMap<String, GeoPosition>();
expected.put("Palermo", new GeoPosition(13.361389338970184, 38.115556395496299));
expected.put("Catania", new GeoPosition(15.087267458438873, 37.50266842333162));
assertThat(geo.radiusWithPosition(15, 37, 200, GeoUnit.KILOMETERS)).isEqualTo(expected);
}
@Test
public void testRadiusWithPositionEmpty() {
RGeo<String> geo = redisson.getGeo("test");
assertThat(geo.radiusWithPosition(15, 37, 200, GeoUnit.KILOMETERS)).isEmpty();
}
@Test
public void testRadiusMember() {
RGeo<String> geo = redisson.getGeo("test");
geo.add(new GeoEntry(13.361389, 38.115556, "Palermo"), new GeoEntry(15.087269, 37.502669, "Catania"));
assertThat(geo.radius("Palermo", 200, GeoUnit.KILOMETERS)).containsExactly("Palermo", "Catania");
}
@Test
public void testRadiusMemberEmpty() {
RGeo<String> geo = redisson.getGeo("test");
assertThat(geo.radius("Palermo", 200, GeoUnit.KILOMETERS)).isEmpty();
}
@Test
public void testRadiusMemberWithDistance() {
RGeo<String> geo = redisson.getGeo("test");
geo.add(new GeoEntry(13.361389, 38.115556, "Palermo"), new GeoEntry(15.087269, 37.502669, "Catania"));
Map<String, Double> expected = new HashMap<String, Double>();
expected.put("Palermo", 0.0);
expected.put("Catania", 166.2742);
assertThat(geo.radiusWithDistance("Palermo", 200, GeoUnit.KILOMETERS)).isEqualTo(expected);
}
@Test
public void testRadiusMemberWithDistanceEmpty() {
RGeo<String> geo = redisson.getGeo("test");
assertThat(geo.radiusWithDistance("Palermo", 200, GeoUnit.KILOMETERS)).isEmpty();
}
@Test
public void testRadiusMemberWithPosition() {
RGeo<String> geo = redisson.getGeo("test");
geo.add(new GeoEntry(13.361389, 38.115556, "Palermo"), new GeoEntry(15.087269, 37.502669, "Catania"));
Map<String, GeoPosition> expected = new HashMap<String, GeoPosition>();
expected.put("Palermo", new GeoPosition(13.361389338970184, 38.115556395496299));
expected.put("Catania", new GeoPosition(15.087267458438873, 37.50266842333162));
assertThat(geo.radiusWithPosition("Palermo", 200, GeoUnit.KILOMETERS)).isEqualTo(expected);
}
@Test
public void testRadiusMemberWithPositionEmpty() {
RGeo<String> geo = redisson.getGeo("test");
assertThat(geo.radiusWithPosition("Palermo", 200, GeoUnit.KILOMETERS)).isEmpty();
}
}

@ -58,7 +58,7 @@ public class RedissonKeysTest extends BaseTest {
assertThat(redisson.getKeys().randomKey()).isIn("test1", "test2");
redisson.getKeys().delete("test1");
Assert.assertEquals(redisson.getKeys().randomKey(), "test2");
redisson.getKeys().flushdb();
redisson.flushdb();
Assert.assertNull(redisson.getKeys().randomKey());
}

@ -1,6 +1,7 @@
package org.redisson;
import static org.assertj.core.api.Assertions.*;
import org.hamcrest.MatcherAssert;
import org.hamcrest.Matchers;
import org.junit.Assert;
import org.junit.Test;
import org.redisson.core.RLexSortedSet;
@ -19,12 +20,12 @@ public class RedissonLexSortedSetTest extends BaseTest {
Assert.assertTrue(set.add("f"));
Assert.assertTrue(set.add("g"));
Assert.assertEquals(0, (int)set.removeRangeTail("z", false));
Assert.assertEquals(0, (int)set.removeRangeTailByLex("z", false));
Assert.assertEquals(4, (int)set.removeRangeTail("c", false));
assertThat(set).containsExactly("a", "b", "c");
Assert.assertEquals(1, (int)set.removeRangeTail("c", true));
assertThat(set).containsExactly("a", "b");
Assert.assertEquals(4, (int)set.removeRangeTailByLex("c", false));
MatcherAssert.assertThat(set, Matchers.contains("a", "b", "c"));
Assert.assertEquals(1, (int)set.removeRangeTailByLex("c", true));
MatcherAssert.assertThat(set, Matchers.contains("a", "b"));
}
@ -39,10 +40,10 @@ public class RedissonLexSortedSetTest extends BaseTest {
set.add("f");
set.add("g");
Assert.assertEquals(2, (int)set.removeRangeHead("c", false));
assertThat(set).containsExactly("c", "d", "e", "f", "g");
Assert.assertEquals(1, (int)set.removeRangeHead("c", true));
assertThat(set).containsExactly("d", "e", "f", "g");
Assert.assertEquals(2, (int)set.removeRangeHeadByLex("c", false));
MatcherAssert.assertThat(set, Matchers.contains("c", "d", "e", "f", "g"));
Assert.assertEquals(1, (int)set.removeRangeHeadByLex("c", true));
MatcherAssert.assertThat(set, Matchers.contains("d", "e", "f", "g"));
}
@Test
@ -56,8 +57,8 @@ public class RedissonLexSortedSetTest extends BaseTest {
set.add("f");
set.add("g");
Assert.assertEquals(5, set.removeRange("aaa", true, "g", false));
assertThat(set).containsExactly("a", "g");
Assert.assertEquals(5, set.removeRangeByLex("aaa", true, "g", false));
MatcherAssert.assertThat(set, Matchers.contains("a", "g"));
}
@ -73,8 +74,8 @@ public class RedissonLexSortedSetTest extends BaseTest {
Assert.assertTrue(set.add("f"));
Assert.assertTrue(set.add("g"));
assertThat(set.rangeTail("c", false)).containsExactly("d", "e", "f", "g");
assertThat(set.rangeTail("c", true)).containsExactly("c", "d", "e", "f", "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"));
}
@ -89,8 +90,8 @@ public class RedissonLexSortedSetTest extends BaseTest {
set.add("f");
set.add("g");
assertThat(set.rangeHead("c", false)).containsExactly("a", "b");
assertThat(set.rangeHead("c", true)).containsExactly("a", "b", "c");
MatcherAssert.assertThat(set.lexRangeHead("c", false), Matchers.contains("a", "b"));
MatcherAssert.assertThat(set.lexRangeHead("c", true), Matchers.contains("a", "b", "c"));
}
@ -105,7 +106,7 @@ public class RedissonLexSortedSetTest extends BaseTest {
set.add("f");
set.add("g");
assertThat(set.range("aaa", true, "g", false)).containsExactly("b", "c", "d", "e", "f");
MatcherAssert.assertThat(set.lexRange("aaa", true, "g", false), Matchers.contains("b", "c", "d", "e", "f"));
}
@Test
@ -119,8 +120,8 @@ public class RedissonLexSortedSetTest extends BaseTest {
set.add("f");
set.add("g");
assertThat(set.count("b", true, "f", true)).isEqualTo(5);
assertThat(set.count("b", false, "f", false)).isEqualTo(3);
Assert.assertEquals(5, (int)set.lexCount("b", true, "f", true));
Assert.assertEquals(3, (int)set.lexCount("b", false, "f", false));
}
}

@ -102,7 +102,7 @@ public class RedissonSetMultimapCacheTest extends BaseTest {
multimap.put("1", "3");
multimap.expireKey("1", 1, TimeUnit.SECONDS);
Thread.sleep(1500);
Thread.sleep(1000);
assertThat(multimap.get("1").size()).isZero();
assertThat(multimap.get("1")).contains();

Loading…
Cancel
Save