Merge pull request #4056 from woodyDM/fix_redissonConnection_lpos

Fixed - RedissonConnection add lpos command
pull/4061/head
Nikita Koksharov 3 years ago committed by GitHub
commit 9282d4dd9a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -785,6 +785,31 @@ public class RedissonConnection extends AbstractRedisConnection {
return write(srcKey, ByteArrayCodec.INSTANCE, RedisCommands.BRPOPLPUSH, srcKey, dstKey, timeout);
}
private static final RedisCommand<List<Long>> LPOS = new RedisCommand<>("LPOS", new ObjectListReplayDecoder<>());
@Override
public List<Long> lPos(byte[] key, byte[] element, Integer rank, Integer count) {
List<Object> 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<Long>) read;
}
}
private static final RedisCommand<Long> SADD = new RedisCommand<Long>("SADD");
@Override

@ -785,6 +785,31 @@ public class RedissonConnection extends AbstractRedisConnection {
return write(srcKey, ByteArrayCodec.INSTANCE, RedisCommands.BRPOPLPUSH, srcKey, dstKey, timeout);
}
private static final RedisCommand<List<Long>> LPOS = new RedisCommand<>("LPOS", new ObjectListReplayDecoder<>());
@Override
public List<Long> lPos(byte[] key, byte[] element, Integer rank, Integer count) {
List<Object> 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<Long>) read;
}
}
private static final RedisCommand<Long> SADD = new RedisCommand<Long>("SADD");
@Override

@ -785,6 +785,31 @@ public class RedissonConnection extends AbstractRedisConnection {
return write(srcKey, ByteArrayCodec.INSTANCE, RedisCommands.BRPOPLPUSH, srcKey, dstKey, timeout);
}
private static final RedisCommand<List<Long>> LPOS = new RedisCommand<>("LPOS", new ObjectListReplayDecoder<>());
@Override
public List<Long> lPos(byte[] key, byte[] element, Integer rank, Integer count) {
List<Object> 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<Long>) read;
}
}
private static final RedisCommand<Long> SADD = new RedisCommand<Long>("SADD");
@Override

Loading…
Cancel
Save