beego: Index | Files

package redis

import ""

Package redis for session provider

depend on

go install

Usage: import(

_ ""


func init() {
	globalSessions, _ = session.NewManager("redis", ``{"cookieName":"gosessionid","gclifetime":3600,"ProviderConfig":""}``)
	go globalSessions.GC()

more docs:


Package Files



var MaxPoolSize = 100

MaxPoolSize redis max pool size

type Provider Uses

type Provider struct {
    // contains filtered or unexported fields

Provider redis session provider

func (*Provider) SessionAll Uses

func (rp *Provider) SessionAll() int

SessionAll return all activeSession

func (*Provider) SessionDestroy Uses

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

SessionDestroy delete redis session by id

func (*Provider) SessionExist Uses

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

SessionExist check redis session exist by sid

func (*Provider) SessionGC Uses

func (rp *Provider) SessionGC()

SessionGC Impelment method, no used.

func (*Provider) SessionInit Uses

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

SessionInit init redis session savepath like redis server addr,pool size,password,dbnum,IdleTimeout second e.g.,100,astaxie,0,30

func (*Provider) SessionRead Uses

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

SessionRead read redis session by sid

func (*Provider) SessionRegenerate Uses

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

SessionRegenerate generate new sid for redis session

type SessionStore Uses

type SessionStore struct {
    // contains filtered or unexported fields

SessionStore redis session store

func (*SessionStore) Delete Uses

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

Delete value in redis session

func (*SessionStore) Flush Uses

func (rs *SessionStore) Flush() error

Flush clear all values in redis session

func (*SessionStore) Get Uses

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

Get value in redis session

func (*SessionStore) SessionID Uses

func (rs *SessionStore) SessionID() string

SessionID get redis session id

func (*SessionStore) SessionRelease Uses

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

SessionRelease save session values to redis

func (*SessionStore) Set Uses

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

Set value in redis session

Package redis imports 7 packages (graph) and is imported by 40 packages. Updated 2020-07-05. Refresh now. Tools for package owners.