Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adding bzpopmin function #114

Merged
merged 6 commits into from
Nov 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name = "Redis"
uuid = "0cf705f9-a9e2-50d1-a699-2b372a39b750"
version = "3.0.0"
version = "3.0.1"

[deps]
DataStructures = "864edb3b-99cc-5e75-8d2d-829cb0a9cfe8"
Expand Down
2 changes: 1 addition & 1 deletion src/Redis.jl
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export sadd, scard, sdiff, sdiffstore, sinter, sinterstore,
export zadd, zcard, zcount, zincrby, zinterstore, zlexcount,
zrange, zrangebylex, zrangebyscore, zrank, zrem,
zremrangebylex, zremrangebyrank, zremrangebyscore, zrevrange,
zrevrangebyscore, zrevrank, zscore, zunionstore, zscan,
zrevrangebyscore, zrevrank, zscore, zunionstore, zscan, bzpopmin,
Aggregate
# HyperLogLog commands
export pfadd, pfcount, pfmerge
Expand Down
2 changes: 2 additions & 0 deletions src/commands.jl
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,8 @@ resorting to the use of `Dict`, which cannot be used in the case where all entri
# number), represented as string.
@redisfunction "zscore" Union{AbstractString, Nothing} key member
@redisfunction "zscan" Set{AbstractString} key cursor::Integer options...
# bzpopmin returns [key, data, score] or nothing if timeout is reached
@redisfunction "bzpopmin" Union{Array{AbstractString, 1}, Nothing} keys timeout

function _build_store_internal(destination, numkeys, keys, weights, aggregate, command)
length(keys) > 0 || throw(ClientException("Must supply at least one key"))
Expand Down
10 changes: 10 additions & 0 deletions test/redis_tests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,16 @@ function redis_tests(conn = RedisConnection())
vals2 = ["a", "b", "c", "d"]
@test zinterstore(conn, testkey3, 2, [testkey, testkey2]) == 4
del(conn, testkey, testkey2, testkey3)

# test using bzpopmin
vals2 = ["a", "b", "c", "d"]
zadd(conn, testkey, zip([4, 2, 1, 3], vals2)...)
@test bzpopmin(conn, testkey, 0) == [testkey, "c", "1"]
@test bzpopmin(conn, testkey, 0) == [testkey, "b", "2"]
@test bzpopmin(conn, testkey, 0) == [testkey, "d", "3"]
@test bzpopmin(conn, testkey, 0) == [testkey, "a", "4"]
@test bzpopmin(conn, testkey, 0.1) == nothing
del(conn, testkey)
end

@testset "Scan" begin
Expand Down
Loading