Documentation ¶
Overview ¶
Package redis for session provider
depend on github.com/go-redis/redis
go install github.com/go-redis/redis
Usage: import(
_ "github.com/Sonek-HoangBui/beego/v2/server/web/session/redis_sentinel" "github.com/Sonek-HoangBui/beego/v2/server/web/session"
)
func init() { globalSessions, _ = session.NewManager("redis_sentinel", ``{"cookieName":"gosessionid","gclifetime":3600,"ProviderConfig":"127.0.0.1:26379;127.0.0.2:26379"}``) go globalSessions.GC() }
more detail about params: please check the notes on the function SessionInit in this package
Index ¶
- Variables
- type Provider
- func (rp *Provider) SessionAll(context.Context) int
- func (rp *Provider) SessionDestroy(ctx context.Context, sid string) error
- func (rp *Provider) SessionExist(ctx context.Context, sid string) (bool, error)
- func (rp *Provider) SessionGC(context.Context)
- func (rp *Provider) SessionInit(ctx context.Context, maxlifetime int64, cfgStr string) error
- func (rp *Provider) SessionRead(ctx context.Context, sid string) (session.Store, error)
- func (rp *Provider) SessionRegenerate(ctx context.Context, oldsid, sid string) (session.Store, error)
- type SessionStore
- func (rs *SessionStore) Delete(ctx context.Context, key interface{}) error
- func (rs *SessionStore) Flush(context.Context) error
- func (rs *SessionStore) Get(ctx context.Context, key interface{}) interface{}
- func (rs *SessionStore) SessionID(context.Context) string
- func (rs *SessionStore) SessionRelease(ctx context.Context, w http.ResponseWriter)
- func (rs *SessionStore) Set(ctx context.Context, key, value interface{}) error
Constants ¶
This section is empty.
Variables ¶
var DefaultPoolSize = 100
DefaultPoolSize redis_sentinel default pool size
Functions ¶
This section is empty.
Types ¶
type Provider ¶
type Provider struct { SavePath string `json:"save_path"` Poolsize int `json:"poolsize"` Password string `json:"password"` DbNum int `json:"db_num"` IdleTimeoutStr string `json:"idle_timeout"` IdleCheckFrequencyStr string `json:"idle_check_frequency"` MaxRetries int `json:"max_retries"` MasterName string `json:"master_name"` // contains filtered or unexported fields }
Provider redis_sentinel session provider
func (*Provider) SessionAll ¶
SessionAll return all activeSession
func (*Provider) SessionDestroy ¶
SessionDestroy delete redis session by id
func (*Provider) SessionExist ¶
SessionExist check redis_sentinel session exist by sid
func (*Provider) SessionInit ¶
SessionInit init redis_sentinel session cfgStr like redis sentinel addr,pool size,password,dbnum,masterName e.g. 127.0.0.1:26379;127.0.0.2:26379,100,1qaz2wsx,0,mymaster
func (*Provider) SessionRead ¶
SessionRead read redis_sentinel session by sid
type SessionStore ¶
type SessionStore struct {
// contains filtered or unexported fields
}
SessionStore redis_sentinel session store
func (*SessionStore) Delete ¶
func (rs *SessionStore) Delete(ctx context.Context, key interface{}) error
Delete value in redis_sentinel session
func (*SessionStore) Flush ¶
func (rs *SessionStore) Flush(context.Context) error
Flush clear all values in redis_sentinel session
func (*SessionStore) Get ¶
func (rs *SessionStore) Get(ctx context.Context, key interface{}) interface{}
Get value in redis_sentinel session
func (*SessionStore) SessionID ¶
func (rs *SessionStore) SessionID(context.Context) string
SessionID get redis_sentinel session id
func (*SessionStore) SessionRelease ¶
func (rs *SessionStore) SessionRelease(ctx context.Context, w http.ResponseWriter)
SessionRelease save session values to redis_sentinel