Protocol
RedisSessionsDelegate
public protocol RedisSessionsDelegate
A delegate object that controls key behavior of an Application.Redis.Sessions
driver.
Requirements
makeNewID()
func makeNewID() -> SessionID
Makes a new session ID token.
The default implementation creates 32 bytes of random data and base64 encodes it.
makeRedisKey(for:)
func makeRedisKey(for sessionID: SessionID) -> RedisKey
Makes a key to identify the given session ID in Redis.
The default implementation prefixes the sessionID
with vrs-
.
Parameters
Name | Type | Description |
---|---|---|
sessionID | SessionID |
The session ID that needs to be transformed into a |
Returns
A Redis key for the given sessionID
to be used to identify associated SessionData
in Redis.
redis(_:store:with:)
@inlinable
func redis<Client: RedisClient>(_ client: Client, store data: SessionData, with key: RedisKey) -> EventLoopFuture<Void>
Instructs your delegate object to handle the responsibility of storing the provided session data to Redis.
Parameters
Name | Type | Description |
---|---|---|
client | Client |
The Redis client to use for the operation. |
data | SessionData |
The session data to store in Redis. |
key | RedisKey |
The Redis key to identify the data being stored. |
Returns
A notification NIO.EventLoopFuture
that resolves when the operation has completed.
redis(_:fetchDataFor:)
@inlinable
func redis<Client: RedisClient>(_ client: Client, fetchDataFor key: RedisKey) -> EventLoopFuture<SessionData?>
Asks the delegate object to fetch session data for a given Redis key.
Parameters
Name | Type | Description |
---|---|---|
client | Client |
The Redis client to use for the operation. |
key | RedisKey |
The Redis key that identifies the data to be fetched. |
Returns
A NIO.EventLoopFuture
that possibly resolves the available session data for the given Redis key.