Documentation ¶
Index ¶
- type GobSerializer
- type JSONSerializer
- type KeyGenFunc
- type RedisStore
- func (s *RedisStore) Close() error
- func (s *RedisStore) Delete(r *http.Request, w http.ResponseWriter, session *sessions.Session) error
- func (s *RedisStore) Get(r *http.Request, name string) (*sessions.Session, error)
- func (s *RedisStore) KeyGen(f KeyGenFunc)
- func (s *RedisStore) KeyPrefix(keyPrefix string)
- func (s *RedisStore) MaxAge(v int)
- func (s *RedisStore) New(r *http.Request, name string) (*sessions.Session, error)
- func (s *RedisStore) Options(opts sessions.Options)
- func (s *RedisStore) Save(r *http.Request, w http.ResponseWriter, session *sessions.Session) error
- func (s *RedisStore) Serializer(ss SessionSerializer)
- func (s *RedisStore) SetMaxLength(l int)
- type SessionSerializer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type GobSerializer ¶
type GobSerializer struct{}
GobSerializer is Gob Serializer
func (GobSerializer) Deserialize ¶
func (gs GobSerializer) Deserialize(d []byte, s *sessions.Session) error
Deserialize back to map[string]interface{}
type JSONSerializer ¶
type JSONSerializer struct{}
JSONSerializer encode the session map to JSON.
func (JSONSerializer) Deserialize ¶
func (s JSONSerializer) Deserialize(d []byte, ss *sessions.Session) error
Deserialize back to map[string]interface{}
type KeyGenFunc ¶
type KeyGenFunc func() string
KeyGenFunc defines a function used by store to generate a key
type RedisStore ¶
type RedisStore struct { Codecs []securecookie.Codec DefaultMaxAge int // default Redis TTL for a MaxAge == 0 session // contains filtered or unexported fields }
RedisStore stores gorilla sessions in Redis
func NewRedisStore ¶
func NewRedisStore(client redis.UniversalClient, keyPairs ...[]byte) (*RedisStore, error)
NewRedisStore returns a new RedisStore with default configuration
func NewRedisStoreSimple ¶
func NewRedisStoreSimple(address, password string, db int, keyPairs ...[]byte) (*RedisStore, error)
NewRedisStoreSimple returns a new RedisStore with easy config
func NewRedisStoreWithRedisConfig ¶
func NewRedisStoreWithRedisConfig(options *redis.Options, keyPairs ...[]byte) (*RedisStore, error)
NewRedisStoreWithRedisConfig returns a new RedisStore with default Redis configuration
func (*RedisStore) Close ¶
func (s *RedisStore) Close() error
Close closes the underlying *redis client
func (*RedisStore) Delete ¶ added in v1.1.0
func (s *RedisStore) Delete(r *http.Request, w http.ResponseWriter, session *sessions.Session) error
func (*RedisStore) KeyGen ¶
func (s *RedisStore) KeyGen(f KeyGenFunc)
KeyGen sets the key generator function
func (*RedisStore) KeyPrefix ¶
func (s *RedisStore) KeyPrefix(keyPrefix string)
KeyPrefix sets the key prefix to store session in Redis
func (*RedisStore) MaxAge ¶
func (s *RedisStore) MaxAge(v int)
MaxAge restricts the maximum age, in seconds, of the session record both in database and a browser. This is to change session storage configuration. If you want just to remove session use your session `s` object and change it's `Options.MaxAge` to -1, as specified in
http://godoc.org/github.com/gorilla/sessions#Options
Default is the one provided by this package value - `sessionExpire`. Set it to 0 for no restriction. Because we use `MaxAge` also in SecureCookie crypting algorithm you should use this function to change `MaxAge` value.
func (*RedisStore) New ¶
New returns a session for the given name without adding it to the registry.
func (*RedisStore) Options ¶
func (s *RedisStore) Options(opts sessions.Options)
Options set options to use when a new session is created
func (*RedisStore) Save ¶
func (s *RedisStore) Save(r *http.Request, w http.ResponseWriter, session *sessions.Session) error
Save adds a single session to the response.
If the Options.MaxAge of the session is <= 0 then the session file will be deleted from the store. With this process it enforces the properly session cookie handling so no need to trust in the cookie management in the web browser.
func (*RedisStore) Serializer ¶
func (s *RedisStore) Serializer(ss SessionSerializer)
Serializer sets the session serializer to store session
func (*RedisStore) SetMaxLength ¶
func (s *RedisStore) SetMaxLength(l int)
SetMaxLength sets RediStore.maxLength if the `l` argument is greater or equal 0 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 RediStore is 4096. Redis allows for max. value sizes of up to 512MB (http://redis.io/topics/data-types) Default: 4096,