PGSession type
type PGSession struct { ID int64 Key string Data string CreatedOn time.Time ModifiedOn time.Time ExpiresOn time.Time }
PGStore represents the currently configured session store.
type PGStore struct { Codecs []securecookie.Codec Options *sessions.Options Path string DbPool *sql.DB }
func NewPGStore(dbURL string, keyPairs ...[]byte) (*PGStore, error)
NewPGStore creates a new PGStore instance and a new database/sql pool. This will also create in the database the schema needed by pgstore.
func NewPGStoreFromPool(db *sql.DB, keyPairs ...[]byte) (*PGStore, error)
NewPGStoreFromPool creates a new PGStore instance from an existing database/sql pool. This will also create the database schema needed by pgstore.
func (db *PGStore) Cleanup(interval time.Duration) (chan<- struct{}, <-chan struct{})
Cleanup runs a background goroutine every interval that deletes expired sessions from the database.
The design is based on https://github.com/yosssi/boltstore
func (db *PGStore) Close()
Close closes the database connection.
func (db *PGStore) Get(r *http.Request, name string) (*sessions.Session, error)
Get Fetches a session for a given name after it has been added to the registry.
func (db *PGStore) MaxAge(age int)
MaxAge sets the maximum age for the store and the underlying cookie implementation. Individual sessions can be deleted by setting Options.MaxAge = -1 for that session.
func (db *PGStore) MaxLength(l int)
MaxLength restricts the maximum length of new sessions to l. If l is 0 there is no limit to the size of a session, use with caution. The default for a new PGStore is 4096. PostgreSQL allows for max value sizes of up to 1GB (http://www.postgresql.org/docs/current/interactive/datatype-character.html)
func (db *PGStore) New(r *http.Request, name string) (*sessions.Session, error)
New returns a new session for the given name without adding it to the registry.
func (db *PGStore) Save(r *http.Request, w http.ResponseWriter, session *sessions.Session) error
Save saves the given session into the database and deletes cookies if needed
func (db *PGStore) StopCleanup(quit chan<- struct{}, done <-chan struct{})
StopCleanup stops the background cleanup from running.