store

package
v0.1.8 Latest Latest
Warning

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

Go to latest
Published: May 21, 2023 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AttrExpire = "expire"
	AttrNx     = "nx"
	AttrXx     = "xx"
)
View Source
const (
	SetSuccess = "OK"
)

Variables

This section is empty.

Functions

func Redis

func Redis(c RedisConfig) *redis.Client

Types

type Attr

type Attr struct {
	Name  string
	Value interface{}
}

func WithExpire

func WithExpire(t time.Duration) *Attr

func WithNx

func WithNx() *Attr

func WithXx

func WithXx() *Attr

type Attrs

type Attrs []*Attr

func (Attrs) FindAttr

func (a Attrs) FindAttr(name string) *InterfaceResult

FindAttr 查找属性

type DBGetter

type DBGetter struct {
	Getter dbGetter
	Err    error
	Attrs  []*Attr

	Operation *Operation
}

func NewDBGetter

func NewDBGetter(getter dbGetter, operation *Operation, attrs ...*Attr) *DBGetter

func (*DBGetter) Get

func (g *DBGetter) Get(key string) *Result

Get 取数据 取出数据后任何格式数据均需要json 反序列化

func (*DBGetter) GetHash

func (g *DBGetter) GetHash(key string, field string) *Result

GetHash 取数据Hash

func (*DBGetter) GetHashAll

func (g *DBGetter) GetHashAll(key string) *Result

GetHashAll 取数据Hash

func (*DBGetter) GetMHash

func (g *DBGetter) GetMHash(key string, fields ...string) *Result

GetMHash 取数据MHash

type InterfaceResult

type InterfaceResult struct {
	Result interface{}
	Err    error
}

InterfaceResult set结果接口

func NewInterfaceResult

func NewInterfaceResult(result interface{}, err error) *InterfaceResult

func (*InterfaceResult) Unwrap

func (i *InterfaceResult) Unwrap() interface{}

func (*InterfaceResult) UnwrapWithDefault

func (i *InterfaceResult) UnwrapWithDefault(defaultValue interface{}) interface{}

type Iterator

type Iterator struct {
	Index int
	Items []interface{}
}

Iterator 迭代器

func NewIterator

func NewIterator(data []interface{}) *Iterator

func (*Iterator) HasNext

func (i *Iterator) HasNext() bool

HasNext 判断是否有下一个

func (*Iterator) Next

func (i *Iterator) Next() interface{}

Next 获取下一个

type Operation

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

Operation redis 操作

func NewOperation

func NewOperation(c RedisConfig) *Operation

func (*Operation) Del

func (o *Operation) Del(keys ...string) *InterfaceResult

Del 删除值 返回删除的数量

func (*Operation) Get

func (o *Operation) Get(key string) *Result

Get 获取单个值

func (*Operation) GetPrefix added in v0.0.5

func (o *Operation) GetPrefix() string

GetPrefix 获取redis prefix

func (*Operation) GetRedisClient added in v0.0.5

func (o *Operation) GetRedisClient() *redis.Client

GetRedisClient Redis 获取redis客户端

func (*Operation) HDel

func (o *Operation) HDel(key string, fields ...string) *InterfaceResult

HDel DelHash 删除hash值

func (*Operation) HGet

func (o *Operation) HGet(key string, field string) *Result

HGet GetHash 获取hash值

func (*Operation) HGetAll

func (o *Operation) HGetAll(key string) *Result

HGetAll GetHashAll 获取hash所有值

func (*Operation) HMGet

func (o *Operation) HMGet(key string, fields ...string) *Result

HMGet GetHashMulti 获取多个hash值

func (*Operation) HMSet

func (o *Operation) HMSet(key string, fields map[string]string) *InterfaceResult

HMSet SetHashMulti 设置多个hash值

func (*Operation) HSet

func (o *Operation) HSet(key string, field string, value interface{}) *InterfaceResult

HSet SetHash 设置hash值

func (*Operation) MGet

func (o *Operation) MGet(keys ...string) *Result

MGet 获取多值

func (*Operation) Set

func (o *Operation) Set(key string, value interface{}, attrs ...*Attr) *InterfaceResult

Set 设置值

type RedisConfig

type RedisConfig struct {
	Host     string
	Port     int
	Prefix   string
	Password string
	Database int
}

type RedisStore added in v0.0.5

type RedisStore struct {
	Once sync.Once
	// contains filtered or unexported fields
}

func (*RedisStore) GetClient added in v0.0.5

func (r *RedisStore) GetClient() *redis.Client

GetClient 获取client

type Result

type Result struct {
	StringResult string
	Err          error
	SliceResult  []interface{}
	MapResult    map[string]interface{}
	MapStringStr map[string]string
}

Result redis get 结果

func NewResult

func NewResult(result interface{}, err error) *Result

func (*Result) Iterator

func (r *Result) Iterator() *Iterator

Iterator 迭代器

func (*Result) UnWarp

func (r *Result) UnWarp() string

UnWarp 获取结果

func (*Result) UnWarpWithDefault

func (r *Result) UnWarpWithDefault(defaultValue string) string

UnWarpWithDefault 获取结果,如果有错误则返回默认值

func (*Result) UnwrapMap

func (r *Result) UnwrapMap() map[string]interface{}

UnwrapMap 取结果map

func (*Result) UnwrapMapStringStr

func (r *Result) UnwrapMapStringStr() map[string]string

UnwrapMapStringStr 获取map string string

func (*Result) UnwrapMapStringStrWithDefault

func (r *Result) UnwrapMapStringStrWithDefault(defaultValue map[string]string) map[string]string

UnwrapMapStringStrWithDefault 获取map string string 结果 如果有错误则返回默认值

func (*Result) UnwrapMapWithDefault

func (r *Result) UnwrapMapWithDefault(defaultValue map[string]interface{}) map[string]interface{}

UnwrapMapWithDefault 取结果map,如果有错误则返回默认值

func (*Result) UnwrapSlice

func (r *Result) UnwrapSlice() []interface{}

UnwrapSlice 取结果切片

func (*Result) UnwrapSliceWithDefault

func (r *Result) UnwrapSliceWithDefault(defaultValue []interface{}) []interface{}

UnwrapSliceWithDefault 取结果切片,如果有错误则返回默认值

Jump to

Keyboard shortcuts

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