The translation from sqlite3store is relatively trivial, here's a snippet:
func (p *SQLite3XStore) exec(query string, opts *sqlitex.ExecOptions) error {
conn, err := p.pool.Take(context.Background())
if err != nil {
return err
}
defer p.pool.Put(conn)
return sqlitex.Execute(conn, query, opts)
}
// Find returns the data for a given session token from the SQLite3XStore instance.
// If the session token is not found or is expired, the returned exists flag will
// be set to false.
func (p *SQLite3XStore) Find(token string) (b []byte, exists bool, err error) {
err = p.exec("SELECT data FROM sessions WHERE token = $1 AND julianday('now') < expiry",
&sqlitex.ExecOptions{
Args: []any{token},
ResultFunc: func(stmt *sqlite.Stmt) error {
exists = true
b = make([]byte, stmt.ColumnLen(0))
stmt.ColumnBytes(0, b)
return nil
},
})
return
}
Is there interest in an sqlite3 store using the CGO-less translation of sqlite3 at https://modernc.org/sqlite + https://github.com/zombiezen/go-sqlite ? Performance is roughly 30% worse than the CGO version.
The translation from sqlite3store is relatively trivial, here's a snippet: