postgres

package
v1.12.1 Latest Latest
Warning

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

Go to latest
Published: Dec 18, 2019 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package postgres for session provider

depends on github.com/lib/pq:

go install github.com/lib/pq

needs this table in your database:

CREATE TABLE session ( session_key char(64) NOT NULL, session_data bytea, session_expiry timestamp NOT NULL, CONSTRAINT session_key PRIMARY KEY(session_key) );

will be activated with these settings in app.conf:

SessionOn = true SessionProvider = postgresql SessionSavePath = "user=a password=b dbname=c sslmode=disable" SessionName = session

Usage: import(

_ "github.com/astaxie/beego/session/postgresql"
"github.com/astaxie/beego/session"

)

func init() {
	globalSessions, _ = session.NewManager("postgresql", ``{"cookieName":"gosessionid","gclifetime":3600,"ProviderConfig":"user=pqgotest dbname=pqgotest sslmode=verify-full"}``)
	go globalSessions.GC()
}

more docs: http://beego.me/docs/module/session.md

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Provider added in v1.6.0

type Provider struct {
	// contains filtered or unexported fields
}

Provider postgresql session provider

func (*Provider) SessionAll added in v1.6.0

func (mp *Provider) SessionAll() int

SessionAll count values in postgresql session

func (*Provider) SessionDestroy added in v1.6.0

func (mp *Provider) SessionDestroy(sid string) error

SessionDestroy delete postgresql session by sid

func (*Provider) SessionExist added in v1.6.0

func (mp *Provider) SessionExist(sid string) bool

SessionExist check postgresql session exist

func (*Provider) SessionGC added in v1.6.0

func (mp *Provider) SessionGC()

SessionGC delete expired values in postgresql session

func (*Provider) SessionInit added in v1.6.0

func (mp *Provider) SessionInit(maxlifetime int64, savePath string) error

SessionInit init postgresql session. savepath is the connection string of postgresql.

func (*Provider) SessionRead added in v1.6.0

func (mp *Provider) SessionRead(sid string) (session.Store, error)

SessionRead get postgresql session by sid

func (*Provider) SessionRegenerate added in v1.6.0

func (mp *Provider) SessionRegenerate(oldsid, sid string) (session.Store, error)

SessionRegenerate generate new sid for postgresql session

type SessionStore added in v1.6.0

type SessionStore struct {
	// contains filtered or unexported fields
}

SessionStore postgresql session store

func (*SessionStore) Delete added in v1.6.0

func (st *SessionStore) Delete(key interface{}) error

Delete value in postgresql session

func (*SessionStore) Flush added in v1.6.0

func (st *SessionStore) Flush() error

Flush clear all values in postgresql session

func (*SessionStore) Get added in v1.6.0

func (st *SessionStore) Get(key interface{}) interface{}

Get value from postgresql session

func (*SessionStore) SessionID added in v1.6.0

func (st *SessionStore) SessionID() string

SessionID get session id of this postgresql session store

func (*SessionStore) SessionRelease added in v1.6.0

func (st *SessionStore) SessionRelease(w http.ResponseWriter)

SessionRelease save postgresql session values to database. must call this method to save values to database.

func (*SessionStore) Set added in v1.6.0

func (st *SessionStore) Set(key, value interface{}) error

Set value in postgresql session. it is temp value in map.

Jump to

Keyboard shortcuts

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