Skip to content
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

add bitfield, bitfield_ro #39

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions commands.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,13 @@ Warning: left for backwards compatibility. It is now called: GETRANGE.")
"Count set bits in a string at KEY
\(with optional bounding indices START and END).")

(def-cmd BITFIELD (key &rest args) :multi
"Treats a Redis string as an array of bits, takes a list of
\operations, returns an array of replies.")

(def-cmd BITFIELD_RO (key &rest args) :multi
"Read-only variant of BITFIELD")

(defmethod tell :before ((cmd (eql 'BITCOUNT)) &rest args)
(assert (or (null (second args)) (third args))))

Expand Down
4 changes: 4 additions & 0 deletions test.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -475,6 +475,10 @@
(red-bitcount "mykey"))
(should be = 16
(red-bitop "NOT" "mykey2" "mykey"))
(should be equal '("1" "1")
(red-bitfield "bitfield:test" "incrby" "u2" 100 1 "OVERFLOW" "SAT" "incrby" "u2" 102 1))
(should be equal '("1")
(red-bitfield_ro "bitfield:test" "GET" "u2" 100))
(should be string= "Uhis is a Redisg"
(red-get "mykey"))
(should be = 16
Expand Down