redis_cluster

package
v2.0.3 Latest Latest
Warning

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

Go to latest
Published: Jul 30, 2021 License: Apache-2.0, Apache-2.0 Imports: 9 Imported by: 0

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/beego/beego/v2/server/web/session/redis_cluster"
"github.com/beego/beego/v2/server/web/session"

)

func init() {
	globalSessions, _ = session.NewManager("redis_cluster", ``{"cookieName":"gosessionid","gclifetime":3600,"ProviderConfig":"127.0.0.1:7070;127.0.0.1:7071"}``)
	go globalSessions.GC()
}

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

Index

Constants

This section is empty.

Variables

View Source
var MaxPoolSize = 1000

MaxPoolSize redis_cluster max 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"`
	// contains filtered or unexported fields
}

Provider redis_cluster session provider

func (*Provider) SessionAll

func (rp *Provider) SessionAll(context.Context) int

SessionAll return all activeSession

func (*Provider) SessionDestroy

func (rp *Provider) SessionDestroy(ctx context.Context, sid string) error

SessionDestroy delete redis session by id

func (*Provider) SessionExist

func (rp *Provider) SessionExist(ctx context.Context, sid string) (bool, error)

SessionExist check redis_cluster session exist by sid

func (*Provider) SessionGC

func (rp *Provider) SessionGC(context.Context)

SessionGC Impelment method, no used.

func (*Provider) SessionInit

func (rp *Provider) SessionInit(ctx context.Context, maxlifetime int64, cfgStr string) error

SessionInit init redis_cluster session cfgStr like redis server addr,pool size,password,dbnum e.g. 127.0.0.1:6379;127.0.0.1:6380,100,test,0

func (*Provider) SessionRead

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

SessionRead read redis_cluster session by sid

func (*Provider) SessionRegenerate

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

SessionRegenerate generate new sid for redis_cluster session

type SessionStore

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

SessionStore redis_cluster session store

func (*SessionStore) Delete

func (rs *SessionStore) Delete(ctx context.Context, key interface{}) error

Delete value in redis_cluster session

func (*SessionStore) Flush

func (rs *SessionStore) Flush(context.Context) error

Flush clear all values in redis_cluster session

func (*SessionStore) Get

func (rs *SessionStore) Get(ctx context.Context, key interface{}) interface{}

Get value in redis_cluster session

func (*SessionStore) SessionID

func (rs *SessionStore) SessionID(context.Context) string

SessionID get redis_cluster session id

func (*SessionStore) SessionRelease

func (rs *SessionStore) SessionRelease(ctx context.Context, w http.ResponseWriter)

SessionRelease save session values to redis_cluster

func (*SessionStore) Set

func (rs *SessionStore) Set(ctx context.Context, key, value interface{}) error

Set value in redis_cluster session

Jump to

Keyboard shortcuts

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