Skip to content

Instance Method

expire(_:after:)

Sets a timeout on key. After the timeout has expired, the key will automatically be deleted.
func expire(_ key: RedisKey, after timeout: TimeAmount) async throws -> Bool

Parameters

key

The key to set the expiration on.

timeout

The time from now the key will expire at.

Return Value

true if the expiration was set.

Discussion

Note

A key with an associated timeout is often said to be “volatile” in Redis terminology.

https://redis.io/commands/expire