session

package
v1.7.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 8, 2026 License: GPL-2.0 Imports: 20 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewAppConfig

func NewAppConfig() django.AppConfig

Types

type QueryStore added in v1.7.2

type QueryStore struct {
	// contains filtered or unexported fields
}

func NewQueryStore added in v1.7.2

func NewQueryStore(db drivers.Database) *QueryStore

NewQueryStore returns a new QueryStore instance, with a background cleanup goroutine that runs every 5 minutes to remove expired session data.

func NewQueryStoreWithCleanupInterval added in v1.7.2

func NewQueryStoreWithCleanupInterval(db drivers.Database, cleanupInterval time.Duration) *QueryStore

NewQueryStoreWithCleanupInterval returns a new QueryStore instance. The cleanupInterval parameter controls how frequently expired session data is removed by the background cleanup goroutine. Setting it to 0 prevents the cleanup goroutine from running (i.e. expired sessions will not be removed).

func (*QueryStore) All added in v1.7.2

func (p *QueryStore) All() (map[string][]byte, error)

func (*QueryStore) AllCtx added in v1.7.2

func (p *QueryStore) AllCtx(ctx context.Context) (map[string][]byte, error)

All returns a map containing the token and data for all active (i.e. not expired) sessions in the QueryStore instance.

func (*QueryStore) Commit added in v1.7.2

func (p *QueryStore) Commit(token string, b []byte, expiry time.Time) error

func (*QueryStore) CommitCtx added in v1.7.2

func (p *QueryStore) CommitCtx(ctx context.Context, token string, b []byte, expiry time.Time) error

Commit adds a session token and data to the QueryStore instance with the given expiry time. If the session token already exists, then the data and expiry time are updated.

func (*QueryStore) Delete added in v1.7.2

func (p *QueryStore) Delete(token string) error

func (*QueryStore) DeleteCtx added in v1.7.2

func (p *QueryStore) DeleteCtx(ctx context.Context, token string) error

Delete removes a session token and corresponding data from the QueryStore instance.

func (*QueryStore) Find added in v1.7.2

func (p *QueryStore) Find(token string) ([]byte, bool, error)

func (*QueryStore) FindCtx added in v1.7.2

func (p *QueryStore) FindCtx(ctx context.Context, token string) ([]byte, bool, error)

Find returns the data for a given session token from the QueryStore instance. If the session token is not found or is expired, the returned exists flag will be set to false.

func (*QueryStore) StopCleanup added in v1.7.2

func (p *QueryStore) StopCleanup()

StopCleanup terminates the background cleanup goroutine for the QueryStore instance. It's rare to terminate this; generally QueryStore instances and their cleanup goroutines are intended to be long-lived and run for the lifetime of your application.

There may be occasions though when your use of the QueryStore is transient. An example is creating a new QueryStore instance in a test function. In this scenario, the cleanup goroutine (which will run forever) will prevent the QueryStore object from being garbage collected even after the test function has finished. You can prevent this by manually calling StopCleanup.

type Session added in v1.7.2

type Session struct {
	//	token CHAR(43) PRIMARY KEY,
	//  data BLOB NOT NULL,
	//  expiry TIMESTAMP(6) NOT NULL
	Token  drivers.Char
	Data   drivers.Bytes
	Expiry int64 // Use int64 to store Unix timestamp in nanoseconds
}

func (*Session) DatabaseIndexes added in v1.7.2

func (s *Session) DatabaseIndexes(obj attrs.Definer) []migrator.Index

func (*Session) FieldDefs added in v1.7.2

func (s *Session) FieldDefs() attrs.Definitions

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL