Documentation ¶
Index ¶
- type PostgresProvider
- func (p *PostgresProvider) Count() (total int)
- func (p *PostgresProvider) Destroy(sid string) error
- func (p *PostgresProvider) Exist(sid string) bool
- func (p *PostgresProvider) GC()
- func (p *PostgresProvider) Init(maxlifetime int64, connStr string) (err error)
- func (p *PostgresProvider) Read(sid string) (session.RawStore, error)
- func (p *PostgresProvider) Regenerate(oldsid, sid string) (_ session.RawStore, err error)
- type PostgresStore
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type PostgresProvider ¶
type PostgresProvider struct {
// contains filtered or unexported fields
}
PostgresProvider represents a postgres session provider implementation.
func (*PostgresProvider) Count ¶
func (p *PostgresProvider) Count() (total int)
Count counts and returns number of sessions.
func (*PostgresProvider) Destroy ¶
func (p *PostgresProvider) Destroy(sid string) error
Destroy deletes a session by session ID.
func (*PostgresProvider) Exist ¶
func (p *PostgresProvider) Exist(sid string) bool
Exist returns true if session with given ID exists.
func (*PostgresProvider) GC ¶
func (p *PostgresProvider) GC()
GC calls GC to clean expired sessions.
func (*PostgresProvider) Init ¶
func (p *PostgresProvider) Init(maxlifetime int64, connStr string) (err error)
Init initializes postgres session provider. connStr: user=a password=b host=localhost port=5432 dbname=c sslmode=disable
func (*PostgresProvider) Read ¶
func (p *PostgresProvider) Read(sid string) (session.RawStore, error)
Read returns raw session store by session ID.
func (*PostgresProvider) Regenerate ¶
func (p *PostgresProvider) Regenerate(oldsid, sid string) (_ session.RawStore, err error)
Regenerate regenerates a session store from old session ID to new one.
type PostgresStore ¶
type PostgresStore struct {
// contains filtered or unexported fields
}
PostgresStore represents a postgres session store implementation.
func NewPostgresStore ¶
func NewPostgresStore(c *sql.DB, sid string, kv map[interface{}]interface{}) *PostgresStore
NewPostgresStore creates and returns a postgres session store.
func (*PostgresStore) Delete ¶
func (s *PostgresStore) Delete(key interface{}) error
Delete delete a key from session.
func (*PostgresStore) Get ¶
func (s *PostgresStore) Get(key interface{}) interface{}
Get gets value by given key in session.
func (*PostgresStore) Release ¶
func (s *PostgresStore) Release() error
save postgres session values to database. must call this method to save values to database.
func (*PostgresStore) Set ¶
func (s *PostgresStore) Set(key, value interface{}) error
Set sets value to given key in session.