Skip to content

Add support for ZPOPMIN and ZPOPMAX commands including blocking variants #2007

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
max-end opened this issue Mar 19, 2021 · 4 comments
Closed
Assignees
Labels

Comments

@max-end
Copy link

max-end commented Mar 19, 2021

redisTemplate is not suport zpopmin、zpopmax instructions?

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Mar 19, 2021
@mp911de mp911de changed the title zpopmin、zpopmax support? RedisTemplate does not support ZPOPMIN and ZPOPMAX Mar 19, 2021
@mp911de
Copy link
Member

mp911de commented Mar 19, 2021

Thanks for reaching out. We're happy to review a pull request that introduces this functionality. Until then you can use RedisConnection.execute(…) to call Redis commands yourself that aren't exposed through a Java method.

@mp911de mp911de added type: enhancement A general enhancement status: ideal-for-contribution An issue that a contributor can help us with and removed status: waiting-for-triage An issue we've not yet triaged labels Mar 19, 2021
@max-end
Copy link
Author

max-end commented Mar 19, 2021

Thanks for reaching out. We're happy to review a pull request that introduces this functionality. Until then you can use RedisConnection.execute(…) to call Redis commands yourself that aren't exposed through a Java method.

Can you help me? thank you

RedisConnection redisConnection=redisTemplate.getRequiredConnectionFactory().getConnection(); Object o = redisConnection.execute("zpopmin","TESTLIST".getBytes());

java.lang.IllegalStateException: io.lettuce.core.output.ByteArrayOutput does not support set(double)

at io.lettuce.core.output.CommandOutput.set(CommandOutput.java:118)
at io.lettuce.core.protocol.RedisStateMachine.safeSet(RedisStateMachine.java:794)
at io.lettuce.core.protocol.RedisStateMachine.handleFloat(RedisStateMachine.java:426)
at io.lettuce.core.protocol.RedisStateMachine$State$Type.handle(RedisStateMachine.java:206)
at io.lettuce.core.protocol.RedisStateMachine.doDecode(RedisStateMachine.java:334)
at io.lettuce.core.protocol.RedisStateMachine.decode(RedisStateMachine.java:295)
at io.lettuce.core.protocol.CommandHandler.decode(CommandHandler.java:832)
at io.lettuce.core.protocol.CommandHandler.decode0(CommandHandler.java:783)
at io.lettuce.core.protocol.CommandHandler.decode(CommandHandler.java:766)
at io.lettuce.core.protocol.CommandHandler.decode(CommandHandler.java:649)
at io.lettuce.core.protocol.CommandHandler.channelRead(CommandHandler.java:589)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357)
at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1410)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)
at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:919)
at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:166)
at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:719)
at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:655)
at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:581)
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:493)
at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:989)
at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
at java.lang.Thread.run(Thread.java:748)

@mp911de
Copy link
Member

mp911de commented Mar 19, 2021

When using Lettuce, you need to provide a CommandOutput to capture the Redis response. For [B]ZPOP[MIN|MAX] that's new ScoredValueOutput<>(ByteArrayCodec.INSTANCE) (via execute(String command, @Nullable CommandOutput commandOutputTypeHint, byte[]... args)).

Spring Data Redis doesn't have yet command output hints for these commands.

@mp911de mp911de self-assigned this Jun 15, 2021
@mp911de mp911de removed the status: ideal-for-contribution An issue that a contributor can help us with label Jun 15, 2021
@mp911de mp911de changed the title RedisTemplate does not support ZPOPMIN and ZPOPMAX Add support for ZPOPMIN and ZPOPMAX commands including blocking variants Jun 15, 2021
@mp911de mp911de added this to the 2.6 M1 (2021.1.0) milestone Jun 15, 2021
mp911de added a commit that referenced this issue Jun 16, 2021
We now support ZPOPMIN, BZPOPMIN, ZPOPMAX and BZPOPMAX through the Template API for all drivers.

Closes #2007
mp911de added a commit that referenced this issue Jun 16, 2021
Improve Javadoc. Add static factory methods for easier RedisZSet construction.

See #2007
mp911de added a commit that referenced this issue Jun 23, 2021
We now support ZPOPMIN, BZPOPMIN, ZPOPMAX and BZPOPMAX through the Template API for all drivers.

Closes #2007
mp911de added a commit that referenced this issue Jun 23, 2021
Improve Javadoc. Add static factory methods for easier RedisZSet construction.

See #2007
@mp911de mp911de linked a pull request Jun 28, 2021 that will close this issue
christophstrobl pushed a commit that referenced this issue Jun 28, 2021
We now support ZPOPMIN, BZPOPMIN, ZPOPMAX and BZPOPMAX through the Template API for all drivers.

Closes #2007
christophstrobl pushed a commit that referenced this issue Jun 28, 2021
Improve Javadoc. Add static factory methods for easier RedisZSet construction.

See #2007
christophstrobl pushed a commit that referenced this issue Jun 29, 2021
christophstrobl pushed a commit that referenced this issue Jun 29, 2021
Improve Javadoc. Add static factory methods for easier RedisZSet construction.

See #2007
Original Pull Request: #2088
@poeschko
Copy link

Very nice to get support for these commands! Any idea yet when this will be available in a released version?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants