Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
4
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Switch to GitLab Next
Sign in / Register
Toggle navigation
RediStack
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
18
Issues
18
List
Boards
Labels
Service Desk
Milestones
Iterations
Merge Requests
3
Merge Requests
3
Requirements
Requirements
List
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Test Cases
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Code Review
Insights
Issue
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Nathan Harris
RediStack
Commits
c010e13b
Verified
Commit
c010e13b
authored
Jun 24, 2019
by
Nathan Harris
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
50 -- Rename `EventLoopFuture.mapFromRESP` to `convertFromRESPValue`
parent
e0e5a689
Pipeline
#67836208
passed with stages
in 4 minutes and 17 seconds
Changes
7
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
65 additions
and
65 deletions
+65
-65
Sources/RedisNIO/Commands/BasicCommands.swift
Sources/RedisNIO/Commands/BasicCommands.swift
+7
-7
Sources/RedisNIO/Commands/HashCommands.swift
Sources/RedisNIO/Commands/HashCommands.swift
+12
-12
Sources/RedisNIO/Commands/ListCommands.swift
Sources/RedisNIO/Commands/ListCommands.swift
+8
-8
Sources/RedisNIO/Commands/SetCommands.swift
Sources/RedisNIO/Commands/SetCommands.swift
+14
-14
Sources/RedisNIO/Commands/SortedSetCommands.swift
Sources/RedisNIO/Commands/SortedSetCommands.swift
+16
-16
Sources/RedisNIO/Commands/StringCommands.swift
Sources/RedisNIO/Commands/StringCommands.swift
+7
-7
Sources/RedisNIO/Extensions/SwiftNIO.swift
Sources/RedisNIO/Extensions/SwiftNIO.swift
+1
-1
No files found.
Sources/RedisNIO/Commands/BasicCommands.swift
View file @
c010e13b
...
...
@@ -23,7 +23,7 @@ extension RedisClient {
@inlinable
public
func
echo
(
_
message
:
String
)
->
EventLoopFuture
<
String
>
{
return
send
(
command
:
"ECHO"
,
with
:
[
message
])
.
mapFromRESP
()
.
convertFromRESPValue
()
}
/// Pings the server, which will respond with a message.
...
...
@@ -35,7 +35,7 @@ extension RedisClient {
public
func
ping
(
with
message
:
String
?
=
nil
)
->
EventLoopFuture
<
String
>
{
let
arg
=
message
!=
nil
?
[
message
]
:
[]
return
send
(
command
:
"PING"
,
with
:
arg
)
.
mapFromRESP
()
.
convertFromRESPValue
()
}
/// Select the Redis logical database having the specified zero-based numeric index.
...
...
@@ -61,7 +61,7 @@ extension RedisClient {
public
func
swapDatabase
(
_
first
:
Int
,
with
second
:
Int
)
->
EventLoopFuture
<
Bool
>
{
/// connection.swapDatabase(index: 0, withIndex: 10)
return
send
(
command
:
"SWAPDB"
,
with
:
[
first
,
second
])
.
mapFromRESP
(
to
:
String
.
self
)
.
convertFromRESPValue
(
to
:
String
.
self
)
.
map
{
return
$0
==
"OK"
}
}
...
...
@@ -75,7 +75,7 @@ extension RedisClient {
guard
keys
.
count
>
0
else
{
return
self
.
eventLoop
.
makeSucceededFuture
(
0
)
}
return
send
(
command
:
"DEL"
,
with
:
keys
)
.
mapFromRESP
()
.
convertFromRESPValue
()
}
/// Sets a timeout on key. After the timeout has expired, the key will automatically be deleted.
...
...
@@ -90,7 +90,7 @@ extension RedisClient {
public
func
expire
(
_
key
:
String
,
after
deadline
:
TimeAmount
)
->
EventLoopFuture
<
Bool
>
{
let
amount
=
deadline
.
nanoseconds
/
1_000_000_000
return
send
(
command
:
"EXPIRE"
,
with
:
[
key
,
amount
])
.
mapFromRESP
(
to
:
Int
.
self
)
.
convertFromRESPValue
(
to
:
Int
.
self
)
.
map
{
return
$0
==
1
}
}
}
...
...
@@ -142,7 +142,7 @@ extension RedisClient {
args
.
append
(
c
)
}
let
response
=
send
(
command
:
command
,
with
:
args
)
.
mapFromRESP
(
to
:
[
RESPValue
]
.
self
)
let
response
=
send
(
command
:
command
,
with
:
args
)
.
convertFromRESPValue
(
to
:
[
RESPValue
]
.
self
)
let
position
=
response
.
flatMapThrowing
{
result
->
Int
in
guard
let
value
=
result
[
0
]
.
string
,
...
...
@@ -154,7 +154,7 @@ extension RedisClient {
}
let
elements
=
response
.
map
{
return
$0
[
1
]
}
.
mapFromRESP
(
to
:
resultType
)
.
convertFromRESPValue
(
to
:
resultType
)
return
position
.
and
(
elements
)
}
...
...
Sources/RedisNIO/Commands/HashCommands.swift
View file @
c010e13b
...
...
@@ -50,7 +50,7 @@ extension RedisClient {
guard
fields
.
count
>
0
else
{
return
self
.
eventLoop
.
makeSucceededFuture
(
0
)
}
return
send
(
command
:
"HDEL"
,
with
:
[
key
]
+
fields
)
.
mapFromRESP
()
.
convertFromRESPValue
()
}
/// Checks if a hash contains the field specified.
...
...
@@ -63,7 +63,7 @@ extension RedisClient {
@inlinable
public
func
hexists
(
_
field
:
String
,
in
key
:
String
)
->
EventLoopFuture
<
Bool
>
{
return
send
(
command
:
"HEXISTS"
,
with
:
[
key
,
field
])
.
mapFromRESP
(
to
:
Int
.
self
)
.
convertFromRESPValue
(
to
:
Int
.
self
)
.
map
{
return
$0
==
1
}
}
...
...
@@ -75,7 +75,7 @@ extension RedisClient {
@inlinable
public
func
hlen
(
of
key
:
String
)
->
EventLoopFuture
<
Int
>
{
return
send
(
command
:
"HLEN"
,
with
:
[
key
])
.
mapFromRESP
()
.
convertFromRESPValue
()
}
/// Gets the string length of a hash field's value.
...
...
@@ -88,7 +88,7 @@ extension RedisClient {
@inlinable
public
func
hstrlen
(
of
field
:
String
,
in
key
:
String
)
->
EventLoopFuture
<
Int
>
{
return
send
(
command
:
"HSTRLEN"
,
with
:
[
key
,
field
])
.
mapFromRESP
()
.
convertFromRESPValue
()
}
/// Gets all field names in a hash.
...
...
@@ -99,7 +99,7 @@ extension RedisClient {
@inlinable
public
func
hkeys
(
in
key
:
String
)
->
EventLoopFuture
<
[
String
]
>
{
return
send
(
command
:
"HKEYS"
,
with
:
[
key
])
.
mapFromRESP
()
.
convertFromRESPValue
()
}
/// Gets all values stored in a hash.
...
...
@@ -110,7 +110,7 @@ extension RedisClient {
@inlinable
public
func
hvals
(
in
key
:
String
)
->
EventLoopFuture
<
[
RESPValue
]
>
{
return
send
(
command
:
"HVALS"
,
with
:
[
key
])
.
mapFromRESP
()
.
convertFromRESPValue
()
}
/// Incrementally iterates over all fields in a hash.
...
...
@@ -156,7 +156,7 @@ extension RedisClient {
in
key
:
String
)
->
EventLoopFuture
<
Bool
>
{
return
send
(
command
:
"HSET"
,
with
:
[
key
,
field
,
value
])
.
mapFromRESP
(
to
:
Int
.
self
)
.
convertFromRESPValue
(
to
:
Int
.
self
)
.
map
{
return
$0
==
1
}
}
...
...
@@ -176,7 +176,7 @@ extension RedisClient {
in
key
:
String
)
->
EventLoopFuture
<
Bool
>
{
return
send
(
command
:
"HSETNX"
,
with
:
[
key
,
field
,
value
])
.
mapFromRESP
(
to
:
Int
.
self
)
.
convertFromRESPValue
(
to
:
Int
.
self
)
.
map
{
return
$0
==
1
}
}
...
...
@@ -232,7 +232,7 @@ extension RedisClient {
guard
fields
.
count
>
0
else
{
return
self
.
eventLoop
.
makeSucceededFuture
([])
}
return
send
(
command
:
"HMGET"
,
with
:
[
key
]
+
fields
)
.
mapFromRESP
(
to
:
[
RESPValue
]
.
self
)
.
convertFromRESPValue
(
to
:
[
RESPValue
]
.
self
)
.
map
{
return
$0
.
map
(
String
.
init
)
}
}
...
...
@@ -244,7 +244,7 @@ extension RedisClient {
@inlinable
public
func
hgetall
(
from
key
:
String
)
->
EventLoopFuture
<
[
String
:
String
]
>
{
return
send
(
command
:
"HGETALL"
,
with
:
[
key
])
.
mapFromRESP
(
to
:
[
String
]
.
self
)
.
convertFromRESPValue
(
to
:
[
String
]
.
self
)
.
map
(
Self
.
_mapHashResponse
)
}
}
...
...
@@ -264,7 +264,7 @@ extension RedisClient {
public
func
hincrby
(
_
amount
:
Int
,
field
:
String
,
in
key
:
String
)
->
EventLoopFuture
<
Int
>
{
/// connection.hincrby(20, field: "foo", in: "key")
return
send
(
command
:
"HINCRBY"
,
with
:
[
key
,
field
,
amount
])
.
mapFromRESP
()
.
convertFromRESPValue
()
}
/// Increments a hash field's value and returns the new value.
...
...
@@ -282,6 +282,6 @@ extension RedisClient {
T
:
RESPValueConvertible
{
return
send
(
command
:
"HINCRBYFLOAT"
,
with
:
[
key
,
field
,
amount
])
.
mapFromRESP
()
.
convertFromRESPValue
()
}
}
Sources/RedisNIO/Commands/ListCommands.swift
View file @
c010e13b
...
...
@@ -25,7 +25,7 @@ extension RedisClient {
@inlinable
public
func
llen
(
of
key
:
String
)
->
EventLoopFuture
<
Int
>
{
return
send
(
command
:
"LLEN"
,
with
:
[
key
])
.
mapFromRESP
()
.
convertFromRESPValue
()
}
/// Gets the element from a list stored at the provided index position.
...
...
@@ -73,7 +73,7 @@ extension RedisClient {
count
:
Int
=
0
)
->
EventLoopFuture
<
Int
>
{
return
send
(
command
:
"LREM"
,
with
:
[
key
,
count
,
value
])
.
mapFromRESP
()
.
convertFromRESPValue
()
}
/// Trims a list to only contain elements within the specified inclusive bounds of 0-based indices.
...
...
@@ -103,7 +103,7 @@ extension RedisClient {
from
key
:
String
)
->
EventLoopFuture
<
[
RESPValue
]
>
{
return
send
(
command
:
"LRANGE"
,
with
:
[
key
,
range
.
startIndex
,
range
.
endIndex
])
.
mapFromRESP
()
.
convertFromRESPValue
()
}
/// Pops the last element from a source list and pushes it to a destination list.
...
...
@@ -187,7 +187,7 @@ extension RedisClient {
_
pivot
:
RESPValueConvertible
)
->
EventLoopFuture
<
Int
>
{
return
send
(
command
:
"LINSERT"
,
with
:
[
key
,
pivotKeyword
,
pivot
,
element
])
.
mapFromRESP
()
.
convertFromRESPValue
()
}
}
...
...
@@ -217,7 +217,7 @@ extension RedisClient {
assert
(
elements
.
count
>
0
,
"At least 1 element should be provided."
)
return
send
(
command
:
"LPUSH"
,
with
:
[
key
]
+
elements
)
.
mapFromRESP
()
.
convertFromRESPValue
()
}
/// Pushes an element into a list, but only if the key exists and holds a list.
...
...
@@ -231,7 +231,7 @@ extension RedisClient {
@inlinable
public
func
lpushx
(
_
element
:
RESPValueConvertible
,
into
key
:
String
)
->
EventLoopFuture
<
Int
>
{
return
send
(
command
:
"LPUSHX"
,
with
:
[
key
,
element
])
.
mapFromRESP
()
.
convertFromRESPValue
()
}
}
...
...
@@ -260,7 +260,7 @@ extension RedisClient {
assert
(
elements
.
count
>
0
,
"At least 1 element should be provided."
)
return
send
(
command
:
"RPUSH"
,
with
:
[
key
]
+
elements
)
.
mapFromRESP
()
.
convertFromRESPValue
()
}
/// Pushes an element into a list, but only if the key exists and holds a list.
...
...
@@ -274,7 +274,7 @@ extension RedisClient {
@inlinable
public
func
rpushx
(
_
element
:
RESPValueConvertible
,
into
key
:
String
)
->
EventLoopFuture
<
Int
>
{
return
send
(
command
:
"RPUSHX"
,
with
:
[
key
,
element
])
.
mapFromRESP
()
.
convertFromRESPValue
()
}
}
...
...
Sources/RedisNIO/Commands/SetCommands.swift
View file @
c010e13b
...
...
@@ -28,7 +28,7 @@ extension RedisClient {
@inlinable
public
func
smembers
(
of
key
:
String
)
->
EventLoopFuture
<
[
RESPValue
]
>
{
return
send
(
command
:
"SMEMBERS"
,
with
:
[
key
])
.
mapFromRESP
()
.
convertFromRESPValue
()
}
/// Checks if the element is included in a set.
...
...
@@ -41,7 +41,7 @@ extension RedisClient {
@inlinable
public
func
sismember
(
_
element
:
RESPValueConvertible
,
of
key
:
String
)
->
EventLoopFuture
<
Bool
>
{
return
send
(
command
:
"SISMEMBER"
,
with
:
[
key
,
element
])
.
mapFromRESP
(
to
:
Int
.
self
)
.
convertFromRESPValue
(
to
:
Int
.
self
)
.
map
{
return
$0
==
1
}
}
...
...
@@ -53,7 +53,7 @@ extension RedisClient {
@inlinable
public
func
scard
(
of
key
:
String
)
->
EventLoopFuture
<
Int
>
{
return
send
(
command
:
"SCARD"
,
with
:
[
key
])
.
mapFromRESP
()
.
convertFromRESPValue
()
}
/// Adds elements to a set.
...
...
@@ -68,7 +68,7 @@ extension RedisClient {
guard
elements
.
count
>
0
else
{
return
self
.
eventLoop
.
makeSucceededFuture
(
0
)
}
return
send
(
command
:
"SADD"
,
with
:
[
key
]
+
elements
)
.
mapFromRESP
()
.
convertFromRESPValue
()
}
/// Removes elements from a set.
...
...
@@ -83,7 +83,7 @@ extension RedisClient {
guard
elements
.
count
>
0
else
{
return
self
.
eventLoop
.
makeSucceededFuture
(
0
)
}
return
send
(
command
:
"SREM"
,
with
:
[
key
]
+
elements
)
.
mapFromRESP
()
.
convertFromRESPValue
()
}
/// Randomly selects and removes one or more elements in a set.
...
...
@@ -100,7 +100,7 @@ extension RedisClient {
guard
count
>
0
else
{
return
self
.
eventLoop
.
makeSucceededFuture
([])
}
return
send
(
command
:
"SPOP"
,
with
:
[
key
,
count
])
.
mapFromRESP
()
.
convertFromRESPValue
()
}
/// Randomly selects one or more elements in a set.
...
...
@@ -119,7 +119,7 @@ extension RedisClient {
guard
count
!=
0
else
{
return
self
.
eventLoop
.
makeSucceededFuture
([])
}
return
send
(
command
:
"SRANDMEMBER"
,
with
:
[
key
,
count
])
.
mapFromRESP
()
.
convertFromRESPValue
()
}
/// Moves an element from one set to another.
...
...
@@ -139,7 +139,7 @@ extension RedisClient {
guard
sourceKey
!=
destKey
else
{
return
self
.
eventLoop
.
makeSucceededFuture
(
true
)
}
return
send
(
command
:
"SMOVE"
,
with
:
[
sourceKey
,
destKey
,
element
])
.
mapFromRESP
()
.
convertFromRESPValue
()
.
map
{
return
$0
==
1
}
}
...
...
@@ -176,7 +176,7 @@ extension RedisClient {
guard
keys
.
count
>
0
else
{
return
self
.
eventLoop
.
makeSucceededFuture
([])
}
return
send
(
command
:
"SDIFF"
,
with
:
keys
)
.
mapFromRESP
()
.
convertFromRESPValue
()
}
/// Calculates the difference between two or more sets and stores the result.
...
...
@@ -192,7 +192,7 @@ extension RedisClient {
assert
(
keys
.
count
>
0
,
"At least 1 key should be provided."
)
return
send
(
command
:
"SDIFFSTORE"
,
with
:
[
destination
]
+
keys
)
.
mapFromRESP
()
.
convertFromRESPValue
()
}
}
...
...
@@ -209,7 +209,7 @@ extension RedisClient {
guard
keys
.
count
>
0
else
{
return
self
.
eventLoop
.
makeSucceededFuture
([])
}
return
send
(
command
:
"SINTER"
,
with
:
keys
)
.
mapFromRESP
()
.
convertFromRESPValue
()
}
/// Calculates the intersetion of two or more sets and stores the result.
...
...
@@ -225,7 +225,7 @@ extension RedisClient {
assert
(
keys
.
count
>
0
,
"At least 1 key should be provided."
)
return
send
(
command
:
"SINTERSTORE"
,
with
:
[
destination
]
+
keys
)
.
mapFromRESP
()
.
convertFromRESPValue
()
}
}
...
...
@@ -242,7 +242,7 @@ extension RedisClient {
guard
keys
.
count
>
0
else
{
return
self
.
eventLoop
.
makeSucceededFuture
([])
}
return
send
(
command
:
"SUNION"
,
with
:
keys
)
.
mapFromRESP
()
.
convertFromRESPValue
()
}
/// Calculates the union of two or more sets and stores the result.
...
...
@@ -258,6 +258,6 @@ extension RedisClient {
assert
(
keys
.
count
>
0
,
"At least 1 key should be provided."
)
return
send
(
command
:
"SUNIONSTORE"
,
with
:
[
destination
]
+
keys
)
.
mapFromRESP
()
.
convertFromRESPValue
()
}
}
Sources/RedisNIO/Commands/SortedSetCommands.swift
View file @
c010e13b
...
...
@@ -83,7 +83,7 @@ extension RedisClient {
}
return
send
(
command
:
"ZADD"
,
with
:
args
)
.
mapFromRESP
()
.
convertFromRESPValue
()
}
/// Adds an element to a sorted set, assigning their score to the value provided.
...
...
@@ -112,7 +112,7 @@ extension RedisClient {
@inlinable
public
func
zcard
(
of
key
:
String
)
->
EventLoopFuture
<
Int
>
{
return
send
(
command
:
"ZCARD"
,
with
:
[
key
])
.
mapFromRESP
()
.
convertFromRESPValue
()
}
/// Gets the score of the specified element in a stored set.
...
...
@@ -167,7 +167,7 @@ extension RedisClient {
@inlinable
public
func
zrank
(
of
element
:
RESPValueConvertible
,
in
key
:
String
)
->
EventLoopFuture
<
Int
?
>
{
return
send
(
command
:
"ZRANK"
,
with
:
[
key
,
element
])
.
mapFromRESP
()
.
convertFromRESPValue
()
}
/// Returns the rank (index) of the specified element in a sorted set.
...
...
@@ -182,7 +182,7 @@ extension RedisClient {
@inlinable
public
func
zrevrank
(
of
element
:
RESPValueConvertible
,
in
key
:
String
)
->
EventLoopFuture
<
Int
?
>
{
return
send
(
command
:
"ZREVRANK"
,
with
:
[
key
,
element
])
.
mapFromRESP
()
.
convertFromRESPValue
()
}
}
...
...
@@ -202,7 +202,7 @@ extension RedisClient {
within
range
:
(
min
:
String
,
max
:
String
)
)
->
EventLoopFuture
<
Int
>
{
return
send
(
command
:
"ZCOUNT"
,
with
:
[
key
,
range
.
min
,
range
.
max
])
.
mapFromRESP
()
.
convertFromRESPValue
()
}
/// Returns the number of elements in a sorted set whose lexiographical values are between the range specified.
...
...
@@ -219,7 +219,7 @@ extension RedisClient {
within
range
:
(
min
:
String
,
max
:
String
)
)
->
EventLoopFuture
<
Int
>
{
return
send
(
command
:
"ZLEXCOUNT"
,
with
:
[
key
,
range
.
min
,
range
.
max
])
.
mapFromRESP
()
.
convertFromRESPValue
()
}
}
...
...
@@ -287,7 +287,7 @@ extension RedisClient {
}
return
send
(
command
:
command
,
with
:
args
)
.
mapFromRESP
(
to
:
[
RESPValue
]
.
self
)
.
convertFromRESPValue
(
to
:
[
RESPValue
]
.
self
)
.
flatMapThrowing
{
return
try
Self
.
_mapSortedSetResponse
(
$0
,
scoreIsFirst
:
true
)
}
}
}
...
...
@@ -453,7 +453,7 @@ extension RedisClient {
in
key
:
String
)
->
EventLoopFuture
<
Double
>
{
return
send
(
command
:
"ZINCRBY"
,
with
:
[
key
,
amount
,
element
])
.
mapFromRESP
()
.
convertFromRESPValue
()
}
}
...
...
@@ -528,7 +528,7 @@ extension RedisClient {
}
return
send
(
command
:
command
,
with
:
args
)
.
mapFromRESP
()
.
convertFromRESPValue
()
}
}
...
...
@@ -588,7 +588,7 @@ extension RedisClient {
if
withScores
{
args
.
append
(
"WITHSCORES"
)
}
return
send
(
command
:
command
,
with
:
args
)
.
mapFromRESP
()
.
convertFromRESPValue
()
}
}
...
...
@@ -657,7 +657,7 @@ extension RedisClient {
}
return
send
(
command
:
command
,
with
:
args
)
.
mapFromRESP
()
.
convertFromRESPValue
()
}
}
...
...
@@ -721,7 +721,7 @@ extension RedisClient {
}
return
send
(
command
:
command
,
with
:
args
)
.
mapFromRESP
()
.
convertFromRESPValue
()
}
}
...
...
@@ -740,7 +740,7 @@ extension RedisClient {
guard
elements
.
count
>
0
else
{
return
self
.
eventLoop
.
makeSucceededFuture
(
0
)
}
return
send
(
command
:
"ZREM"
,
with
:
[
key
]
+
elements
)
.
mapFromRESP
()
.
convertFromRESPValue
()
}
/// Removes elements from a sorted set whose lexiographical values are between the range specified.
...
...
@@ -757,7 +757,7 @@ extension RedisClient {
from
key
:
String
)
->
EventLoopFuture
<
Int
>
{
return
send
(
command
:
"ZREMRANGEBYLEX"
,
with
:
[
key
,
range
.
min
,
range
.
max
])
.
mapFromRESP
()
.
convertFromRESPValue
()
}
/// Removes elements from a sorted set whose index is between the provided range.
...
...
@@ -773,7 +773,7 @@ extension RedisClient {
from
key
:
String
)
->
EventLoopFuture
<
Int
>
{
return
send
(
command
:
"ZREMRANGEBYRANK"
,
with
:
[
key
,
range
.
start
,
range
.
stop
])
.
mapFromRESP
()
.
convertFromRESPValue
()
}
/// Removes elements from a sorted set whose score is within the range specified.
...
...
@@ -789,6 +789,6 @@ extension RedisClient {
from
key
:
String
)
->
EventLoopFuture
<
Int
>
{
return
send
(
command
:
"ZREMRANGEBYSCORE"
,
with
:
[
key
,
range
.
min
,
range
.
max
])
.
mapFromRESP
()
.
convertFromRESPValue
()
}
}
Sources/RedisNIO/Commands/StringCommands.swift
View file @
c010e13b
...
...
@@ -40,7 +40,7 @@ extension RedisClient {
guard
keys
.
count
>
0
else
{
return
self
.
eventLoop
.
makeSucceededFuture
([])
}
return
send
(
command
:
"MGET"
,
with
:
keys
)
.
mapFromRESP
()
.
convertFromRESPValue
()
}
}
...
...
@@ -85,7 +85,7 @@ extension RedisClient {
@inlinable
public
func
msetnx
(
_
operations
:
[
String
:
RESPValueConvertible
])
->
EventLoopFuture
<
Bool
>
{
return
_mset
(
command
:
"MSETNX"
,
operations
)
.
mapFromRESP
(
to
:
Int
.
self
)
.
convertFromRESPValue
(
to
:
Int
.
self
)
.
map
{
return
$0
==
1
}
}
...
...
@@ -116,7 +116,7 @@ extension RedisClient {
@inlinable
public
func
increment
(
_
key
:
String
)
->
EventLoopFuture
<
Int
>
{
return
send
(
command
:
"INCR"
,
with
:
[
key
])
.
mapFromRESP
()
.
convertFromRESPValue
()
}
/// Increments the stored value by the amount desired .
...
...
@@ -129,7 +129,7 @@ extension RedisClient {
@inlinable
public
func
increment
(
_
key
:
String
,
by
count
:
Int
)
->
EventLoopFuture
<
Int
>
{
return
send
(
command
:
"INCRBY"
,
with
:
[
key
,
count
])
.
mapFromRESP
()
.
convertFromRESPValue
()
}
/// Increments the stored value by the amount desired.
...
...
@@ -144,7 +144,7 @@ extension RedisClient {
where
T
:
RESPValueConvertible
{
return
send
(
command
:
"INCRBYFLOAT"
,
with
:
[
key
,
count
])
.
mapFromRESP
()
.
convertFromRESPValue
()
}
}
...
...
@@ -159,7 +159,7 @@ extension RedisClient {
@inlinable
public
func
decrement
(
_
key
:
String
)
->
EventLoopFuture
<
Int
>
{
return
send
(
command
:
"DECR"
,
with
:
[
key
])
.
mapFromRESP
()
.
convertFromRESPValue
()
}
/// Decrements the stored valye by the amount desired.
...
...
@@ -171,6 +171,6 @@ extension RedisClient {
/// - Returns: The new value after the operation.
public
func
decrement
(
_
key
:
String
,
by
count
:
Int
)
->
EventLoopFuture
<
Int
>
{
return
send
(
command
:
"DECRBY"
,
with
:
[
key
,
count
])
.
mapFromRESP
()
.
convertFromRESPValue
()
}
}
Sources/RedisNIO/Extensions/SwiftNIO.swift
View file @
c010e13b
...
...
@@ -20,7 +20,7 @@ extension EventLoopFuture where Value == RESPValue {
/// - Parameter to: The desired type to convert to.
/// - Returns: An `EventLoopFuture` that resolves a value of the desired type.
@inlinable
public
func
mapFromRESP
<
T
>
(
public
func
convertFromRESPValue
<
T
>
(
to
type
:
T
.
Type
=
T
.
self
,
file
:
StaticString
=
#function
,
function
:
StaticString
=
#function
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment