Refine RedisList.

Add missing Javadoc. Add trim overload accepting long to avoid potential integer downcasting. Add factory methods to RedisList.

See: #2039
Original Pull Request: #2107
This commit is contained in:
Mark Paluch
2021-06-30 11:30:33 +02:00
committed by Christoph Strobl
parent 54ad66b62c
commit eefbd0d821
6 changed files with 101 additions and 8 deletions

View File

@@ -26,7 +26,6 @@ import org.springframework.data.redis.connection.lettuce.extension.LettuceConnec
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.data.redis.support.atomic.RedisAtomicInteger;
import org.springframework.data.redis.support.atomic.RedisAtomicLong;
import org.springframework.data.redis.support.collections.DefaultRedisList;
import org.springframework.data.redis.support.collections.DefaultRedisMap;
import org.springframework.data.redis.support.collections.DefaultRedisSet;
import org.springframework.data.redis.support.collections.RedisList;
@@ -47,7 +46,7 @@ public class BoundKeyParams {
StringRedisTemplate templateJS = new StringRedisTemplate(jedisConnFactory);
DefaultRedisMap mapJS = new DefaultRedisMap("bound:key:map", templateJS);
DefaultRedisSet setJS = new DefaultRedisSet("bound:key:set", templateJS);
RedisList list = new DefaultRedisList("bound:key:list", templateJS);
RedisList list = RedisList.create("bound:key:list", templateJS);
// Lettuce
LettuceConnectionFactory lettuceConnFactory = LettuceConnectionFactoryExtension
@@ -56,7 +55,7 @@ public class BoundKeyParams {
StringRedisTemplate templateLT = new StringRedisTemplate(lettuceConnFactory);
DefaultRedisMap mapLT = new DefaultRedisMap("bound:key:mapLT", templateLT);
DefaultRedisSet setLT = new DefaultRedisSet("bound:key:setLT", templateLT);
RedisList listLT = new DefaultRedisList("bound:key:listLT", templateLT);
RedisList listLT = RedisList.create("bound:key:listLT", templateLT);
StringObjectFactory sof = new StringObjectFactory();

View File

@@ -319,9 +319,10 @@ public abstract class AbstractRedisListIntegrationTests<T> extends AbstractRedis
list.add(t1);
list.add(t2);
assertThat(list).hasSize(2);
assertThat(list.trim(0, 0)).hasSize(1);
assertThat(list.trim(0L, 0L)).hasSize(1);
assertThat(list).hasSize(1);
assertThat(list.get(0)).isEqualTo(t1);
assertThat(list).hasSize(1);
}
@SuppressWarnings("unchecked")

View File

@@ -36,7 +36,7 @@ public class RedisListIntegrationTests extends AbstractRedisListIntegrationTests
}
RedisStore copyStore(RedisStore store) {
return new DefaultRedisList<>(store.getKey(), store.getOperations());
return RedisList.create(store.getKey(), store.getOperations());
}
AbstractRedisCollection<Object> createCollection() {