Redis Documentation Beta

Protocol Redis​Sessions​Delegate

public protocol RedisSessionsDelegate 

A delegate object that controls key behavior of an Application.Redis.Sessions driver.

Requirements

make​New​ID()

func makeNewID() -> SessionID

Makes a new session ID token.

The default implementation creates 32 bytes of random data and base64 encodes it.

make​Redis​Key(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

session​ID Session​ID

The session ID that needs to be transformed into a RediStack.RedisKey for storage in Redis.

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

client Client

The Redis client to use for the operation.

data Session​Data

The session data to store in Redis.

key Redis​Key

The Redis key to identify the data being stored.

Returns

A notification NIO.EventLoopFuture that resolves when the operation has completed.

redis(_:​fetch​Data​For:​)

@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

client Client

The Redis client to use for the operation.

key Redis​Key

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.