@@ -126,7 +126,11 @@ proc managedSend(
126
126
r: Redis | AsyncRedis, data: string
127
127
): Future[void ] {.multisync.} =
128
128
when r is Redis:
129
- r.socket.send(data)
129
+ when defined(windows):
130
+ if not r.socket.tryRecv(data):
131
+ r.socket.close()
132
+ else :
133
+ r.socket.send(data)
130
134
else :
131
135
proc doSend() =
132
136
r.currentCommand = some(data)
@@ -157,7 +161,7 @@ proc managedRecvLine(r: Redis | AsyncRedis): Future[string] {.multisync.} =
157
161
result = " "
158
162
else :
159
163
when r is Redis:
160
- let taintedResult: TaintedString = recvLine(r.socket)
164
+ let taintedResult = recvLine(r.socket)
161
165
result = $ taintedResult
162
166
else :
163
167
result = await recvLine(r.socket)
@@ -237,7 +241,7 @@ proc readSingleString(
237
241
# Some commands return a /bulk/ value or a /multi-bulk/ nil. Odd.
238
242
if allowMBNil:
239
243
if line == " *-1" :
240
- return
244
+ return
241
245
242
246
if line[0 ] != '$' :
243
247
raiseInvalidReply(r, '$' , line[0 ])
@@ -342,8 +346,8 @@ proc flushPipeline*(r: Redis | AsyncRedis, wasMulti = false): Future[RedisList]
342
346
for i in 0 .. tot- 1 :
343
347
var ret = await r.readNext()
344
348
for item in ret:
345
- if not (item.contains(" OK" ) or item.contains(" QUEUED" )):
346
- result .add(item)
349
+ if not (item.contains(" OK" ) or item.contains(" QUEUED" )):
350
+ result .add(item)
347
351
348
352
r.pipeline.expected = 0
349
353
@@ -727,7 +731,7 @@ proc bRPopLPush*(r: Redis | AsyncRedis, source, destination: string,
727
731
await r.sendCommand(" BRPOPLPUSH" , source, @ [destination, $ timeout])
728
732
result = await r.readBulkString(true ) # Multi-Bulk nil allowed.
729
733
730
- proc lIndex* (r: Redis | AsyncRedis, key: string , index: int ): Future[RedisString] {.multisync.} =
734
+ proc lIndex* (r: Redis | AsyncRedis, key: string , index: int ): Future[RedisString] {.multisync.} =
731
735
# # Get an element from a list by its index
732
736
await r.sendCommand(" LINDEX" , key, @ [$ index])
733
737
result = await r.readBulkString()
@@ -789,7 +793,7 @@ proc lSet*(r: Redis | AsyncRedis, key: string, index: int, value: string): Futur
789
793
await r.sendCommand(" LSET" , key, @ [$ index, value])
790
794
raiseNoOK(r, await r.readStatus())
791
795
792
- proc lTrim* (r: Redis | AsyncRedis, key: string , start, stop: int ): Future[void ] {.multisync.} =
796
+ proc lTrim* (r: Redis | AsyncRedis, key: string , start, stop: int ): Future[void ] {.multisync.} =
793
797
# # Trim a list to the specified range
794
798
await r.sendCommand(" LTRIM" , key, @ [$ start, $ stop])
795
799
raiseNoOK(r, await r.readStatus())
@@ -927,7 +931,7 @@ proc zcount*(r: Redis | AsyncRedis, key: string, min: string, max: string): Futu
927
931
result = await r.readInteger()
928
932
929
933
proc zincrby* (r: Redis | AsyncRedis, key: string , increment: string ,
930
- member: string ): Future[RedisString] {.multisync.} =
934
+ member: string ): Future[RedisString] {.multisync.} =
931
935
# # Increment the score of a member in a sorted set
932
936
await r.sendCommand(" ZINCRBY" , key, @ [increment, member])
933
937
result = await r.readBulkString()
@@ -1364,9 +1368,9 @@ proc someTests(r: Redis | AsyncRedis, how: SendMode): Future[seq[string]] {.mult
1364
1368
for r in res:
1365
1369
list.add(r)
1366
1370
list.add(await r.get(" invalid_key" ))
1367
- list.add($ (await r.lPush(" mylist" ," itema" )))
1368
- list.add($ (await r.lPush(" mylist" ," itemb" )))
1369
- await r.lTrim(" mylist" ,0 , 1 )
1371
+ list.add($ (await r.lPush(" mylist" , " itema" )))
1372
+ list.add($ (await r.lPush(" mylist" , " itemb" )))
1373
+ await r.lTrim(" mylist" , 0 , 1 )
1370
1374
var p = await r.lRange(" mylist" , 0 , - 1 )
1371
1375
1372
1376
for i in items(p):
0 commit comments