Documentation ¶
Index ¶
- func LoadSessionBySessionId(s *RedisStore, sessionId string) (*sessions.Session, error)
- func SaveSessionWithoutContext(s *RedisStore, sessionId string, session *sessions.Session) error
- type RedisStore
- func NewRedisStore(size int, network, address, password string, keyPairs ...[]byte) (*RedisStore, error)
- func NewRedisStoreWithDB(size int, network, address, password, DB string, keyPairs ...[]byte) (*RedisStore, error)
- func NewRedisStoreWithPool(pool *redis.Pool, keyPairs ...[]byte) (*RedisStore, error)
- 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) New(r *http.Request, name string) (*sessions.Session, error)
- func (s *RedisStore) Save(r *http.Request, w http.ResponseWriter, session *sessions.Session) error
- func (s *RedisStore) SetKeyPrefix(p string)
- func (s *RedisStore) SetMaxAge(v int)
- func (s *RedisStore) SetMaxLength(l int)
- func (s *RedisStore) SetSerializer(ss serializer.SessionSerializer)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func LoadSessionBySessionId ¶
func LoadSessionBySessionId(s *RedisStore, sessionId string) (*sessions.Session, error)
LoadSessionBySessionId Get session using session_id even without a context
func SaveSessionWithoutContext ¶
func SaveSessionWithoutContext(s *RedisStore, sessionId string, session *sessions.Session) error
SaveSessionWithoutContext Save session even without a context
Types ¶
type RedisStore ¶
type RedisStore struct { Pool *redis.Pool Codecs []securecookie.Codec Options *sessions.Options // default configuration DefaultMaxAge int // default Redis TTL for a MaxAge == 0 session // contains filtered or unexported fields }
RedisStore stores sessions in a redis backend.
func NewRedisStore ¶
func NewRedisStore(size int, network, address, password string, keyPairs ...[]byte) (*RedisStore, error)
NewRedisStore returns a new RedisStore. size: maximum number of idle connections.
func NewRedisStoreWithDB ¶
func NewRedisStoreWithDB(size int, network, address, password, DB string, keyPairs ...[]byte) (*RedisStore, error)
NewRedisStoreWithDB - like NewRedisStore but accepts `DB` parameter to select redis DB instead of using the default one ("0")
func NewRedisStoreWithPool ¶
func NewRedisStoreWithPool(pool *redis.Pool, keyPairs ...[]byte) (*RedisStore, error)
NewRedisStoreWithPool instantiates a RediStore with a *redis.Pool passed in.
func (*RedisStore) Close ¶
func (s *RedisStore) Close() error
Close closes the underlying *redis.Pool
func (*RedisStore) Delete ¶
func (s *RedisStore) Delete(r *http.Request, w http.ResponseWriter, session *sessions.Session) error
Delete removes the session from redis, and sets the cookie to expire.
WARNING: This method should be considered deprecated since it is not exposed via the gorilla/sessions interface. Set session.Options.MaxAge = -1 and call Save instead. - July 18th, 2013
func (*RedisStore) Get ¶
Get returns a session for the given name after adding it to the registry.
See gorilla/sessions FilesystemStore.Get().
func (*RedisStore) New ¶
New returns a session for the given name without adding it to the registry.
See gorilla/sessions FilesystemStore.New().
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.
func (*RedisStore) SetKeyPrefix ¶
func (s *RedisStore) SetKeyPrefix(p string)
SetKeyPrefix set the prefix
func (*RedisStore) SetMaxAge ¶
func (s *RedisStore) SetMaxAge(v int)
SetMaxAge 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) SetMaxLength ¶
func (s *RedisStore) SetMaxLength(l int)
SetMaxLength sets RedisStore.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 RedisStore is 4096. Redis allows for max. value sizes of up to 512MB (http://redis.io/topics/data-types) Default: 4096,
func (*RedisStore) SetSerializer ¶
func (s *RedisStore) SetSerializer(ss serializer.SessionSerializer)
SetSerializer sets the serializer