Documentation ¶
Index ¶
- type GoRediStore
- func NewGoRediStore(size int, network, address, password string, keyPairs ...[]byte) (*GoRediStore, error)
- func NewGoRediStoreWithDB(size int, network, address, password string, DB int, keyPairs ...[]byte) (*GoRediStore, error)
- func NewGoRediStoreWithPool(client *redis.Client, keyPairs ...[]byte) (*GoRediStore, error)
- func (s *GoRediStore) Close() error
- func (s *GoRediStore) Delete(r *http.Request, w http.ResponseWriter, session *sessions.Session) error
- func (s *GoRediStore) Get(r *http.Request, name string) (*sessions.Session, error)
- func (s *GoRediStore) New(r *http.Request, name string) (*sessions.Session, error)
- func (s *GoRediStore) Save(r *http.Request, w http.ResponseWriter, session *sessions.Session) error
- func (s *GoRediStore) SetKeyPrefix(p string)
- func (s *GoRediStore) SetMaxAge(v int)
- func (s *GoRediStore) SetMaxLength(l int)
- func (s *GoRediStore) SetSerializer(ss SessionSerializer)
- type GobSerializer
- type JSONSerializer
- type SessionSerializer
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type GoRediStore ¶
type GoRediStore struct { Client *redis.Client 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 := NewGoRediStore(10, "tcp", ":6379", "", []byte("session-key")) if err != nil { panic(err) } defer store.Close()
Output:
func NewGoRediStore ¶
func NewGoRediStore(size int, network, address, password string, keyPairs ...[]byte) (*GoRediStore, error)
NewRediStore returns a new RediStore. size: maximum number of idle connections.
func NewGoRediStoreWithDB ¶
func NewGoRediStoreWithDB(size int, network, address, password string, DB int, keyPairs ...[]byte) (*GoRediStore, error)
NewRediStoreWithDB - like NewRedisStore but accepts `DB` parameter to select redis DB instead of using the default one ("0")
func NewGoRediStoreWithPool ¶
func NewGoRediStoreWithPool(client *redis.Client, keyPairs ...[]byte) (*GoRediStore, error)
NewRediStoreWithPool instantiates a RediStore with a *redis.Pool passed in.
func (*GoRediStore) Close ¶
func (s *GoRediStore) Close() error
Close closes the underlying *redis.Pool
func (*GoRediStore) Delete ¶
func (s *GoRediStore) 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 (*GoRediStore) Get ¶
Get returns a session for the given name after adding it to the registry.
See gorilla/sessions FilesystemStore.Get().
func (*GoRediStore) New ¶
New returns a session for the given name without adding it to the registry.
See gorilla/sessions FilesystemStore.New().
func (*GoRediStore) Save ¶
func (s *GoRediStore) Save(r *http.Request, w http.ResponseWriter, session *sessions.Session) error
Save adds a single session to the response.
func (*GoRediStore) SetKeyPrefix ¶
func (s *GoRediStore) SetKeyPrefix(p string)
SetKeyPrefix set the prefix
func (*GoRediStore) SetMaxAge ¶
func (s *GoRediStore) 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 (*GoRediStore) SetMaxLength ¶
func (s *GoRediStore) 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,
func (*GoRediStore) SetSerializer ¶
func (s *GoRediStore) SetSerializer(ss SessionSerializer)
SetSerializer sets the serializer
type GobSerializer ¶
type GobSerializer struct{}
GobSerializer uses gob package to encode the session map
func (GobSerializer) Deserialize ¶
func (s GobSerializer) Deserialize(d []byte, ss *sessions.Session) error
Deserialize back to map[interface{}]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{}