Commit 15a3c038 authored by Nathan Harris's avatar Nathan Harris

Merge branch 'expire-timeout' into '47-proposal-feedback'

Update `RedisClient.expire` to no longer use `deadline` terminology.

See merge request Mordil/swift-redis-nio-client!65
parents c5241a46 b96f64c7
......@@ -84,11 +84,11 @@ extension RedisClient {
/// [https://redis.io/commands/expire](https://redis.io/commands/expire)
/// - Parameters:
/// - key: The key to set the expiration on.
/// - deadline: The time from now the key will expire at.
/// - timeout: The time from now the key will expire at.
/// - Returns: `true` if the expiration was set.
@inlinable
public func expire(_ key: String, after deadline: TimeAmount) -> EventLoopFuture<Bool> {
let amount = deadline.nanoseconds / 1_000_000_000
public func expire(_ key: String, after timeout: TimeAmount) -> EventLoopFuture<Bool> {
let amount = timeout.nanoseconds / 1_000_000_000
return send(command: "EXPIRE", with: [key, amount])
.convertFromRESPValue(to: Int.self)
.map { return $0 == 1 }
......
......@@ -60,14 +60,14 @@ final class BasicCommandsTests: XCTestCase {
func test_expire() throws {
try connection.set(#function, to: "value").wait()
let before = try connection.get(#function).wait()
XCTAssertNotNil(before)
let result = try connection.expire(#function, after: .nanoseconds(1)).wait()
XCTAssertEqual(result, true)
let after = try connection.get(#function).wait()
XCTAssertNil(after)
XCTAssertNotNil(try connection.get(#function).wait())
XCTAssertTrue(try connection.expire(#function, after: .nanoseconds(1)).wait())
XCTAssertNil(try connection.get(#function).wait())
try connection.set(#function, to: "new value").wait()
XCTAssertNotNil(try connection.get(#function).wait())
XCTAssertTrue(try connection.expire(#function, after: .seconds(10)).wait())
XCTAssertNotNil(try connection.get(#function).wait())
}
func test_ping() throws {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment