sessions

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2020 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Del

func Del(c *gin.Context, key string)

Del delete the specified session

func Get

func Get(c *gin.Context, key string) string

Get gets the specified session

func Set

func Set(c *gin.Context, key, val string)

Set set session

Types

type RedisStoreConfig

type RedisStoreConfig struct {
	RedisType string `mapstructure:"redis_type"`

	Network  string `mapstructure:"network"`
	Addr     string `mapstructure:"addr"`
	Password string `mapstructure:"password"`
	DB       int    `mapstructure:"db"`

	Addresses          []string `mapstructure:"addresses"`
	Username           string   `mapstructure:"username"`
	SentinelPassword   string   `mapstructure:"sentinel_password"`
	MaxRetries         int      `mapstructure:"max_retries"`
	MinRetryBackoff    string   `mapstructure:"min_retry_backoff"`
	MaxRetryBackoff    string   `mapstructure:"max_retry_backoff"`
	DialTimeout        string   `mapstructure:"dial_timeout"`
	ReadTimeout        string   `mapstructure:"read_timeout"`
	WriteTimeout       string   `mapstructure:"write_timeout"`
	PoolSize           int      `mapstructure:"pool_size"`
	MinIdleConns       int      `mapstructure:"min_idle_conns"`
	MaxConnAge         string   `mapstructure:"max_conn_age"`
	PoolTimeout        string   `mapstructure:"pool_timeout"`
	IdleTimeout        string   `mapstructure:"idle_timeout"`
	IdleCheckFrequency string   `mapstructure:"idle_check_frequency"`
	MaxRedirects       int      `mapstructure:"max_redirects"`
	ReadOnly           bool     `mapstructure:"read_only"`
	RouteByLatency     bool     `mapstructure:"route_by_latency"`
	RouteRandomly      bool     `mapstructure:"route_randomly"`
	SlaveOnly          bool     `mapstructure:"slave_only"`
	Randomly           bool     `mapstructure:"randomly"`
	MasterName         string   `mapstructure:"master_name"`

	NewClient    func(opt *redis.Options) *redis.Client
	TLSConfig    *tls.Config
	Dialer       func(ctx context.Context, network, addr string) (net.Conn, error)
	OnConnect    func(ctx context.Context, cn *redis.Conn) error
	Limiter      redis.Limiter
	ClusterSlots func(ctx context.Context) ([]redis.ClusterSlot, error)
}

RedisStoreConfig redis config

func (RedisStoreConfig) NewRedis

func (rsc RedisStoreConfig) NewRedis() redis.Cmdable

NewRedis get a storage operation instance of redis according to the configuration information

type Sessions

type Sessions struct {
	Driver           string           `mapstructure:"driver"`
	RedisStoreConfig RedisStoreConfig `mapstructure:"redis"`
	Key              string           `mapstructure:"key"`
	Name             string           `mapstructure:"name"`
	Domain           string           `mapstructure:"domain"`
	MaxAge           string           `mapstructure:"max_age"`
	HTTPOnly         bool             `mapstructure:"http_only"`
	// contains filtered or unexported fields
}

Sessions session related function processing

func (*Sessions) Inject

func (s *Sessions) Inject(engine *gin.Engine) gin.IRoutes

Inject start the session service, call it in the custom routing code, and import it. *gin.Engine object

func (*Sessions) OnChange

func (s *Sessions) OnChange(viper *viper.Viper)

OnChange reinitialize when configuration file changes

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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