Skip to content

Commit 085dca5

Browse files
avikstanmaykm
andauthored
Add keys to evalscript (#109)
* Add keys to evalsha Shouldn't `evalscript` take a `keys` argument, at least according to https://redis.io/docs/latest/commands/eval/ ? * Fix tests * use new evalscript method signature always --------- Co-authored-by: tan <[email protected]>
1 parent 645c8f6 commit 085dca5

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

src/commands.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -213,8 +213,8 @@ end
213213

214214
# Scripting commands
215215
# TODO: PipelineConnection and TransactionConnection
216-
function evalscript(conn::RedisConnection, script, numkeys::Integer, args)
217-
response = execute_command(conn, flatten_command("eval", script, numkeys, args))
216+
function evalscript(conn::RedisConnection, script, numkeys::Integer, keys, args)
217+
response = execute_command(conn, flatten_command("eval", script, numkeys, keys, args))
218218
return response
219219
end
220220

test/redis_tests.jl

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -333,23 +333,24 @@ function redis_tests(conn = RedisConnection())
333333

334334
@testset "Scripting" begin
335335
script = "return {KEYS[1], KEYS[2], ARGV[1], ARGV[2]}"
336-
args = ["key1", "key2", "first", "second"]
337-
resp = evalscript(conn, script, 2, args)
338-
@test resp == args
336+
keys = ["key1", "key2"]
337+
args = ["first", "second"]
338+
resp = evalscript(conn, script, 2, keys, args)
339+
@test resp == vcat(keys, args)
339340
del(conn, "key1")
340341

341342
script = "return redis.call('set', KEYS[1], 'bar')"
342343
ky = "foo"
343-
resp = evalscript(conn, script, 1, [ky])
344+
resp = evalscript(conn, script, 1, [ky], [])
344345
@test resp == "OK"
345346
del(conn, ky)
346347

347348
script = "return {10,20}"
348-
resp = evalscript(conn, script, 0, [])
349+
resp = evalscript(conn, script, 0, [], [])
349350
@test resp == [10, 20]
350351

351352
script = "return"
352-
resp = evalscript(conn, script, 0, [])
353+
resp = evalscript(conn, script, 0, [], [])
353354
@test resp === nothing
354355

355356
#@test evalscript(conn, "return {'1','2',{'3','Hello World!'}}", 0, []) == ["1"; "2"; ["3","Hello World!"]]

0 commit comments

Comments
 (0)