Documentation
¶
Overview ¶
Package valkeystore is a session store backend for gorilla/sessions
Index ¶
- type ValkeyStore
- func New(address []string, username, password string, keyPairs ...[]byte) (*ValkeyStore, error)
- func NewWithClient(client valkey.Client, keyPairs ...[]byte) (*ValkeyStore, error)
- func NewWithDatabase(address []string, username, password string, database int, keyPairs ...[]byte) (*ValkeyStore, error)
- func NewWithURL(url string, keyPairs ...[]byte) (*ValkeyStore, error)
- func (r *ValkeyStore) Close()
- func (r *ValkeyStore) Get(request *http.Request, name string) (*sessions.Session, error)
- func (r *ValkeyStore) New(request *http.Request, name string) (*sessions.Session, error)
- func (r *ValkeyStore) Save(request *http.Request, writer http.ResponseWriter, session *sessions.Session) error
- func (r *ValkeyStore) SetKeyPrefix(keyPrefix string)
- func (r *ValkeyStore) SetMaxAge(maxAge int)
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ValkeyStore ¶
type ValkeyStore struct {
Codecs []securecookie.Codec
Options *sessions.Options // default configuration
// contains filtered or unexported fields
}
ValkeyStore represents a valkey session store.
Example ¶
// valkeystore
store, err := New([]string{":6379"}, "", "", []byte("secret-key"))
if err != nil {
panic(err)
}
defer store.Close()
func New ¶ added in v0.2.0
func New(address []string, username, password string, keyPairs ...[]byte) (*ValkeyStore, error)
New creates a new valkey store with the given parameters and key pairs.
func NewWithClient ¶ added in v0.2.0
func NewWithClient(client valkey.Client, keyPairs ...[]byte) (*ValkeyStore, error)
NewWithClient creates a new valkey store with the given client and key pairs.
func NewWithDatabase ¶ added in v0.2.0
func NewWithDatabase( address []string, username, password string, database int, keyPairs ...[]byte, ) (*ValkeyStore, error)
NewWithDatabase creates a new valkey store with the given parameters and key pairs.
func NewWithURL ¶ added in v0.2.0
func NewWithURL(url string, keyPairs ...[]byte) (*ValkeyStore, error)
NewWithURL creates a new valkey store with the given URL and key pairs.
func (*ValkeyStore) Close ¶
func (r *ValkeyStore) Close()
Close closes the valkey client connection.
func (*ValkeyStore) New ¶
New returns a session for the given name without adding it to the registry.
func (*ValkeyStore) Save ¶
func (r *ValkeyStore) Save(request *http.Request, writer http.ResponseWriter, session *sessions.Session) error
Save adds a single session to the response.
func (*ValkeyStore) SetKeyPrefix ¶
func (r *ValkeyStore) SetKeyPrefix(keyPrefix string)
SetKeyPrefix set the prefix.
func (*ValkeyStore) SetMaxAge ¶
func (r *ValkeyStore) SetMaxAge(maxAge 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 `age` 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 encrypting algorithm you should use this function to change `MaxAge` value.