Documentation ¶
Index ¶
- type SentinelClientConfig
- type SentinelFailoverStore
- func (s *SentinelFailoverStore) Get(r *http.Request, name string) (*sessions.Session, error)
- func (s *SentinelFailoverStore) MaxAge(age int)
- func (s *SentinelFailoverStore) MaxLength(l int)
- func (s *SentinelFailoverStore) New(r *http.Request, name string) (*sessions.Session, error)
- func (s *SentinelFailoverStore) Save(r *http.Request, w http.ResponseWriter, session *sessions.Session) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type SentinelClientConfig ¶
type SentinelFailoverStore ¶
type SentinelFailoverStore struct { //Codecs []securecookie.Codec //Options *sessions.Options // default configuration //DefaultMaxAge int // default Redis TTL for a MaxAge == 0 session *redistore.RediStore FailoverClient *redis.Client // contains filtered or unexported fields }
SentinelFailoverStore stores sessions in Redis Sentinel Failover.
It also serves as a referece for custom stores.
This store is still experimental and not well tested. Feedback is welcome.
func NewSentinelFailoverStore ¶
func NewSentinelFailoverStore(clientConfig SentinelClientConfig, keyPairs ...[]byte) *SentinelFailoverStore
This function returns a new Redis Sentinel store.
Keys are defined in pairs to allow key rotation, but the common case is to set a single authentication key and optionally an encryption key.
The first key in a pair is used for authentication and the second for encryption. The encryption key can be set to nil or omitted in the last pair, but the authentication key is required in all pairs.
It is recommended to use an authentication key with 32 or 64 bytes. The encryption key, if set, must be either 16, 24, or 32 bytes to select AES-128, AES-192, or AES-256 modes.
Use the convenience function securecookie.GenerateRandomKey() to create strong keys.
func (*SentinelFailoverStore) Get ¶
Get returns a session for the given name after adding it to the registry.
It returns a new session if the sessions doesn't exist. Access IsNew on the session to check if it is an existing session or a new one.
It returns a new session and an error if the session exists but could not be decoded.
func (*SentinelFailoverStore) MaxAge ¶
func (s *SentinelFailoverStore) MaxAge(age int)
MaxAge sets the maximum age for the store and the underlying cookie implementation. Individual sessions can be deleted by setting Options.MaxAge = -1 for that session.
func (*SentinelFailoverStore) MaxLength ¶
func (s *SentinelFailoverStore) MaxLength(l int)
MaxLength restricts the maximum length of new sessions to l. If l is 0 there is no limit to the size of a session, use with caution. The default for a new SentinelFailoverStore is 4096.
func (*SentinelFailoverStore) New ¶
New returns a session for the given name without adding it to the registry.
The difference between New() and Get() is that calling New() twice will decode the session data twice, while Get() registers and reuses the same decoded session after the first call.
func (*SentinelFailoverStore) Save ¶
func (s *SentinelFailoverStore) Save(r *http.Request, w http.ResponseWriter, session *sessions.Session) error
Save adds a single session to the response.