base

package
v1.0.14 Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ValueTypeInt     = "int"
	ValueTypeInt8    = "int8"
	ValueTypeInt16   = "int16"
	ValueTypeInt32   = "int32"
	ValueTypeInt64   = "int64"
	ValueTypeUint    = "uint"
	ValueTypeUint8   = "uint8"
	ValueTypeUint16  = "uint16"
	ValueTypeUint32  = "uint32"
	ValueTypeUint64  = "uint64"
	ValueTypeFloat32 = "float32"
	ValueTypeFloat64 = "float64"
	ValueTypeBool    = "bool"
	ValueTypeString  = "string"
	ValueTypeTime    = "time.Time"
	ValueTypeTimeP   = "*time.Time"
	ValueTypeGTime   = "gtime.Time"
	ValueTypeGTimeP  = "*gtime.Time"
)

Variables

This section is empty.

Functions

func SetField

func SetField[T any](t *T, fieldName string, value interface{}) (err error)

SetField 是一个泛型函数,用于设置任何结构体中指定字段的值。

Types

type Base

type Base struct {
	Ctx    context.Context
	Prefix string

	IsEnabledPrefix bool
}

func NewBase added in v1.0.5

func NewBase(ctx context.Context, prefix string, isEnabledPrefix bool) *Base

func (*Base) GetKey added in v1.0.12

func (s *Base) GetKey(key string) string

func (*Base) GetKeys added in v1.0.12

func (s *Base) GetKeys(keys []string) []string

type GenericsVarStructHelper

type GenericsVarStructHelper struct {
}

GenericsVarStructHelper 泛型值转换

func NewGenericsVarStructHelper

func NewGenericsVarStructHelper() *GenericsVarStructHelper

func (*GenericsVarStructHelper) Reflect2ValueByType

func (s *GenericsVarStructHelper) Reflect2ValueByType(val reflect.Value, fieldName string, vType string) (value interface{}, err error)

Reflect2ValueByType 反射获取值 用于写入redis 需将特殊类型转换字符串或整形时间戳等 总之必须是Redis支持的类型 其实最终都是string

func (*GenericsVarStructHelper) Var2ValueByType

func (s *GenericsVarStructHelper) Var2ValueByType(v *g.Var, val reflect.Value, fieldName string, vType string) (err error)

Var2ValueByType 反射将 gvar.Var 转换为结构体字段的值

type TransactionHelper

type TransactionHelper struct {
	*Base
}

TransactionHelper Redis Transaction类型助手类

func NewTransactionHelper

func NewTransactionHelper(base *Base) *TransactionHelper

NewTransactionHelper 实例化

func (TransactionHelper) Discard

func (s TransactionHelper) Discard() (v *gvar.Var, err error)

func (TransactionHelper) Exec

func (s TransactionHelper) Exec() (v *gvar.Var, err error)

func (TransactionHelper) Multi

func (s TransactionHelper) Multi() (v *gvar.Var, err error)

func (TransactionHelper) UnWatch

func (s TransactionHelper) UnWatch() (v *gvar.Var, err error)

func (TransactionHelper) Watch

func (s TransactionHelper) Watch(key string) (v *gvar.Var, err error)

Jump to

Keyboard shortcuts

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