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

Fix commands with arg seq #24

Merged
merged 1 commit into from
May 14, 2021
Merged
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
24 changes: 8 additions & 16 deletions src/redis.nim
Original file line number Diff line number Diff line change
Expand Up @@ -549,8 +549,7 @@ proc bitCount*(r: Redis | AsyncRedis, key: string, limits: seq[string]): Future[

proc bitPos*(r: Redis | AsyncRedis, key: string, bit: int, limits: seq[string]): Future[RedisInteger] {.multisync.} =
## Returns position of the first occurence of bit within limits
var parameters: seq[string]
newSeq(parameters, len(limits) + 1)
var parameters = newSeqOfCap[string](len(limits) + 1)
parameters.add($bit)
parameters.add(limits)

Expand Down Expand Up @@ -699,8 +698,7 @@ proc hVals*(r: Redis | AsyncRedis, key: string): Future[RedisList] {.multisync.}
proc bLPop*(r: Redis | AsyncRedis, keys: seq[string], timeout: int): Future[RedisList] {.multisync.} =
## Remove and get the *first* element in a list, or block until
## one is available
var args: seq[string]
newSeq(args, len(keys) + 1)
var args = newSeqOfCap[string](len(keys) + 1)
for i in items(keys):
args.add(i)

Expand All @@ -712,8 +710,7 @@ proc bLPop*(r: Redis | AsyncRedis, keys: seq[string], timeout: int): Future[Redi
proc bRPop*(r: Redis | AsyncRedis, keys: seq[string], timeout: int): Future[RedisList] {.multisync.} =
## Remove and get the *last* element in a list, or block until one
## is available.
var args: seq[string]
newSeq(args, len(keys) + 1)
var args = newSeqOfCap[string](len(keys) + 1)
for i in items(keys):
args.add(i)

Expand Down Expand Up @@ -942,9 +939,8 @@ proc zinterstore*(r: Redis | AsyncRedis, destination: string, numkeys: string,
aggregate: string = ""): Future[RedisInteger] {.multisync.} =
## Intersect multiple sorted sets and store the resulting sorted set in
## a new key
var args: seq[string]
let argsLen = 2 + len(keys) + (if len(weights) > 0: len(weights) + 1 else: 0) + (if len(aggregate) > 0: 1 + len(aggregate) else: 0)
newSeq(args, argsLen)
var args = newSeqofCap[string](argsLen)

args.add(destination)
args.add(numkeys)
Expand Down Expand Up @@ -979,8 +975,7 @@ proc zrangebyscore*(r: Redis | AsyncRedis, key: string, min: string, max: string
withScores: bool = false, limit: bool = false,
limitOffset: int = 0, limitCount: int = 0): Future[RedisList] {.multisync.} =
## Return a range of members in a sorted set, by score
var args: seq[string]
newSeq(args, 3 + (if withScores: 1 else: 0) + (if limit: 3 else: 0))
var args = newSeqOfCap[string](3 + (if withScores: 1 else: 0) + (if limit: 3 else: 0))
args.add(key)
args.add(min)
args.add(max)
Expand All @@ -998,8 +993,7 @@ proc zrangebylex*(r: Redis | AsyncRedis, key: string, start: string, stop: strin
limit: bool = false, limitOffset: int = 0,
limitCount: int = 0): Future[RedisList] {.multisync.} =
## Return a range of members in a sorted set, ordered lexicographically
var args: seq[string]
newSeq(args, 3 + (if limit: 3 else: 0))
var args = newSeqOfCap[string](3 + (if limit: 3 else: 0))
args.add(key)
args.add(start)
args.add(stop)
Expand Down Expand Up @@ -1052,8 +1046,7 @@ proc zrevrangebyscore*(r: Redis | AsyncRedis, key: string, min: string, max: str
limitOffset: int = 0, limitCount: int = 0): Future[RedisList] {.multisync.} =
## Return a range of members in a sorted set, by score, with
## scores ordered from high to low
var args: seq[string]
newSeq(args, 3 + (if withScores: 1 else: 0) + (if limit: 3 else: 0))
var args = newSeqOfCap[string](3 + (if withScores: 1 else: 0) + (if limit: 3 else: 0))
args.add(key)
args.add(min)
args.add(max)
Expand Down Expand Up @@ -1085,8 +1078,7 @@ proc zunionstore*(r: Redis | AsyncRedis, destination: string, numkeys: string,
keys: seq[string], weights: seq[string] = @[],
aggregate: string = ""): Future[RedisInteger] {.multisync.} =
## Add multiple sorted sets and store the resulting sorted set in a new key
var args: seq[string]
newSeq(args, 2 + len(keys) + (if len(weights) > 0: 1 + len(weights) else: 0) + (if len(aggregate) > 0: 1 + len(aggregate) else: 0))
var args = newSeqOfCap[string](2 + len(keys) + (if len(weights) > 0: 1 + len(weights) else: 0) + (if len(aggregate) > 0: 1 + len(aggregate) else: 0))
args.add(destination)
args.add(numkeys)

Expand Down