session

package
v3.0.1+incompatible Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 11, 2016 License: Apache-2.0, Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

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) Destory

func (p *PostgresProvider) Destory(sid string) error

Destory 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) Flush

func (s *PostgresStore) Flush() error

Flush deletes all session data.

func (*PostgresStore) Get

func (s *PostgresStore) Get(key interface{}) interface{}

Get gets value by given key in session.

func (*PostgresStore) ID

func (s *PostgresStore) ID() string

ID returns current session ID.

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL