Skip to content

feat(commands): blocking list operations (BLPOP/BRPOP/BLMOVE/BLMPOP/BRPOPLPUSH) #56

Description

@TinDang97

Summary

Moon does not implement any of the blocking list commands. Clients using Moon as a Redis-compatible work queue (Sidekiq-style, Celery broker, custom BLPOP consumers) will fail with -ERR unknown command.

Missing commands

  • BLPOP key [key ...] timeout
  • BRPOP key [key ...] timeout
  • BLMOVE src dst LEFT|RIGHT LEFT|RIGHT timeout
  • BLMPOP timeout numkeys key [key ...] LEFT|RIGHT [COUNT count]
  • BRPOPLPUSH src dst timeout (deprecated in Redis 6.2 but still widely used)

Design notes

  • Need per-key wait queue. Natural fit: attach an Option<SmallVec<Waker>> to each list entry in the shard's DashTable.
  • On LPUSH/RPUSH, if the key has waiters, wake the oldest and hand off the element directly (avoid the push + immediate pop round trip).
  • Timeout handling: drive off the shard's cached timestamp tick, not per-client timers. Reuse the expiration wheel.
  • Cross-shard BLPOP key1 key2 where keys live on different shards: register waiters on each shard, first to fire wins — requires a shared cancellation token.
  • Client state: connection must be marked blocked; CLIENT UNPAUSE / CLIENT KILL must unblock.

Acceptance criteria

  • Consistency test entry (scripts/test-consistency.sh) comparing output to Redis for: immediate-return case, true-blocking case, timeout case, multi-key case.
  • No .await while holding a shard lock.
  • No per-blocked-client allocation on the hot path.
  • Works under both runtime-tokio and runtime-monoio.

References

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestredis-parityMissing Redis commands / parity gaps

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions