diff --git a/redisson-spring-data/redisson-spring-data-24/src/main/java/org/redisson/spring/data/connection/RedissonConnection.java b/redisson-spring-data/redisson-spring-data-24/src/main/java/org/redisson/spring/data/connection/RedissonConnection.java index 7fb6e4971..b486c0f6b 100644 --- a/redisson-spring-data/redisson-spring-data-24/src/main/java/org/redisson/spring/data/connection/RedissonConnection.java +++ b/redisson-spring-data/redisson-spring-data-24/src/main/java/org/redisson/spring/data/connection/RedissonConnection.java @@ -785,6 +785,31 @@ public class RedissonConnection extends AbstractRedisConnection { return write(srcKey, ByteArrayCodec.INSTANCE, RedisCommands.BRPOPLPUSH, srcKey, dstKey, timeout); } + private static final RedisCommand> LPOS = new RedisCommand<>("LPOS", new ObjectListReplayDecoder<>()); + + @Override + public List lPos(byte[] key, byte[] element, Integer rank, Integer count) { + List args = new ArrayList<>(); + args.add(key); + args.add(element); + if (rank != null) { + args.add("RANK"); + args.add(rank); + } + if (count != null) { + args.add("COUNT"); + args.add(count); + } + Object read = read(key, ByteArrayCodec.INSTANCE, LPOS, args.toArray()); + if (read == null) { + return Collections.emptyList(); + } else if (read instanceof Long) { + return Collections.singletonList((Long) read); + } else { + return (List) read; + } + } + private static final RedisCommand SADD = new RedisCommand("SADD"); @Override diff --git a/redisson-spring-data/redisson-spring-data-25/src/main/java/org/redisson/spring/data/connection/RedissonConnection.java b/redisson-spring-data/redisson-spring-data-25/src/main/java/org/redisson/spring/data/connection/RedissonConnection.java index c9533338c..56ff22b9b 100644 --- a/redisson-spring-data/redisson-spring-data-25/src/main/java/org/redisson/spring/data/connection/RedissonConnection.java +++ b/redisson-spring-data/redisson-spring-data-25/src/main/java/org/redisson/spring/data/connection/RedissonConnection.java @@ -785,6 +785,31 @@ public class RedissonConnection extends AbstractRedisConnection { return write(srcKey, ByteArrayCodec.INSTANCE, RedisCommands.BRPOPLPUSH, srcKey, dstKey, timeout); } + private static final RedisCommand> LPOS = new RedisCommand<>("LPOS", new ObjectListReplayDecoder<>()); + + @Override + public List lPos(byte[] key, byte[] element, Integer rank, Integer count) { + List args = new ArrayList<>(); + args.add(key); + args.add(element); + if (rank != null) { + args.add("RANK"); + args.add(rank); + } + if (count != null) { + args.add("COUNT"); + args.add(count); + } + Object read = read(key, ByteArrayCodec.INSTANCE, LPOS, args.toArray()); + if (read == null) { + return Collections.emptyList(); + } else if (read instanceof Long) { + return Collections.singletonList((Long) read); + } else { + return (List) read; + } + } + private static final RedisCommand SADD = new RedisCommand("SADD"); @Override diff --git a/redisson-spring-data/redisson-spring-data-26/src/main/java/org/redisson/spring/data/connection/RedissonConnection.java b/redisson-spring-data/redisson-spring-data-26/src/main/java/org/redisson/spring/data/connection/RedissonConnection.java index c9533338c..56ff22b9b 100644 --- a/redisson-spring-data/redisson-spring-data-26/src/main/java/org/redisson/spring/data/connection/RedissonConnection.java +++ b/redisson-spring-data/redisson-spring-data-26/src/main/java/org/redisson/spring/data/connection/RedissonConnection.java @@ -785,6 +785,31 @@ public class RedissonConnection extends AbstractRedisConnection { return write(srcKey, ByteArrayCodec.INSTANCE, RedisCommands.BRPOPLPUSH, srcKey, dstKey, timeout); } + private static final RedisCommand> LPOS = new RedisCommand<>("LPOS", new ObjectListReplayDecoder<>()); + + @Override + public List lPos(byte[] key, byte[] element, Integer rank, Integer count) { + List args = new ArrayList<>(); + args.add(key); + args.add(element); + if (rank != null) { + args.add("RANK"); + args.add(rank); + } + if (count != null) { + args.add("COUNT"); + args.add(count); + } + Object read = read(key, ByteArrayCodec.INSTANCE, LPOS, args.toArray()); + if (read == null) { + return Collections.emptyList(); + } else if (read instanceof Long) { + return Collections.singletonList((Long) read); + } else { + return (List) read; + } + } + private static final RedisCommand SADD = new RedisCommand("SADD"); @Override