Skip to content

Commit d2dd26a

Browse files
committed
feat: allow evalscript on pipelines & transactions
This augments `evalscript` to allow it on `PipelineConnection` and `TransactionConnection`.
1 parent 085dca5 commit d2dd26a

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

src/commands.jl

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -212,8 +212,7 @@ end
212212
@redisfunction "watch" Bool key keys...
213213

214214
# Scripting commands
215-
# TODO: PipelineConnection and TransactionConnection
216-
function evalscript(conn::RedisConnection, script, numkeys::Integer, keys, args)
215+
function evalscript(conn::Union{RedisConnection,PipelineConnection,TransactionConnection}, script, numkeys::Integer, keys, args)
217216
response = execute_command(conn, flatten_command("eval", script, numkeys, keys, args))
218217
return response
219218
end

test/redis_tests.jl

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -378,21 +378,30 @@ function redis_tests(conn = RedisConnection())
378378
@test exec(trans) == ["OK", "foobar"]
379379
@test del(trans, testkey) == "QUEUED"
380380
@test exec(trans) == [true]
381+
@test evalscript(trans, "return", 0, [], []) == "QUEUED"
382+
@test exec(trans) == [nothing]
381383
disconnect(trans)
382384
end
383385

384386
@testset "Pipelines" begin
385387
pipe = open_pipeline(conn)
386388
set(pipe, testkey3, "anything")
387389
@test length(read_pipeline(pipe)) == 1
390+
388391
get(pipe, testkey3)
389392
set(pipe, testkey4, "testing")
390393
result = read_pipeline(pipe)
391394
@test length(result) == 2
392395
@test result == ["anything", "OK"]
396+
393397
@test del(pipe, testkey3) == 1
394398
@test del(pipe, testkey4) == 2
395-
@test result == ["anything", "OK"]
399+
result = read_pipeline(pipe)
400+
@test result == [1, 1]
401+
402+
evalscript(pipe, "return", 0, [], [])
403+
result = read_pipeline(pipe)
404+
@test result == []
396405
disconnect(pipe)
397406
end
398407

0 commit comments

Comments
 (0)