Browse files

EVAL: Fixed bug and added ARGVs

  • Loading branch information...
1 parent f39f70d commit 950c3eb30ab454827e3d04e34c2f8f281c1540d4 @cstar committed Jun 1, 2011
Showing with 6 additions and 4 deletions.
  1. +5 −3 src/erldis.erl
  2. +1 −1 test/erldis_tests.erl
View
8 src/erldis.erl
@@ -394,12 +394,14 @@ flushall(Client) -> erldis_client:sr_scall(Client, <<"flushall">>).
%%%%%%%%%%%%%%%%%%%%%%%
%% Script evaluation %%
%%%%%%%%%%%%%%%%%%%%%%%
-
-eval(Client, Script, Keys)->
+eval(Client, Script, Keys) ->
+ eval(Client, Script, Keys, []).
+
+eval(Client, Script, Keys, Args)->
Len = length(Keys),
lists:map(fun(L)->
numeric(L)
- end, erldis_client:scall(Client, [<<"eval">>, Script, Len, Keys])).
+ end, erldis_client:scall(Client, lists:flatten([<<"eval">>, Script, Len, Keys, Args]))).
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
View
2 test/erldis_tests.erl
@@ -213,7 +213,7 @@ eval_test()->
?assertEqual([{error, <<"Some Error">>}],
erldis:eval(Client, <<"return {err='Some Error'}">>,[])),
?assertEqual([1, 2, <<"a">>, <<"ba">>],erldis:eval(Client, <<"return {1,2,'a','ba'}">>, [])),
- erldis:set(Client, <<"martin">>, <<"sacha">>),
+ ?assertEqual([ok],erldis:eval(Client, <<"return redis.call('set', KEYS[1], ARGV[1])">>, [<<"martin">>], [<<"sacha">>])),
?assertEqual([<<"sacha">>],erldis:eval(Client, <<"return redis.call('get', 'martin')">>, [])),
?assertEqual([<<"sacha">>],erldis:eval(Client, <<"return redis.call('get', KEYS[1])">>, [<<"martin">>])),
ok.

0 comments on commit 950c3eb

Please sign in to comment.