Documentation
¶
Index ¶
- func NewAppConfig() django.AppConfig
- type QueryStore
- func (p *QueryStore) All() (map[string][]byte, error)
- func (p *QueryStore) AllCtx(ctx context.Context) (map[string][]byte, error)
- func (p *QueryStore) Commit(token string, b []byte, expiry time.Time) error
- func (p *QueryStore) CommitCtx(ctx context.Context, token string, b []byte, expiry time.Time) error
- func (p *QueryStore) Delete(token string) error
- func (p *QueryStore) DeleteCtx(ctx context.Context, token string) error
- func (p *QueryStore) Find(token string) ([]byte, bool, error)
- func (p *QueryStore) FindCtx(ctx context.Context, token string) ([]byte, bool, error)
- func (p *QueryStore) StopCleanup()
- type Session
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewAppConfig ¶
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) AllCtx ¶ added in v1.7.2
All returns a map containing the token and data for all active (i.e. not expired) sessions in the QueryStore instance.
func (*QueryStore) CommitCtx ¶ added in v1.7.2
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
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 (*Session) FieldDefs ¶ added in v1.7.2
func (s *Session) FieldDefs() attrs.Definitions