lib/rediska/driver.rb in rediska-0.1.6 vs lib/rediska/driver.rb in rediska-0.1.7
- old
+ new
@@ -92,9 +92,15 @@
def getbit(key, offset)
return unless data[key]
data[key].unpack('B*')[0].split('')[offset].to_i
end
+ def bitcount(key, start_index = 0, end_index = -1)
+ return 0 unless data[key]
+
+ data[key][start_index..end_index].unpack('B*')[0].count('1')
+ end
+
def getrange(key, start, ending)
return unless data[key]
data[key][start..ending]
end
alias :substr :getrange