RedisStore

public class RedisStore: Store

An implementation of the Store protocol for the storage of Session data using Redis.

  • ttl

    The Time to Live value for the stored entries.

    Declaration

    Swift

    public var ttl: Int
  • db

    The number of the Redis database to store the session data in.

    Declaration

    Swift

    public var db: Int
  • The host of the Redis server.

    Declaration

    Swift

    public var redisHost: String
  • The port the Redis server is listening on.

    Declaration

    Swift

    public var redisPort: Int32
  • The password to use if Redis password authentication is setup on the Redis server.

    Declaration

    Swift

    public var redisPassword: String?
  • The prefix to be added to the keys of the stored data.

    Declaration

    Swift

    public var keyPrefix: String
  • Initialize an instance of RedisStore.

    Parameter

    Parameter redisHost: The host of the Redis server.

    Parameter

    Parameter redisPort: The port the Redis server is listening on.

    Parameter

    Parameter redisPassword: The password to use if Redis password authentication is setup on the Redis server.

    Parameter

    Parameter ttl: The Time to Live value for the stored entries.

    Parameter

    Parameter db: The number of the Redis database to store the session data in.

    Parameter

    Parameter keyPrefix: The prefix to be added to the keys of the stored data.

    Declaration

    Swift

    public init(redisHost: String, redisPort: Int32, redisPassword: String?=nil, ttl: Int = 3600, db: Int = 0, keyPrefix: String = "s:")

    Parameters

    redisHost

    The host of the Redis server.

    redisPort

    The port the Redis server is listening on.

    redisPassword

    The password to use if Redis password authentication is setup on the Redis server.

    ttl

    The Time to Live value for the stored entries.

    db

    The number of the Redis database to store the session data in.

    keyPrefix

    The prefix to be added to the keys of the stored data.

  • Load the session data.

    Parameter

    Parameter sessionId: The ID of the session.

    Parameter

    Parameter callback: The closure to invoke once the session data is fetched.

    Declaration

    Swift

    public func load(sessionId: String, callback: @escaping (Data?, NSError?) -> Void)

    Parameters

    sessionId

    The ID of the session.

    callback

    The closure to invoke once the session data is fetched.

  • Save the session data.

    Parameter

    Parameter sessionId: The ID of the session.

    Parameter

    Parameter data: The data to save.

    Parameter

    Parameter callback: The closure to invoke once the session data is saved.

    Declaration

    Swift

    public func save(sessionId: String, data: Data, callback: @escaping (NSError?) -> Void)

    Parameters

    sessionId

    The ID of the session.

    data

    The data to save.

    callback

    The closure to invoke once the session data is saved.

  • Touch the session data.

    Parameter

    Parameter sessionId: The ID of the session.

    Parameter

    Parameter callback: The closure to invoke once the session data is touched.

    Declaration

    Swift

    public func touch(sessionId: String, callback: @escaping (NSError?) -> Void)

    Parameters

    sessionId

    The ID of the session.

    callback

    The closure to invoke once the session data is touched.

  • Delete the session data.

    Parameter

    Parameter sessionId: The ID of the session.

    Parameter

    Parameter callback: The closure to invoke once the session data is deleted.

    Declaration

    Swift

    public func delete(sessionId: String, callback: @escaping (NSError?) -> Void)

    Parameters

    sessionId

    The ID of the session.

    callback

    The closure to invoke once the session data is deleted.