Add support for new BITOP operations: DIFF, DIFF1, ANDOR, ONE #3690
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds support for four new BITOP operations that will be available in Redis 8.2+: DIFF, DIFF1, ANDOR, and ONE. These operations extend Redis bitmap functionality to support common set operations that previously required multiple commands or Lua scripts.
New Operations
BITOP DIFF: Returns members of the first bitmap that are not members of any other bitmaps (X ∧ ¬(Y1 ∨ Y2 ∨ ...))
BITOP DIFF1: Returns members of any bitmap except the first that are not members of the first bitmap (¬X ∧ (Y1 ∨ Y2 ∨ ...))
BITOP ANDOR: Returns members of the first bitmap that are also members of one or more other bitmaps (X ∧ (Y1 ∨ Y2 ∨ ...))
BITOP ONE: Returns members of exactly one of the given bitmaps (generalized XOR for multiple keys)
Changes Made
Tests: Added comprehensive test coverage for all four new operations
Synchronous tests in tests/test_commands.py
Asynchronous tests in tests/test_asyncio/test_commands.py
Tests include bitwise logic verification, edge cases, and return value validation
All tests gated with @skip_if_server_version_lt("8.2.0") for compatibility