-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Support BIT/BYTE
for bitcount
and bitpos
for redis 7+
#1242
Conversation
What about: |
9c6af45
to
d04583b
Compare
👍 for |
d04583b
to
2d0bc45
Compare
lib/redis/commands/bitmaps.rb
Outdated
send_command([:bitcount, key, start, stop]) | ||
def bitcount(key, start = 0, stop = -1, scale: 'BYTE') | ||
command = [:bitcount, key, start, stop] | ||
command << 'BIT' if scale.to_s.upcase == 'BIT' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
command << 'BIT' if scale.to_s.upcase == 'BIT' | |
command << 'BIT' if scale. |
I think we should append it unless it's not set. Because here if I pass scale: "lol"
, it will silently do nothing.
With scale: nil
in the signature.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed, thanks.
2d0bc45
to
9a6abb4
Compare
lib/redis/commands/bitmaps.rb
Outdated
@@ -27,9 +27,13 @@ def getbit(key, offset) | |||
# @param [String] key | |||
# @param [Integer] start start index | |||
# @param [Integer] stop stop index | |||
# @param [String, Symbol] scale the scale of the offset range | |||
# e.g. 'BYTE' - interpreted as a range of bytes, 'BIT' - interpreted as a range of bites |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
# e.g. 'BYTE' - interpreted as a range of bytes, 'BIT' - interpreted as a range of bites | |
# e.g. 'BYTE' - interpreted as a range of bytes, 'BIT' - interpreted as a range of bits |
lib/redis/commands/bitmaps.rb
Outdated
send_command([:bitcount, key, start, stop]) | ||
def bitcount(key, start = 0, stop = -1, scale: nil) | ||
command = [:bitcount, key, start, stop] | ||
command << scale.to_s.upcase if scale |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wouldn't even bother with the to_s.upcase
, we can directly pass it to redis in lower case, it's no problem.
9a6abb4
to
df08cd0
Compare
Reference #1187
Redis 7.0 release notes - https://raw.githubusercontent.com/redis/redis/7.0/00-RELEASENOTES
I am not very happy with the
bytes_range
parameter name. Maybe you can suggest something better? Maybeuse_bytes
oroffset_unit
etc...