Module: Redis::Commands::Bitmaps
Relationships & Source Files | |
Extension / Inclusion / Inheritance Descendants | |
Included In:
| |
Defined in: | lib/redis/commands/bitmaps.rb |
Instance Method Summary
-
#bitcount(key, start = 0, stop = -1,, scale: nil) ⇒ Integer
Count the number of set bits in a range of the string value stored at key.
-
#bitop(operation, destkey, *keys) ⇒ Integer
Perform a bitwise operation between strings and store the resulting string in a key.
-
#bitpos(key, bit, start = nil, stop = nil, scale: nil) ⇒ Integer
Return the position of the first bit set to 1 or 0 in a string.
-
#getbit(key, offset) ⇒ Integer
Returns the bit value at offset in the string value stored at key.
-
#setbit(key, offset, value) ⇒ Integer
Sets
or clears the bit at offset in the string value stored at key.
Instance Method Details
#bitcount(key, start = 0, stop = -1,, scale: nil) ⇒ Integer
Count the number of set bits in a range of the string value stored at key.
# File 'lib/redis/commands/bitmaps.rb', line 33
def bitcount(key, start = 0, stop = -1, scale: nil) command = [:bitcount, key, start, stop] command << scale if scale send_command(command) end
#bitop(operation, destkey, *keys) ⇒ Integer
Perform a bitwise operation between strings and store the resulting string in a key.
# File 'lib/redis/commands/bitmaps.rb', line 45
def bitop(operation, destkey, *keys) keys.flatten!(1) command = [:bitop, operation, destkey] command.concat(keys) send_command(command) end
#bitpos(key, bit, start = nil, stop = nil, scale: nil) ⇒ Integer
Return the position of the first bit set to 1 or 0 in a string.
# File 'lib/redis/commands/bitmaps.rb', line 62
def bitpos(key, bit, start = nil, stop = nil, scale: nil) raise(ArgumentError, 'stop parameter specified without start parameter') if stop && !start command = [:bitpos, key, bit] command << start if start command << stop if stop command << scale if scale send_command(command) end
#getbit(key, offset) ⇒ Integer
Returns the bit value at offset in the string value stored at key.
# File 'lib/redis/commands/bitmaps.rb', line 21
def getbit(key, offset) send_command([:getbit, key, offset]) end
#setbit(key, offset, value) ⇒ Integer
Sets
or clears the bit at offset in the string value stored at key.
# File 'lib/redis/commands/bitmaps.rb', line 12
def setbit(key, offset, value) send_command([:setbit, key, offset, value]) end