Skip to content

Commit 2f5ab2a

Browse files
authored
Merge pull request #114 from atoptima/feat/bzpopmin
adding bzpopmin function
2 parents 0347f25 + c9a4a97 commit 2f5ab2a

File tree

4 files changed

+14
-2
lines changed

4 files changed

+14
-2
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name = "Redis"
22
uuid = "0cf705f9-a9e2-50d1-a699-2b372a39b750"
3-
version = "3.0.0"
3+
version = "3.0.1"
44

55
[deps]
66
DataStructures = "864edb3b-99cc-5e75-8d2d-829cb0a9cfe8"

src/Redis.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ export sadd, scard, sdiff, sdiffstore, sinter, sinterstore,
3535
export zadd, zcard, zcount, zincrby, zinterstore, zlexcount,
3636
zrange, zrangebylex, zrangebyscore, zrank, zrem,
3737
zremrangebylex, zremrangebyrank, zremrangebyscore, zrevrange,
38-
zrevrangebyscore, zrevrank, zscore, zunionstore, zscan,
38+
zrevrangebyscore, zrevrank, zscore, zunionstore, zscan, bzpopmin,
3939
Aggregate
4040
# HyperLogLog commands
4141
export pfadd, pfcount, pfmerge

src/commands.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,8 @@ resorting to the use of `Dict`, which cannot be used in the case where all entri
164164
# number), represented as string.
165165
@redisfunction "zscore" Union{AbstractString, Nothing} key member
166166
@redisfunction "zscan" Set{AbstractString} key cursor::Integer options...
167+
# bzpopmin returns [key, data, score] or nothing if timeout is reached
168+
@redisfunction "bzpopmin" Union{Array{AbstractString, 1}, Nothing} keys timeout
167169

168170
function _build_store_internal(destination, numkeys, keys, weights, aggregate, command)
169171
length(keys) > 0 || throw(ClientException("Must supply at least one key"))

test/redis_tests.jl

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -325,6 +325,16 @@ function redis_tests(conn = RedisConnection())
325325
vals2 = ["a", "b", "c", "d"]
326326
@test zinterstore(conn, testkey3, 2, [testkey, testkey2]) == 4
327327
del(conn, testkey, testkey2, testkey3)
328+
329+
# test using bzpopmin
330+
vals2 = ["a", "b", "c", "d"]
331+
zadd(conn, testkey, zip([4, 2, 1, 3], vals2)...)
332+
@test bzpopmin(conn, testkey, 0) == [testkey, "c", "1"]
333+
@test bzpopmin(conn, testkey, 0) == [testkey, "b", "2"]
334+
@test bzpopmin(conn, testkey, 0) == [testkey, "d", "3"]
335+
@test bzpopmin(conn, testkey, 0) == [testkey, "a", "4"]
336+
@test bzpopmin(conn, testkey, 0.1) == nothing
337+
del(conn, testkey)
328338
end
329339

330340
@testset "Scan" begin

0 commit comments

Comments
 (0)