|
2 | 2 | //
|
3 | 3 | // This source file is part of the RediStack open source project
|
4 | 4 | //
|
5 |
| -// Copyright (c) 2020 RediStack project authors |
| 5 | +// Copyright (c) 2020-2022 RediStack project authors |
6 | 6 | // Licensed under Apache License v2.0
|
7 | 7 | //
|
8 | 8 | // See LICENSE.txt for license information
|
@@ -67,6 +67,12 @@ extension RedisCommand {
|
67 | 67 | return .init(milliseconds: try $0.map())
|
68 | 68 | }
|
69 | 69 | }
|
| 70 | + |
| 71 | + /// [KEYS](https://redis.io/commands/keys) |
| 72 | + /// - Parameter pattern: The key pattern to search for matching keys that exist in Redis. |
| 73 | + public static func keys(matching pattern: String) -> RedisCommand<[String]> { |
| 74 | + return .init(keyword: "KEYS", arguments: [pattern.convertedToRESPValue()]) |
| 75 | + } |
70 | 76 |
|
71 | 77 | /// [SCAN](https://redis.io/commands/scan)
|
72 | 78 | /// - Parameters:
|
@@ -115,6 +121,15 @@ extension RedisClient {
|
115 | 121 | return self.send(.expire(key, after: timeout))
|
116 | 122 | }
|
117 | 123 |
|
| 124 | + /// Searches the keys in the database that match the given pattern. |
| 125 | + /// |
| 126 | + /// See ``RedisCommand/keys(matching:)`` |
| 127 | + /// - Parameter pattern: The key pattern to search for matching keys that exist in Redis. |
| 128 | + /// - Returns: A list of keys that matched the provided pattern. |
| 129 | + public func listKeys(matching pattern: String) -> EventLoopFuture<[String]> { |
| 130 | + return self.send(.keys(matching: pattern)) |
| 131 | + } |
| 132 | + |
118 | 133 | /// Incrementally iterates over all keys in the currently selected database.
|
119 | 134 | ///
|
120 | 135 | /// See `RedisCommand.scan(startingFrom:matching:count:)`
|
|
0 commit comments