Skip to content

Commit

Permalink
Merge pull request #111 from JuliaDatabases/tan/scriptexec
Browse files Browse the repository at this point in the history
feat: allow evalscript on pipelines & transactions
  • Loading branch information
jkaye2012 authored Jul 15, 2024
2 parents 085dca5 + d2dd26a commit 249a92e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
3 changes: 1 addition & 2 deletions src/commands.jl
Original file line number Diff line number Diff line change
Expand Up @@ -212,8 +212,7 @@ end
@redisfunction "watch" Bool key keys...

# Scripting commands
# TODO: PipelineConnection and TransactionConnection
function evalscript(conn::RedisConnection, script, numkeys::Integer, keys, args)
function evalscript(conn::Union{RedisConnection,PipelineConnection,TransactionConnection}, script, numkeys::Integer, keys, args)
response = execute_command(conn, flatten_command("eval", script, numkeys, keys, args))
return response
end
Expand Down
11 changes: 10 additions & 1 deletion test/redis_tests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -378,21 +378,30 @@ function redis_tests(conn = RedisConnection())
@test exec(trans) == ["OK", "foobar"]
@test del(trans, testkey) == "QUEUED"
@test exec(trans) == [true]
@test evalscript(trans, "return", 0, [], []) == "QUEUED"
@test exec(trans) == [nothing]
disconnect(trans)
end

@testset "Pipelines" begin
pipe = open_pipeline(conn)
set(pipe, testkey3, "anything")
@test length(read_pipeline(pipe)) == 1

get(pipe, testkey3)
set(pipe, testkey4, "testing")
result = read_pipeline(pipe)
@test length(result) == 2
@test result == ["anything", "OK"]

@test del(pipe, testkey3) == 1
@test del(pipe, testkey4) == 2
@test result == ["anything", "OK"]
result = read_pipeline(pipe)
@test result == [1, 1]

evalscript(pipe, "return", 0, [], [])
result = read_pipeline(pipe)
@test result == []
disconnect(pipe)
end

Expand Down

0 comments on commit 249a92e

Please sign in to comment.