Skip to content

Commit 479a286

Browse files
authored
Add custom BLMPOP response, remove SPOP response. (#205)
Signed-off-by: Adam Fowler <[email protected]>
1 parent eef513d commit 479a286

File tree

5 files changed

+12
-10
lines changed

5 files changed

+12
-10
lines changed

Sources/Valkey/Commands/Custom/ListCustomCommands.swift

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,10 @@ extension LMPOP {
3131
}
3232
public typealias Response = OptionalResponse?
3333
}
34+
35+
extension BLMPOP {
36+
/// - Returns: One of the following
37+
/// * [Null]: If no element could be popped.
38+
/// * [Array]: List key from which elements were popped.
39+
public typealias Response = LMPOP.Response
40+
}

Sources/Valkey/Commands/Custom/SetCustomCommands.swift

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,6 @@
55
// See LICENSE.txt for license information
66
// SPDX-License-Identifier: Apache-2.0
77
//
8-
extension SPOP {
9-
public typealias Response = [RESPToken]?
10-
}
11-
128
extension SSCAN {
139
public struct Response: RESPTokenDecodable, Sendable {
1410
public let cursor: Int

Sources/Valkey/Commands/ListCommands.swift

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,6 @@ public struct BLMPOP: ValkeyCommand {
9393
}
9494
}
9595
}
96-
public typealias Response = RESPToken.Array?
97-
9896
@inlinable public static var name: String { "BLMPOP" }
9997

10098
public var timeout: Double
@@ -312,7 +310,6 @@ public struct LMOVE: ValkeyCommand {
312310
}
313311
}
314312
}
315-
316313
@inlinable public static var name: String { "LMOVE" }
317314

318315
public var source: ValkeyKey
@@ -688,7 +685,7 @@ extension ValkeyClientProtocol {
688685
/// * [Array]: The key from which elements were popped and the popped elements
689686
@inlinable
690687
@discardableResult
691-
public func blmpop(timeout: Double, keys: [ValkeyKey], where: BLMPOP.Where, count: Int? = nil) async throws -> RESPToken.Array? {
688+
public func blmpop(timeout: Double, keys: [ValkeyKey], where: BLMPOP.Where, count: Int? = nil) async throws -> BLMPOP.Response {
692689
try await execute(BLMPOP(timeout: timeout, keys: keys, where: `where`, count: count))
693690
}
694691

Sources/Valkey/Commands/SetCommands.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,8 @@ public struct SMOVE<Member: RESPStringRenderable>: ValkeyCommand {
268268
/// Returns one or more random members from a set after removing them. Deletes the set if the last member was popped.
269269
@_documentation(visibility: internal)
270270
public struct SPOP: ValkeyCommand {
271+
public typealias Response = RESPToken?
272+
271273
@inlinable public static var name: String { "SPOP" }
272274

273275
public var key: ValkeyKey
@@ -547,7 +549,7 @@ extension ValkeyClientProtocol {
547549
/// * [Array]: List to the removed members when 'COUNT' is given.
548550
@inlinable
549551
@discardableResult
550-
public func spop(_ key: ValkeyKey, count: Int? = nil) async throws -> SPOP.Response {
552+
public func spop(_ key: ValkeyKey, count: Int? = nil) async throws -> RESPToken? {
551553
try await execute(SPOP(key, count: count))
552554
}
553555

Sources/_ValkeyCommandsBuilder/ValkeyCommandsRender.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
/// List of functions where the Response calculation has been disabled because we want
99
/// to override the response in the Valkey library
1010
private let disableResponseCalculationCommands: Set<String> = [
11+
"BLMPOP",
1112
"BZMPOP",
1213
"BZPOPMAX",
1314
"BZPOPMIN",
@@ -18,7 +19,6 @@ private let disableResponseCalculationCommands: Set<String> = [
1819
"ROLE",
1920
"LMOVE",
2021
"LMPOP",
21-
"SPOP",
2222
"SSCAN",
2323
"XAUTOCLAIM",
2424
"XCLAIM",

0 commit comments

Comments
 (0)