Skip to content

Commit

Permalink
[FEAT] Jedis - Zfunctions - Added functionality for zrange usability
Browse files Browse the repository at this point in the history
  • Loading branch information
jacksoncalvert authored and captchanjack committed Nov 16, 2021
1 parent 6df4c8f commit d528cef
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "Jedis"
uuid = "b89ccfe0-2c5f-46f6-b89b-da3e1c2e286f"
authors = ["Jack Chan <[email protected]>"]
version = "0.2.5"
version = "0.2.6"

[deps]
MbedTLS = "739be429-bea8-5141-9913-cc70e7f3736d"
Expand Down
4 changes: 2 additions & 2 deletions src/Jedis.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ export Client, Pipeline, RedisError, get_global_client, set_global_client, get_s
ping, flushdb, flushall, quit, set, setnx, get, del, exists, hexists, hkeys, setex,
expire, ttl, multi, exec, multi_exec, pipeline, hset, hget, hgetall, hmget, hdel, rpush,
lpush, lpos, lrem, lpop, rpop, blpop, brpop, llen, lrange, publish, subscribe, unsubscribe,
psubscribe, punsubscribe, incr, incrby, incrbyfloat, hincrby, hincrbyfloat, zincrby,
acquire_lock, release_lock, redis_lock, isredislocked
psubscribe, punsubscribe, incr, incrby, incrbyfloat, hincrby, hincrbyfloat, zincrby, zadd,
zrange, zrangebyscore, zrem, acquire_lock, release_lock, redis_lock, isredislocked

using Sockets
using MbedTLS
Expand Down
32 changes: 31 additions & 1 deletion src/commands.jl
Original file line number Diff line number Diff line change
Expand Up @@ -333,4 +333,34 @@ hincrbyfloat(key, field, increment; client=get_global_client()) = execute(["HINC
Increment the score of a member in a sorted set.
"""
zincrby(key, field, increment; client=get_global_client()) = execute(["ZINCRBY", key, field, increment], client)
zincrby(key, field, increment; client=get_global_client()) = execute(["ZINCRBY", key, field, increment], client)

"""
zadd(key, score, member[, score_and_members...])
Add one or more members to a sorted set, or update its score if it
already exists.
"""
zadd(key, score, member, score_and_members...; client=get_global_client()) = execute(["ZADD", key, score, member, score_and_members...], client)

"""
zrange(key, min, max)
Store a range of members from sorted set into another key.
"""
zrange(key, min, max; client=get_global_client()) = execute(["ZRANGE", key, min, max], client)

"""
zrangebyscore(key, min, max)
Return a range of members in a sorted set, by score.
"""
zrangebyscore(key, min, max; client=get_global_client()) = execute(["ZRANGEBYSCORE", key, min, max], client)

"""
zrem(key, member[, members...])
Remove one or more members from a sorted set.
"""
zrem(key, member, members...; client=get_global_client()) = execute(["ZREM", key, member, members...], client)

14 changes: 14 additions & 0 deletions test/test_commands.jl
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,20 @@ end
flushall()
end

@testset "ZFUNC" begin
@test zadd("testscore", 1, "test1") == 1
@test zadd("testscore", 2, "test2") == 1
@test zrange("testscore", 0, -1) == ["test1", "test2"]
@test zrange("testscore", 0, 1) == ["test1", "test2"]
@test zrange("testscore", 1, 1) == ["test2"]
@test zrangebyscore("testscore", 1, 1) == ["test1"]
@test zrem("testscore", "test1") == 1
@test zadd("testscore", 1, "test1", 3, "test3") == 2
@test zrem("testscore", "test1", "test3") == 2
@test zrange("testscore", 0, -1) == ["test2"]
flushall()
end

# @testset "QUIT" begin
# @test quit() == "OK"
# @test_throws Base.IOError ping()
Expand Down

2 comments on commit d528cef

@captchanjack
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/48832

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.2.6 -m "<description of version>" d528cef530039208f52986b0e482d6c3284f843b
git push origin v0.2.6

Please sign in to comment.