Skip to content
Browse files

add binary level commands setbit getbit

  • Loading branch information...
1 parent 23c28fd commit 59223baa72ab0a99322841da8df4774b487d3d1f @hungryblank hungryblank committed Apr 3, 2011
Showing with 16 additions and 0 deletions.
  1. +10 −0 src/erldis.erl
  2. +6 −0 test/erldis_tests.erl
View
10 src/erldis.erl
@@ -275,6 +275,16 @@ hvals(Client, Key) -> erldis_client:scall(Client, [<<"hvals">>, Key]).
hgetall(Client, Key) ->
tuplelist(erldis_client:scall(Client, [<<"hgetall">>, Key])).
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%% Commands operating on binary values %%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+setbit(Client, Key, Offset, Value) ->
+ numeric(erldis_client:sr_scall(Client, [<<"setbit">>, Key, Offset, Value])).
+
+getbit(Client, Key, Offset) ->
+ numeric(erldis_client:sr_scall(Client, [<<"getbit">>, Key, Offset])).
+
%%%%%%%%%%%%%
%% Sorting %%
%%%%%%%%%%%%%
View
6 test/erldis_tests.erl
@@ -164,6 +164,12 @@ zset_test() ->
?assertEqual(shutdown, erldis:quit(Client)).
+binary_test() ->
+ {ok, Client} = erldis:connect("localhost", 6379),
+ ?assertEqual(ok, erldis:flushdb(Client)),
+ ?assertEqual(0, erldis:setbit(Client, <<"bin_key">>, 7, 1)),
+ ?assertEqual(1, erldis:getbit(Client, <<"bin_key">>, 7)).
+
% inline_tests(Client) ->
% [?_assertMatch(ok, erldis:set(Client, <<"hello">>, <<"kitty!">>)),
% ?_assertMatch(false, erldis:setnx(Client, <<"hello">>, <<"kitty!">>)),

0 comments on commit 59223ba

Please sign in to comment.
Something went wrong with that request. Please try again.