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
fb161021
Verified
Commit
fb161021
authored
Feb 19, 2020
by
Nathan Harris
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rename ELF.convertFromRESPValue to be an overload of map
parent
6bd5df7d
Pipeline
#123487881
passed with stage
in 0 seconds
Changes
7
Pipelines
17
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
67 additions
and
67 deletions
+67
-67
Sources/RediStack/Commands/BasicCommands.swift
Sources/RediStack/Commands/BasicCommands.swift
+7
-7
Sources/RediStack/Commands/HashCommands.swift
Sources/RediStack/Commands/HashCommands.swift
+11
-11
Sources/RediStack/Commands/ListCommands.swift
Sources/RediStack/Commands/ListCommands.swift
+8
-8
Sources/RediStack/Commands/SetCommands.swift
Sources/RediStack/Commands/SetCommands.swift
+14
-14
Sources/RediStack/Commands/SortedSetCommands.swift
Sources/RediStack/Commands/SortedSetCommands.swift
+16
-16
Sources/RediStack/Commands/StringCommands.swift
Sources/RediStack/Commands/StringCommands.swift
+8
-8
Sources/RediStack/RESP/RESPValue.swift
Sources/RediStack/RESP/RESPValue.swift
+3
-3
No files found.
Sources/RediStack/Commands/BasicCommands.swift
View file @
fb161021
...
...
@@ -24,7 +24,7 @@ extension RedisClient {
public
func
echo
(
_
message
:
String
)
->
EventLoopFuture
<
String
>
{
let
args
=
[
RESPValue
(
bulk
:
message
)]
return
send
(
command
:
"ECHO"
,
with
:
args
)
.
convertFromRESPValue
()
.
map
()
}
/// Pings the server, which will respond with a message.
...
...
@@ -38,7 +38,7 @@ extension RedisClient {
?
[
.
init
(
bulk
:
message
!
)]
// safe because we did a nil pre-check
:
[]
return
send
(
command
:
"PING"
,
with
:
args
)
.
convertFromRESPValue
()
.
map
()
}
/// Select the Redis logical database having the specified zero-based numeric index.
...
...
@@ -68,7 +68,7 @@ extension RedisClient {
.
init
(
bulk
:
second
)
]
return
send
(
command
:
"SWAPDB"
,
with
:
args
)
.
convertFromRESPValue
(
to
:
String
.
self
)
.
map
(
to
:
String
.
self
)
.
map
{
return
$0
==
"OK"
}
}
...
...
@@ -95,7 +95,7 @@ extension RedisClient {
let
args
=
keys
.
map
(
RESPValue
.
init
)
return
send
(
command
:
"DEL"
,
with
:
args
)
.
convertFromRESPValue
()
.
map
()
}
/// Removes the specified keys. A key is ignored if it does not exist.
...
...
@@ -123,7 +123,7 @@ extension RedisClient {
.
init
(
bulk
:
timeout
.
seconds
)
]
return
send
(
command
:
"EXPIRE"
,
with
:
args
)
.
convertFromRESPValue
(
to
:
Int
.
self
)
.
map
(
to
:
Int
.
self
)
.
map
{
return
$0
==
1
}
}
}
...
...
@@ -175,7 +175,7 @@ extension RedisClient {
args
.
append
(
.
init
(
bulk
:
c
))
}
let
response
=
send
(
command
:
command
,
with
:
args
)
.
convertFromRESPValue
(
to
:
[
RESPValue
]
.
self
)
let
response
=
send
(
command
:
command
,
with
:
args
)
.
map
(
to
:
[
RESPValue
]
.
self
)
let
position
=
response
.
flatMapThrowing
{
result
->
Int
in
guard
let
value
=
result
[
0
]
.
string
,
...
...
@@ -187,7 +187,7 @@ extension RedisClient {
}
let
elements
=
response
.
map
{
return
$0
[
1
]
}
.
convertFromRESPValue
(
to
:
resultType
)
.
map
(
to
:
resultType
)
return
position
.
and
(
elements
)
}
...
...
Sources/RediStack/Commands/HashCommands.swift
View file @
fb161021
...
...
@@ -53,7 +53,7 @@ extension RedisClient {
args
.
append
(
convertingContentsOf
:
fields
)
return
send
(
command
:
"HDEL"
,
with
:
args
)
.
convertFromRESPValue
()
.
map
()
}
/// Removes the specified fields from a hash.
...
...
@@ -82,7 +82,7 @@ extension RedisClient {
.
init
(
bulk
:
field
)
]
return
send
(
command
:
"HEXISTS"
,
with
:
args
)
.
convertFromRESPValue
(
to
:
Int
.
self
)
.
map
(
to
:
Int
.
self
)
.
map
{
return
$0
==
1
}
}
...
...
@@ -95,7 +95,7 @@ extension RedisClient {
public
func
hlen
(
of
key
:
RedisKey
)
->
EventLoopFuture
<
Int
>
{
let
args
=
[
RESPValue
(
bulk
:
key
)]
return
send
(
command
:
"HLEN"
,
with
:
args
)
.
convertFromRESPValue
()
.
map
()
}
/// Gets the string length of a hash field's value.
...
...
@@ -112,7 +112,7 @@ extension RedisClient {
.
init
(
bulk
:
field
)
]
return
send
(
command
:
"HSTRLEN"
,
with
:
args
)
.
convertFromRESPValue
()
.
map
()
}
/// Gets all field names in a hash.
...
...
@@ -124,7 +124,7 @@ extension RedisClient {
public
func
hkeys
(
in
key
:
RedisKey
)
->
EventLoopFuture
<
[
String
]
>
{
let
args
=
[
RESPValue
(
bulk
:
key
)]
return
send
(
command
:
"HKEYS"
,
with
:
args
)
.
convertFromRESPValue
()
.
map
()
}
/// Gets all values stored in a hash.
...
...
@@ -136,7 +136,7 @@ extension RedisClient {
public
func
hvals
(
in
key
:
RedisKey
)
->
EventLoopFuture
<
[
RESPValue
]
>
{
let
args
=
[
RESPValue
(
bulk
:
key
)]
return
send
(
command
:
"HVALS"
,
with
:
args
)
.
convertFromRESPValue
()
.
map
()
}
/// Incrementally iterates over all fields in a hash.
...
...
@@ -187,7 +187,7 @@ extension RedisClient {
value
.
convertedToRESPValue
()
]
return
send
(
command
:
"HSET"
,
with
:
args
)
.
convertFromRESPValue
(
to
:
Int
.
self
)
.
map
(
to
:
Int
.
self
)
.
map
{
return
$0
==
1
}
}
...
...
@@ -212,7 +212,7 @@ extension RedisClient {
value
.
convertedToRESPValue
()
]
return
send
(
command
:
"HSETNX"
,
with
:
args
)
.
convertFromRESPValue
(
to
:
Int
.
self
)
.
map
(
to
:
Int
.
self
)
.
map
{
return
$0
==
1
}
}
...
...
@@ -276,7 +276,7 @@ extension RedisClient {
args
.
append
(
convertingContentsOf
:
fields
)
return
send
(
command
:
"HMGET"
,
with
:
args
)
.
convertFromRESPValue
(
to
:
[
RESPValue
]
.
self
)
.
map
(
to
:
[
RESPValue
]
.
self
)
.
map
{
return
$0
.
map
(
String
.
init
)
}
}
...
...
@@ -301,7 +301,7 @@ extension RedisClient {
public
func
hgetall
(
from
key
:
RedisKey
)
->
EventLoopFuture
<
[
String
:
String
]
>
{
let
args
=
[
RESPValue
(
bulk
:
key
)]
return
send
(
command
:
"HGETALL"
,
with
:
args
)
.
convertFromRESPValue
(
to
:
[
String
]
.
self
)
.
map
(
to
:
[
String
]
.
self
)
.
map
(
Self
.
_mapHashResponse
)
}
}
...
...
@@ -352,6 +352,6 @@ extension RedisClient {
amount
.
convertedToRESPValue
()
]
return
send
(
command
:
command
,
with
:
args
)
.
convertFromRESPValue
()
.
map
()
}
}
Sources/RediStack/Commands/ListCommands.swift
View file @
fb161021
...
...
@@ -26,7 +26,7 @@ extension RedisClient {
public
func
llen
(
of
key
:
RedisKey
)
->
EventLoopFuture
<
Int
>
{
let
args
=
[
RESPValue
(
bulk
:
key
)]
return
send
(
command
:
"LLEN"
,
with
:
args
)
.
convertFromRESPValue
()
.
map
()
}
/// Gets the element from a list stored at the provided index position.
...
...
@@ -88,7 +88,7 @@ extension RedisClient {
value
.
convertedToRESPValue
()
]
return
send
(
command
:
"LREM"
,
with
:
args
)
.
convertFromRESPValue
()
.
map
()
}
}
...
...
@@ -257,7 +257,7 @@ extension RedisClient {
.
init
(
bulk
:
lastIndex
)
]
return
send
(
command
:
"LRANGE"
,
with
:
args
)
.
convertFromRESPValue
()
.
map
()
}
/// Gets all elements from a List within the specified inclusive bounds of 0-based indices.
...
...
@@ -502,7 +502,7 @@ extension RedisClient {
element
.
convertedToRESPValue
()
]
return
send
(
command
:
"LINSERT"
,
with
:
args
)
.
convertFromRESPValue
()
.
map
()
}
}
...
...
@@ -536,7 +536,7 @@ extension RedisClient {
args
.
append
(
convertingContentsOf
:
elements
)
return
send
(
command
:
"LPUSH"
,
with
:
args
)
.
convertFromRESPValue
()
.
map
()
}
/// Pushes all of the provided elements into a list.
...
...
@@ -567,7 +567,7 @@ extension RedisClient {
element
.
convertedToRESPValue
()
]
return
send
(
command
:
"LPUSHX"
,
with
:
args
)
.
convertFromRESPValue
()
.
map
()
}
}
...
...
@@ -600,7 +600,7 @@ extension RedisClient {
args
.
append
(
convertingContentsOf
:
elements
)
return
send
(
command
:
"RPUSH"
,
with
:
args
)
.
convertFromRESPValue
()
.
map
()
}
/// Pushes all of the provided elements into a list.
...
...
@@ -630,7 +630,7 @@ extension RedisClient {
element
.
convertedToRESPValue
()
]
return
send
(
command
:
"RPUSHX"
,
with
:
args
)
.
convertFromRESPValue
()
.
map
()
}
}
...
...
Sources/RediStack/Commands/SetCommands.swift
View file @
fb161021
...
...
@@ -29,7 +29,7 @@ extension RedisClient {
public
func
smembers
(
of
key
:
RedisKey
)
->
EventLoopFuture
<
[
RESPValue
]
>
{
let
args
=
[
RESPValue
(
bulk
:
key
)]
return
send
(
command
:
"SMEMBERS"
,
with
:
args
)
.
convertFromRESPValue
()
.
map
()
}
/// Checks if the element is included in a set.
...
...
@@ -46,7 +46,7 @@ extension RedisClient {
element
.
convertedToRESPValue
()
]
return
send
(
command
:
"SISMEMBER"
,
with
:
args
)
.
convertFromRESPValue
(
to
:
Int
.
self
)
.
map
(
to
:
Int
.
self
)
.
map
{
return
$0
==
1
}
}
...
...
@@ -59,7 +59,7 @@ extension RedisClient {
public
func
scard
(
of
key
:
RedisKey
)
->
EventLoopFuture
<
Int
>
{
let
args
=
[
RESPValue
(
bulk
:
key
)]
return
send
(
command
:
"SCARD"
,
with
:
args
)
.
convertFromRESPValue
()
.
map
()
}
/// Adds elements to a set.
...
...
@@ -77,7 +77,7 @@ extension RedisClient {
args
.
append
(
convertingContentsOf
:
elements
)
return
send
(
command
:
"SADD"
,
with
:
args
)
.
convertFromRESPValue
()
.
map
()
}
/// Adds elements to a set.
...
...
@@ -107,7 +107,7 @@ extension RedisClient {
args
.
append
(
convertingContentsOf
:
elements
)
return
send
(
command
:
"SREM"
,
with
:
args
)
.
convertFromRESPValue
()
.
map
()
}
/// Removes elements from a set.
...
...
@@ -140,7 +140,7 @@ extension RedisClient {
.
init
(
bulk
:
count
)
]
return
send
(
command
:
"SPOP"
,
with
:
args
)
.
convertFromRESPValue
()
.
map
()
}
/// Randomly selects one or more elements in a set.
...
...
@@ -163,7 +163,7 @@ extension RedisClient {
.
init
(
bulk
:
count
)
]
return
send
(
command
:
"SRANDMEMBER"
,
with
:
args
)
.
convertFromRESPValue
()
.
map
()
}
/// Moves an element from one set to another.
...
...
@@ -188,7 +188,7 @@ extension RedisClient {
element
.
convertedToRESPValue
()
]
return
send
(
command
:
"SMOVE"
,
with
:
args
)
.
convertFromRESPValue
()
.
map
()
.
map
{
return
$0
==
1
}
}
...
...
@@ -226,7 +226,7 @@ extension RedisClient {
let
args
=
keys
.
map
(
RESPValue
.
init
)
return
send
(
command
:
"SDIFF"
,
with
:
args
)
.
convertFromRESPValue
()
.
map
()
}
/// Calculates the difference between two or more sets.
...
...
@@ -255,7 +255,7 @@ extension RedisClient {
args
.
append
(
convertingContentsOf
:
keys
)
return
send
(
command
:
"SDIFFSTORE"
,
with
:
args
)
.
convertFromRESPValue
()
.
map
()
}
}
...
...
@@ -273,7 +273,7 @@ extension RedisClient {
let
args
=
keys
.
map
(
RESPValue
.
init
)
return
send
(
command
:
"SINTER"
,
with
:
args
)
.
convertFromRESPValue
()
.
map
()
}
/// Calculates the intersection of two or more sets.
...
...
@@ -302,7 +302,7 @@ extension RedisClient {
args
.
append
(
convertingContentsOf
:
keys
)
return
send
(
command
:
"SINTERSTORE"
,
with
:
args
)
.
convertFromRESPValue
()
.
map
()
}
}
...
...
@@ -320,7 +320,7 @@ extension RedisClient {
let
args
=
keys
.
map
(
RESPValue
.
init
)
return
send
(
command
:
"SUNION"
,
with
:
args
)
.
convertFromRESPValue
()
.
map
()
}
/// Calculates the union of two or more sets.
...
...
@@ -349,6 +349,6 @@ extension RedisClient {
args
.
append
(
convertingContentsOf
:
keys
)
return
send
(
command
:
"SUNIONSTORE"
,
with
:
args
)
.
convertFromRESPValue
()
.
map
()
}
}
Sources/RediStack/Commands/SortedSetCommands.swift
View file @
fb161021
...
...
@@ -124,7 +124,7 @@ extension RedisClient {
}
return
self
.
send
(
command
:
"ZADD"
,
with
:
args
)
.
convertFromRESPValue
()
.
map
()
}
/// Adds elements to a sorted set, assigning their score to the values provided.
...
...
@@ -179,7 +179,7 @@ extension RedisClient {
public
func
zcard
(
of
key
:
RedisKey
)
->
EventLoopFuture
<
Int
>
{
let
args
=
[
RESPValue
(
bulk
:
key
)]
return
send
(
command
:
"ZCARD"
,
with
:
args
)
.
convertFromRESPValue
()
.
map
()
}
/// Gets the score of the specified element in a stored set.
...
...
@@ -242,7 +242,7 @@ extension RedisClient {
element
.
convertedToRESPValue
()
]
return
send
(
command
:
"ZRANK"
,
with
:
args
)
.
convertFromRESPValue
()
.
map
()
}
/// Returns the rank (index) of the specified element in a sorted set.
...
...
@@ -261,7 +261,7 @@ extension RedisClient {
element
.
convertedToRESPValue
()
]
return
send
(
command
:
"ZREVRANK"
,
with
:
args
)
.
convertFromRESPValue
()
.
map
()
}
}
...
...
@@ -344,7 +344,7 @@ extension RedisClient {
.
init
(
bulk
:
range
.
max
.
description
)
]
return
self
.
send
(
command
:
"ZCOUNT"
,
with
:
args
)
.
convertFromRESPValue
()
.
map
()
}
/// Returns the count of elements in a SortedSet with a score within the inclusive range specified.
...
...
@@ -477,7 +477,7 @@ extension RedisClient {
.
init
(
bulk
:
range
.
max
.
description
)
]
return
self
.
send
(
command
:
"ZLEXCOUNT"
,
with
:
args
)
.
convertFromRESPValue
()
.
map
()
}
/// Returns the count of elements in a SortedSet whose lexiographical value is greater than a minimum value.
...
...
@@ -595,7 +595,7 @@ extension RedisClient {
}
return
send
(
command
:
command
,
with
:
args
)
.
convertFromRESPValue
(
to
:
[
RESPValue
]
.
self
)
.
map
(
to
:
[
RESPValue
]
.
self
)
.
flatMapThrowing
{
return
try
Self
.
_mapSortedSetResponse
(
$0
,
scoreIsFirst
:
true
)
}
}
}
...
...
@@ -768,7 +768,7 @@ extension RedisClient {
element
.
convertedToRESPValue
()
]
return
send
(
command
:
"ZINCRBY"
,
with
:
args
)
.
convertFromRESPValue
()
.
map
()
}
}
...
...
@@ -859,7 +859,7 @@ extension RedisClient {
}
return
send
(
command
:
command
,
with
:
args
)
.
convertFromRESPValue
()
.
map
()
}
}
...
...
@@ -1271,7 +1271,7 @@ extension RedisClient {
if
withScores
{
args
.
append
(
.
init
(
bulk
:
"WITHSCORES"
))
}
return
send
(
command
:
command
,
with
:
args
)
.
convertFromRESPValue
()
.
map
()
}
}
...
...
@@ -1560,7 +1560,7 @@ extension RedisClient {
}
return
send
(
command
:
command
,
with
:
args
)
.
convertFromRESPValue
()
.
map
()
}
}
...
...
@@ -1752,7 +1752,7 @@ extension RedisClient {
}
return
send
(
command
:
command
,
with
:
args
)
.
convertFromRESPValue
()
.
map
()
}
}
...
...
@@ -1774,7 +1774,7 @@ extension RedisClient {
args
.
append
(
convertingContentsOf
:
elements
)
return
send
(
command
:
"ZREM"
,
with
:
args
)
.
convertFromRESPValue
()
.
map
()
}
/// Removes the specified elements from a sorted set.
...
...
@@ -1819,7 +1819,7 @@ extension RedisClient {
.
init
(
bulk
:
range
.
max
.
description
)
]
return
send
(
command
:
"ZREMRANGEBYLEX"
,
with
:
args
)
.
convertFromRESPValue
()
.
map
()
}
/// Removes elements from a SortedSet whose lexiographical values are greater than a minimum value.
...
...
@@ -1888,7 +1888,7 @@ extension RedisClient {
.
init
(
bulk
:
lastIndex
)
]
return
self
.
send
(
command
:
"ZREMRANGEBYRANK"
,
with
:
args
)
.
convertFromRESPValue
()
.
map
()
}
/// Removes all elements from a SortedSet within the specified inclusive bounds of 0-based indices.
...
...
@@ -1982,7 +1982,7 @@ extension RedisClient {
.
init
(
bulk
:
range
.
max
.
description
)
]
return
self
.
send
(
command
:
"ZREMRANGEBYSCORE"
,
with
:
args
)
.
convertFromRESPValue
()
.
map
()
}
/// Removes elements from a SortedSet whose score is within the inclusive range specified.
...
...
Sources/RediStack/Commands/StringCommands.swift
View file @
fb161021
...
...
@@ -55,7 +55,7 @@ extension RedisClient {
let
args
=
keys
.
map
(
RESPValue
.
init
)
return
send
(
command
:
"MGET"
,
with
:
args
)
.
convertFromRESPValue
()
.
map
()
}
/// Gets the values of all specified keys, using `.null` to represent non-existant values.
...
...
@@ -87,7 +87,7 @@ extension RedisClient {
value
.
convertedToRESPValue
()
]
return
send
(
command
:
"APPEND"
,
with
:
args
)
.
convertFromRESPValue
()
.
map
()
}
/// Sets the value stored in the key provided, overwriting the previous value.
...
...
@@ -132,7 +132,7 @@ extension RedisClient {
@inlinable
public
func
msetnx
<
Value
:
RESPValueConvertible
>
(
_
operations
:
[
RedisKey
:
Value
])
->
EventLoopFuture
<
Bool
>
{
return
_mset
(
command
:
"MSETNX"
,
operations
)
.
convertFromRESPValue
(
to
:
Int
.
self
)
.
map
(
to
:
Int
.
self
)
.
map
{
return
$0
==
1
}
}
...
...
@@ -167,7 +167,7 @@ extension RedisClient {
public
func
increment
(
_
key
:
RedisKey
)
->
EventLoopFuture
<
Int
>
{
let
args
=
[
RESPValue
(
bulk
:
key
)]
return
send
(
command
:
"INCR"
,
with
:
args
)
.
convertFromRESPValue
()
.
map
()
}
/// Increments the stored value by the amount desired .
...
...
@@ -184,7 +184,7 @@ extension RedisClient {
.
init
(
bulk
:
count
)
]
return
send
(
command
:
"INCRBY"
,
with
:
args
)
.
convertFromRESPValue
()
.
map
()
}
/// Increments the stored value by the amount desired.
...
...
@@ -205,7 +205,7 @@ extension RedisClient {
count
.
convertedToRESPValue
()
]
return
send
(
command
:
"INCRBYFLOAT"
,
with
:
args
)
.
convertFromRESPValue
()
.
map
()
}
}
...
...
@@ -221,7 +221,7 @@ extension RedisClient {
public
func
decrement
(
_
key
:
RedisKey
)
->
EventLoopFuture
<
Int
>
{
let
args
=
[
RESPValue
(
bulk
:
key
)]
return
send
(
command
:
"DECR"
,
with
:
args
)
.
convertFromRESPValue
()
.
map
()
}
/// Decrements the stored valye by the amount desired.
...
...
@@ -237,6 +237,6 @@ extension RedisClient {
.
init
(
bulk
:
count
)
]
return
send
(
command
:
"DECRBY"
,
with
:
args
)
.
convertFromRESPValue
()
.
map
()
}
}
Sources/RediStack/RESP/RESPValue.swift
View file @
fb161021
...
...
@@ -173,13 +173,13 @@ 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
convertFromRESPValue
<
T
>
(
public
func
map
<
T
>
(
to
type
:
T
.
Type
=
T
.
self
,
file
:
StaticString
=
#function
,
function
:
StaticString
=
#function
,
line
:
UInt
=
#line
)
->
EventLoopFuture
<
T
>
where
T
:
RESPValueConvertible
)
->
EventLoopFuture
<
T
>
where
T
:
RESPValueConvertible
{
return
self
.
flatMapThrowing
{
guard
let
value
=
T
(
fromRESP
:
$0
)
else
{
...
...
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