guile-redis
guile-redis copied to clipboard
Sending null values in an `EVAL` script.
Hi there, I was trying to send an EVAL script that takes as argument a possibly null value, but it seems the type dispatch here does not allow it. If I understand correctly, passing an empty string is prepended by 0 (the length) and thus do not match Redis' .
My script (a Lua implementation of a kind of CAS):
local w = redis.call('GET', ARGV[1]);
if (w == ARGV[2]) then
redis.call('SET', ARGV[3], ARGV[4]);
end;
return w;
Steps to reproduce it:
scheme@(guile-user)> (display script)
local w = redis.call('GET', ARGV[1]);
if (w == ARGV[2]) then
return "OK";
else
return "NOK";
end;
scheme@(guile-user)> (use-modules (redis))
scheme@(guile-user)> (define cnx (redis-connect))
scheme@(guile-user)> (redis-send cnx (eval (list script 0 0 "")))
$8 = "NOK"
scheme@(guile-user)> (redis-send cnx (eval (list script 0 0 '())))
ice-9/boot-9.scm:1685:16: In procedure raise-exception:
Throw to key `redis-invalid' with args `()'.
Entering a new prompt. Type `,bt' for a backtrace or `,q' to continue.
I also tried the following (after this doc):
scheme@(guile-user)> (redis-send cnx (eval (list script 0 0 "_\r\n")))
$9 = "NOK"
scheme@(guile-user)> (redis-send cnx (eval (list script 0 0 "_")))
$10 = "NOK"
My script works for non-null values:
scheme@(guile-user)> (redis-send cnx (set '(0 0)))
$12 = "OK"
scheme@(guile-user)> (redis-send cnx (eval (list script 0 0 0)))
$13 = "OK"