Documentation ¶
Index ¶
- func LoadSessionBySessionId(s *RediStore, sessionId string) (*sessions.Session, error)
- func SaveSessionWithoutContext(s *RediStore, sessionId string, session *sessions.Session) error
- func SetKeyPrefix(s Store, prefix string) error
- type RediStore
- func GetRedisStore(s Store) (rediStore *RediStore, err error)
- func NewRediStore(size int, network, address, password string, keyPairs ...[]byte) (*RediStore, error)
- func NewRediStoreWithDB(size int, network, address, password, DB string, keyPairs ...[]byte) (*RediStore, error)
- func NewRediStoreWithPool(pool *redis.Pool, keyPairs ...[]byte) (*RediStore, error)
- func (s *RediStore) Close() error
- func (s *RediStore) Delete(r *http.Request, w http.ResponseWriter, session *sessions.Session) error
- func (s *RediStore) Get(r *http.Request, name string) (*sessions.Session, error)
- func (s *RediStore) New(r *http.Request, name string) (*sessions.Session, error)
- func (s *RediStore) Save(r *http.Request, w http.ResponseWriter, session *sessions.Session) error
- func (s *RediStore) SetKeyPrefix(p string)
- func (s *RediStore) SetMaxAge(v int)
- func (s *RediStore) SetMaxLength(l int)
- func (s *RediStore) SetSerializer(ss hs.Serializer)
- type Store
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func LoadSessionBySessionId ¶ added in v1.0.2
LoadSessionBySessionId Get session using session_id even without a context
func SaveSessionWithoutContext ¶ added in v1.0.2
SaveSessionWithoutContext Save session even without a context
func SetKeyPrefix ¶
SetKeyPrefix sets the key prefix in the redis database.
Types ¶
type RediStore ¶ added in v1.0.2
type RediStore 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 }
RediStore stores sessions in a redis backend.
Example ¶
// RedisStore store, err := NewRediStore(10, "tcp", ":6379", "", []byte("secret-key")) if err != nil { panic(err) } defer store.Close()
Output:
func GetRedisStore ¶
GetRedisStore get the actual working store. Ref: https://godoc.org/github.com/boj/redistore#RediStore
func NewRediStore ¶ added in v1.0.2
func NewRediStore(size int, network, address, password string, keyPairs ...[]byte) (*RediStore, error)
NewRediStore returns a new RediStore. size: maximum number of idle connections.
func NewRediStoreWithDB ¶ added in v1.0.2
func NewRediStoreWithDB(size int, network, address, password, DB string, keyPairs ...[]byte) (*RediStore, error)
NewRediStoreWithDB - like NewRedisStore but accepts `DB` parameter to select redis DB instead of using the default one ("0")
func NewRediStoreWithPool ¶ added in v1.0.2
NewRediStoreWithPool instantiates a RediStore with a *redis.Pool passed in.
func (*RediStore) Delete ¶ added in v1.0.2
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 (*RediStore) Get ¶ added in v1.0.2
Get returns a session for the given name after adding it to the registry.
See gorilla/sessions FilesystemStore.Get().
func (*RediStore) New ¶ added in v1.0.2
New returns a session for the given name without adding it to the registry.
See gorilla/sessions FilesystemStore.New().
func (*RediStore) SetKeyPrefix ¶ added in v1.0.2
SetKeyPrefix set the prefix
func (*RediStore) SetMaxAge ¶ added in v1.0.2
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 (*RediStore) SetMaxLength ¶ added in v1.0.2
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,
func (*RediStore) SetSerializer ¶ added in v1.0.2
func (s *RediStore) SetSerializer(ss hs.Serializer)
SetSerializer sets the serializer
type Store ¶
func NewStoreWithDB ¶
NewStoreWithDB - like NewStore but accepts `DB` parameter to select redis DB instead of using the default one ("0")
Ref: https://godoc.org/github.com/boj/redistore#NewRediStoreWithDB
func NewStoreWithPool ¶
NewStoreWithPool instantiates a RediStore with a *redis.Pool passed in.
Ref: https://godoc.org/github.com/boj/redistore#NewRediStoreWithPool