redis

package
v1.0.6 Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2021 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const ProviderName = "redis"

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {

	// Redis server host
	Host string

	// Redis server port
	Port int64

	// Maximum number of idle connections in the redis server pool.
	MaxIdle int

	// Close connections after remaining idle for this duration. If the value
	// is zero, then idle connections are not closed. Applications should set
	// the timeout to a value less than the server's timeout.
	// (s)
	IdleTimeout int64

	// redis server conn auth, default ""
	Password string

	// select db number, default 0
	DbNumber int

	// sessionId as redis key prefix
	KeyPrefix string

	// session value serialize func
	SerializeFunc func(data map[string]interface{}) ([]byte, error)

	// session value unSerialize func
	UnSerializeFunc func(data []byte) (map[string]interface{}, error)
}

func (*Config) Name

func (mc *Config) Name() string

type Provider

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

func NewProvider

func NewProvider() *Provider

new redis provider

func (*Provider) Count

func (rp *Provider) Count() int

session values count

func (*Provider) Destroy

func (rp *Provider) Destroy(sessionId string) error

destroy session by sessionId

func (*Provider) GC

func (rp *Provider) GC()

session redis provider not need garbage collection

func (*Provider) Init

func (rp *Provider) Init(lifeTime int64, redisConfig fasthttpsession.ProviderConfig) error

init provider config

func (*Provider) NeedGC

func (rp *Provider) NeedGC() bool

not need gc

func (*Provider) ReadStore

func (rp *Provider) ReadStore(sessionId string) (fasthttpsession.SessionStore, error)

read session store by session id

func (*Provider) Regenerate

func (rp *Provider) Regenerate(oldSessionId string, sessionId string) (fasthttpsession.SessionStore, error)

regenerate session

type Store

type Store struct {
	fasthttpsession.Store
}

func NewRedisStore

func NewRedisStore(sessionId string) *Store

new default redis store

func NewRedisStoreData

func NewRedisStoreData(sessionId string, data map[string]interface{}) *Store

new redis store data

func (*Store) Save

func (rs *Store) Save(ctx *fasthttp.RequestCtx) error

save store

Jump to

Keyboard shortcuts

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