Skip to content

Commit

Permalink
Merge pull request #114 from atoptima/feat/bzpopmin
Browse files Browse the repository at this point in the history
adding bzpopmin function
  • Loading branch information
jkaye2012 authored Nov 21, 2024
2 parents 0347f25 + c9a4a97 commit 2f5ab2a
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 2 deletions.
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

0 comments on commit 2f5ab2a

Please sign in to comment.