Script error fixed during RSetCache.toArray or RSetCache.readAll invocation.

pull/400/head
Nikita 9 years ago
parent 1a646d29a5
commit 25ed6d59bb

@ -230,7 +230,10 @@ public class RedissonSetCache<V> extends RedissonExpirable implements RSetCache<
public Future<Set<V>> readAllAsync() {
return commandExecutor.evalReadAsync(getName(), codec, RedisCommands.EVAL_SET,
"local expireHead = redis.call('zrange', KEYS[2], 0, 0, 'withscores');" +
"local keys = redis.call('hkeys', KEYS[1]);" +
"local keys = redis.call('hkeys', KEYS[1]); "
+ "if #keys == 0 then "
+ "return {}; "
+ "end; " +
"local maxDate = ARGV[1]; " +
"local minExpireDate = 92233720368547758;" +
"if #expireHead == 2 and tonumber(expireHead[2]) <= tonumber(maxDate) then " +
@ -250,7 +253,10 @@ public class RedissonSetCache<V> extends RedissonExpirable implements RSetCache<
private Future<List<Object>> readAllasListAsync() {
return commandExecutor.evalReadAsync(getName(), codec, RedisCommands.EVAL_LIST,
"local expireHead = redis.call('zrange', KEYS[2], 0, 0, 'withscores');" +
"local keys = redis.call('hkeys', KEYS[1]);" +
"local keys = redis.call('hkeys', KEYS[1]); " +
"if #keys == 0 then "
+ "return {}; " +
"end; " +
"local maxDate = ARGV[1]; " +
"local minExpireDate = 92233720368547758;" +
"if #expireHead == 2 and tonumber(expireHead[2]) <= tonumber(maxDate) then " +
@ -310,8 +316,8 @@ public class RedissonSetCache<V> extends RedissonExpirable implements RSetCache<
return commandExecutor.evalWriteAsync(getName(), codec, RedisCommands.EVAL_BOOLEAN,
"redis.call('zadd', KEYS[2], ARGV[1], ARGV[3]); " +
"if redis.call('hexists', KEYS[1], ARGV[3]) == 0 then " +
"redis.call('hset', KEYS[1], ARGV[3], ARGV[2]); " +
"return 1; " +
"redis.call('hset', KEYS[1], ARGV[3], ARGV[2]); " +
"return 1; " +
"end;" +
"return 0; ",
Arrays.<Object>asList(getName(), getTimeoutSetName()), timeoutDate, objectState, key);

@ -32,6 +32,12 @@ public class RedissonSetCacheTest extends BaseTest {
}
@Test
public void testEmptyReadAll() {
RSetCache<Integer> set = redisson.getSetCache("set");
assertThat(set.readAll()).isEmpty();
}
@Test
public void testAddBean() throws InterruptedException, ExecutionException {
SimpleBean sb = new SimpleBean();

Loading…
Cancel
Save