Skip to content

Commit 252b0b8

Browse files
committed
Improve KEYS command to be more type-safe
1 parent 370ef8c commit 252b0b8

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

Sources/RediStack/Commands/KeyCommands.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ extension RedisCommand {
7070

7171
/// [KEYS](https://redis.io/commands/keys)
7272
/// - Parameter pattern: The key pattern to search for matching keys that exist in Redis.
73-
public static func keys(matching pattern: String) -> RedisCommand<[String]> {
73+
public static func keys(matching pattern: String) -> RedisCommand<[RedisKey]> {
7474
return .init(keyword: "KEYS", arguments: [pattern.convertedToRESPValue()])
7575
}
7676

@@ -126,7 +126,7 @@ extension RedisClient {
126126
/// See ``RedisCommand/keys(matching:)``
127127
/// - Parameter pattern: The key pattern to search for matching keys that exist in Redis.
128128
/// - Returns: A list of keys that matched the provided pattern.
129-
public func listKeys(matching pattern: String) -> EventLoopFuture<[String]> {
129+
public func listKeys(matching pattern: String) -> EventLoopFuture<[RedisKey]> {
130130
return self.send(.keys(matching: pattern))
131131
}
132132

Tests/RediStackIntegrationTests/Commands/KeyCommandsTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,6 @@ final class KeyCommandsTests: RediStackIntegrationTestCase {
156156
}
157157
let keys = try self.connection.listKeys(matching: "\(#function)*").wait()
158158
XCTAssertEqual(keys.count, range.count)
159-
XCTAssertTrue(keys.allSatisfy({ $0.contains(#function) }))
159+
XCTAssertTrue(keys.allSatisfy({ $0.rawValue.contains(#function) }))
160160
}
161161
}

0 commit comments

Comments
 (0)