You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is an SQLite session store implementation for sessionup
Installation
To install simply use:
go get github.com/jellydator/sessionup-sqlitestore
Usage
To create and use new SQLiteStore use New method. A working sqlite3 driver is
required along with the table name that should be used to store sessions.
Expired sessions should be periodically deleted as manager will no longer use
them. It can be done by either using DeleteByID or DeleteByUserKey methods or
by using Cleanup. Cleanup is a blocking method that periodically deletes all
expired sessions. It accepts context and interval parameters. Context is used to
close the procedure and interval describes how often the action should be
performed.
varwg sync.WaitGroupctx, cancel:=context.WithCancel(context.Background())
wg.Add(1)
gofunc() {
// we can use for loop, in case cleanup returns an error, we can// restart the process after handling the error.for {
deferwg.Done()
err:=store.Cleanup(ctx, 15*time.Minute)
iferrors.Is(err, ctx.Err()) {
return
}
// handle error
}
}()
// to gracefully close cleanupcancel()
wg.Wait()
Cleanup can also be started when creating SQLiteStore using NewWithCleanup.
Additionally it returns error channel and close/cancel delegate function.