session

package module
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2023 License: MIT Imports: 9 Imported by: 6

README

session

infra.Go session module.

Documentation

Index

Constants

View Source
const (
	NAME = "SESSION"
)

Variables

View Source
var (
	ErrInvalidConnection = errors.New("Invalid session connection.")
)

Functions

func Clear

func Clear(prefixs ...string) error

Clear 清理会话

func Delete

func Delete(id string) error

Delete 删除会话

func Exists

func Exists(id string) (bool, error)

Exists 是否存在会话

func Keys

func Keys(prefixs ...string) ([]string, error)

KeysFrom 获取Keys

func Read

func Read(id string) (Map, error)

Read 读取会话

func Write

func Write(id string, value Map, expiries ...time.Duration) error

Write 写会话

Types

type Config

type Config struct {
	Driver  string
	Weight  int
	Prefix  string
	Codec   string
	Expiry  time.Duration
	Setting Map
}

type Configs

type Configs map[string]Config

type Connect

type Connect interface {
	Open() error
	Close() error

	Read(id string) ([]byte, error)
	Write(id string, val []byte, expiry time.Duration) error
	Exists(id string) (bool, error)
	Delete(id string) error
	Keys(prefix string) ([]string, error)
	Clear(prefix string) error
}

Connect 会话连接

type Driver

type Driver interface {
	Connect(*Instance) (Connect, error)
}

Driver 数据驱动

type Instance

type Instance struct {
	Name    string
	Config  Config
	Setting Map
	// contains filtered or unexported fields
}

type Module

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

func (*Module) Clear

func (this *Module) Clear(prefixs ...string) error

Clear 按前缀清理缓存

func (*Module) Config

func (this *Module) Config(name string, config Config)

func (*Module) Configs

func (this *Module) Configs(name string, config Configs)

func (*Module) Configure

func (this *Module) Configure(global Map)

func (*Module) Connect

func (this *Module) Connect()

func (*Module) Delete

func (this *Module) Delete(id string) error

Delete 删除会话

func (*Module) Driver

func (this *Module) Driver(name string, driver Driver)

Driver 注册驱动

func (*Module) Exists

func (this *Module) Exists(id string) (bool, error)

Exists 判断会话是否存在

func (*Module) Initialize

func (this *Module) Initialize()

func (*Module) Keys

func (this *Module) Keys(prefixs ...string) ([]string, error)

Keys 获取所有前缀的KEYS

func (*Module) Launch

func (this *Module) Launch()

func (*Module) Read

func (this *Module) Read(id string) (Map, error)

Read 读取会话

func (*Module) Register

func (this *Module) Register(name string, value Any)

func (*Module) Terminate

func (this *Module) Terminate()

func (*Module) Write

func (this *Module) Write(id string, val Map, expiries ...time.Duration) error

Write 写会话

Jump to

Keyboard shortcuts

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