Documentation ¶
Index ¶
- Constants
- func NewLock(client redis.Cmdable, key string) sessions.Lock
- func NewRedisSessionStore(opts *options.SessionOptions, cookieOpts *options.Cookie) (sessions.SessionStore, error)
- type Client
- type Lock
- type SessionStore
- func (store *SessionStore) Clear(ctx context.Context, key string) error
- func (store *SessionStore) Load(ctx context.Context, key string) ([]byte, error)
- func (store *SessionStore) Lock(key string) sessions.Lock
- func (store *SessionStore) Save(ctx context.Context, key string, value []byte, exp time.Duration) error
- func (store *SessionStore) VerifyConnection(ctx context.Context) error
Constants ¶
const LockSuffix = "lock"
Variables ¶
This section is empty.
Functions ¶
func NewLock ¶
NewLock instantiate a new lock instance. This will not yet apply a lock on Redis side. For that you have to call Obtain(ctx context.Context, expiration time.Duration)
func NewRedisSessionStore ¶
func NewRedisSessionStore(opts *options.SessionOptions, cookieOpts *options.Cookie) (sessions.SessionStore, error)
NewRedisSessionStore initialises a new instance of the SessionStore and wraps it in a persistence.Manager
Types ¶
type Client ¶
type Client interface { Get(ctx context.Context, key string) ([]byte, error) Lock(key string) sessions.Lock Set(ctx context.Context, key string, value []byte, expiration time.Duration) error Del(ctx context.Context, key string) error Ping(ctx context.Context) error }
Client is wrapper interface for redis.Client and redis.ClusterClient.
func NewRedisClient ¶
func NewRedisClient(opts options.RedisStoreOptions) (Client, error)
NewRedisClient makes a redis.Client (either standalone, sentinel aware, or redis cluster)
type Lock ¶
type Lock struct {
// contains filtered or unexported fields
}
type SessionStore ¶
type SessionStore struct {
Client Client
}
SessionStore is an implementation of the persistence.Store interface that stores sessions in redis
func (*SessionStore) Clear ¶
func (store *SessionStore) Clear(ctx context.Context, key string) error
Clear clears any saved session information for a given persistence cookie from redis, and then clears the session
func (*SessionStore) Load ¶
Load reads sessions.SessionState information from a persistence cookie within the HTTP request object
func (*SessionStore) Lock ¶
func (store *SessionStore) Lock(key string) sessions.Lock
Lock creates a lock object for sessions.SessionState
func (*SessionStore) Save ¶
func (store *SessionStore) Save(ctx context.Context, key string, value []byte, exp time.Duration) error
Save takes a sessions.SessionState and stores the information from it to redis, and adds a new persistence cookie on the HTTP response writer
func (*SessionStore) VerifyConnection ¶
func (store *SessionStore) VerifyConnection(ctx context.Context) error
VerifyConnection verifies the redis connection is valid and the server is responsive