Documentation
¶
Overview ¶
Package sessionstore implements the scs.Store interface on top of the cms_sessions table. It exists (rather than using scs's own pgxstore) so the table name carries the cms_ prefix and can live in a database shared with the host application.
Index ¶
- type Store
- func (s *Store) Commit(token string, data []byte, expiry time.Time) error
- func (s *Store) CommitCtx(ctx context.Context, token string, data []byte, expiry time.Time) error
- func (s *Store) Delete(token string) error
- func (s *Store) DeleteCtx(ctx context.Context, token string) error
- func (s *Store) Find(token string) ([]byte, bool, error)
- func (s *Store) FindCtx(ctx context.Context, token string) ([]byte, bool, error)
- func (s *Store) StopCleanup()
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store persists sessions in the cms_sessions table.
func NewWithCleanupInterval ¶
NewWithCleanupInterval returns a Store whose background cleanup runs at the given interval. A zero or negative interval disables cleanup.
func (*Store) CommitCtx ¶ added in v1.2.2
CommitCtx is Commit under a write context: deadlined, but not cancellable by the request. See sessiondata.WriteContext.
func (*Store) DeleteCtx ¶ added in v1.2.2
DeleteCtx is Delete under a write context. A logout that did not land because the browser hung up would leave a session that still works, so this one in particular outlives the request that asked for it.
func (*Store) FindCtx ¶ added in v1.2.2
FindCtx is Find under the request's own context, so a lookup for a visitor who is no longer there stops with them.
func (*Store) StopCleanup ¶
func (s *Store) StopCleanup()
StopCleanup halts the background cleanup goroutine, for tests or graceful shutdown. It returns once the goroutine has actually stopped, and is safe to call any number of times — including on a store built with cleanup disabled.