Documentation ¶
Overview ¶
Package redistore is a session store backend for gorilla/sessions
Index ¶
- func NewTiKVGinStore(client *rawkv.Client, keyPairs ...[]byte) ginsessions.Store
- type GobSerializer
- type JSONSerializer
- type SessionSerializer
- type TiKVStore
- func (s *TiKVStore) Close() error
- func (s *TiKVStore) Delete(r *http.Request, w http.ResponseWriter, session *sessions.Session) error
- func (s *TiKVStore) Get(r *http.Request, name string) (*sessions.Session, error)
- func (s *TiKVStore) New(r *http.Request, name string) (*sessions.Session, error)
- func (s *TiKVStore) Options(opts ginsessions.Options)
- func (s *TiKVStore) Save(r *http.Request, w http.ResponseWriter, session *sessions.Session) error
- func (s *TiKVStore) SetKeyPrefix(p string)
- func (s *TiKVStore) SetMaxAge(v int)
- func (s *TiKVStore) SetMaxLength(l int)
- func (s *TiKVStore) SetSerializer(ss SessionSerializer)
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewTiKVGinStore ¶
func NewTiKVGinStore(client *rawkv.Client, keyPairs ...[]byte) ginsessions.Store
NewTiKVStore instantiates a TiKVStore for Gin.
Types ¶
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{}
type SessionSerializer ¶
type SessionSerializer interface { Deserialize(d []byte, ss *sessions.Session) error Serialize(ss *sessions.Session) ([]byte, error) }
SessionSerializer provides an interface hook for alternative serializers
type TiKVStore ¶
type TiKVStore struct { Codecs []securecookie.Codec DefaultMaxAge int // default TiKV TTL for a MaxAge == 0 session // contains filtered or unexported fields }
TiKVStore stores sessions in a tikv backend.
Example ¶
// TiKVStore cli, err := rawkv.NewClient(context.TODO(), []string{"127.0.0.1:2379"}, config.DefaultConfig().Security) if err != nil { panic(err) } defer cli.Close() store := NewTiKVStore(cli, []byte("secret-key")) defer store.Close()
Output:
func NewTiKVStore ¶
NewTiKVStore instantiates a TiKVStore.
func (*TiKVStore) Delete ¶
Delete removes the session from tikv, 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 (*TiKVStore) Get ¶
Get returns a session for the given name after adding it to the registry.
See gorilla/sessions FilesystemStore.Get().
func (*TiKVStore) New ¶
New returns a session for the given name without adding it to the registry.
See gorilla/sessions FilesystemStore.New().
func (*TiKVStore) Options ¶
func (s *TiKVStore) Options(opts ginsessions.Options)
Options sets configuration for a session.
See gin-contrib/sessions https://github.com/gin-contrib/sessions/blob/master/sessions.go
func (*TiKVStore) SetKeyPrefix ¶
SetKeyPrefix set the prefix
func (*TiKVStore) SetMaxAge ¶
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 (*TiKVStore) SetMaxLength ¶
SetMaxLength sets TiKVStore.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 TiKVStore is 4096. TiKV allows for max. value sizes of up to 1.5MB (https://tikv.io/docs/v3.4/dev-guide/limit/) Default: 4096,
func (*TiKVStore) SetSerializer ¶
func (s *TiKVStore) SetSerializer(ss SessionSerializer)
SetSerializer sets the serializer