dbservice

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Jan 6, 2025 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var LockOrWaitOptionDefault = LockOrWaitOption{}

默认锁配置

Functions

This section is empty.

Types

type DBService

type DBService struct {
	*zservice.ZService

	Gorm  *GormEX    // 数据库 gorm
	Redis *GoRedisEX // 缓存 redis
	// contains filtered or unexported fields
}

数据服务,结合:github.com/redis/go-redis/v9 和 gorm.io/gorm 配合使用

func NewDBService

func NewDBService(opt DBServiceOption) *DBService

func (*DBService) GetNewTableID

func (dbs *DBService) GetNewTableID(
	ctx *zservice.Context,
	genID func() uint32,
	verifyFN func(ctx *zservice.Context, id uint32) (bool, *zservice.Error),
) (uint32, *zservice.Error)

获取一个新的ID

func (*DBService) GetTableValue

func (dbs *DBService) GetTableValue(ctx *zservice.Context, opt GetTableValueOption) *zservice.Error

获取指定值 注意,如果没找到数据回返回:zservice.Code_NotFound

func (*DBService) HasTableValue

func (dbs *DBService) HasTableValue(ctx *zservice.Context, opt HasTableValueOption) (bool, *zservice.Error)

查询表中是否有指定值

func (*DBService) IsNotFoundErr

func (dbs *DBService) IsNotFoundErr(e error) bool

是否是未找到错误

func (*DBService) SaveTableValue

func (dbs *DBService) SaveTableValue(ctx *zservice.Context, opt SaveTableValueOption) *zservice.Error

存储表数据

func (*DBService) SyncTableCache

func (dbs *DBService) SyncTableCache(ctx *zservice.Context, tabArr any, getRK func(v any) string) *zservice.Error

同步表缓存

type DBServiceOption

type DBServiceOption struct {
	Name            string           // 服务名称 仅用于日志显示,如果主服务中有多个DBService,建议配置,如果只有一个DBService,可以忽略此配置
	DBType          string           // 数据库 类型 目前支持 mysql/postgres
	DBName          string           // 数据库 名称
	DBHost          string           // 数据库 地址 填入地址才会启用 Gorm 功能
	DBPort          int              // 数据库 端口
	DBUser          string           // 数据库 用户名
	DBPass          string           // 数据库 密码
	DBParams        string           // 数据库 额外参数
	MaxIdleConns    int              // 最大空闲连接数 default: 10
	MaxOpenConns    int              // 最大连接数 default: 30
	ConnMaxLifetime float32          // 连接最大生命周期 default: 300s
	RedisAddr       string           // redis 地址 填入地址才会启用 Redis 功能
	RedisPass       string           // redis 密码
	RedisPrefix     string           // redis 前缀 默认使用 zservice.Init 中的 serviceName
	Debug           bool             // 是否开启 debug
	OnStart         func(*DBService) // 启动的回调
}

type GetTableValueOption

type GetTableValueOption struct {
	Tab        any                                                          // 需要查询的表结构体对象
	RK         string                                                       // redis缓存Key
	SQLConds   []any                                                        // 查询条件, 使用 Gorm 中的 Where 条件,不要自己拼接,避免 sql 注入
	Order      string                                                       // 排序
	Expires    *time.Duration                                               // 缓存过期时间,默认:10天, 0 表示不过期
	RedisGetFN func(*zservice.Context, any, string) (bool, *zservice.Error) // 获取缓存数据,需要对数据进行重新处理, 返回处理状态或者错误消息,处理后的数据为空表示处理失败,会继续进行数据查询
	RedisSetFN func(*zservice.Context, any) string                          // 存储缓存数据,返回处理后的字符串,字符串将存储到 redis
}

type GoRedisEX

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

func NewGoRedisEX

func NewGoRedisEX(opt DBServiceOption) *GoRedisEX

func (*GoRedisEX) AddKeyPrefix

func (r *GoRedisEX) AddKeyPrefix(key string) string

添加前缀

func (*GoRedisEX) AddkeyPrefixs

func (r *GoRedisEX) AddkeyPrefixs(key ...string) []string

func (*GoRedisEX) BLMPop

func (r *GoRedisEX) BLMPop(ctx context.Context, timeout time.Duration, direction string, count int64, keys ...string) *redis.KeyValuesCmd

func (*GoRedisEX) BLMPopCtx

func (r *GoRedisEX) BLMPopCtx(ctx context.Context, timeout time.Duration, direction string, count int64, keys ...string) *redis.KeyValuesCmd

func (*GoRedisEX) BLPop

func (r *GoRedisEX) BLPop(ctx context.Context, timeout time.Duration, keys ...string) *redis.StringSliceCmd

func (*GoRedisEX) BLPopCtx

func (r *GoRedisEX) BLPopCtx(ctx context.Context, timeout time.Duration, keys ...string) *redis.StringSliceCmd

func (*GoRedisEX) BRPop

func (r *GoRedisEX) BRPop(ctx context.Context, timeout time.Duration, keys ...string) *redis.StringSliceCmd

func (*GoRedisEX) BRPopCtx

func (r *GoRedisEX) BRPopCtx(ctx context.Context, timeout time.Duration, keys ...string) *redis.StringSliceCmd

func (*GoRedisEX) BRPopLPush

func (r *GoRedisEX) BRPopLPush(ctx context.Context, source, destination string, timeout time.Duration) *redis.StringCmd

func (*GoRedisEX) BRPopLPushCtx

func (r *GoRedisEX) BRPopLPushCtx(ctx context.Context, source, destination string, timeout time.Duration) *redis.StringCmd

func (*GoRedisEX) Client

func (r *GoRedisEX) Client() *redis.Client

获取原生客户端

func (*GoRedisEX) Copy

func (r *GoRedisEX) Copy(key, newkey string, db int, replace bool) *redis.IntCmd

func (*GoRedisEX) CopyCtx

func (r *GoRedisEX) CopyCtx(ctx context.Context, key, newkey string, db int, replace bool) *redis.IntCmd

func (*GoRedisEX) Del

func (r *GoRedisEX) Del(keys ...string) *redis.IntCmd

func (*GoRedisEX) DelCtx

func (r *GoRedisEX) DelCtx(ctx context.Context, keys ...string) *redis.IntCmd

func (*GoRedisEX) Dump

func (r *GoRedisEX) Dump(key string) *redis.StringCmd

func (*GoRedisEX) DumpCtx

func (r *GoRedisEX) DumpCtx(ctx context.Context, key string) *redis.StringCmd

func (*GoRedisEX) Exists

func (r *GoRedisEX) Exists(keys ...string) *redis.IntCmd

func (*GoRedisEX) ExistsCtx

func (r *GoRedisEX) ExistsCtx(ctx context.Context, keys ...string) *redis.IntCmd

func (*GoRedisEX) Expire

func (r *GoRedisEX) Expire(key string, expiration time.Duration) *redis.BoolCmd

func (*GoRedisEX) ExpireAt

func (r *GoRedisEX) ExpireAt(key string, expiration time.Time) *redis.BoolCmd

func (*GoRedisEX) ExpireAtCtx

func (r *GoRedisEX) ExpireAtCtx(ctx context.Context, key string, expiration time.Time) *redis.BoolCmd

func (*GoRedisEX) ExpireCtx

func (r *GoRedisEX) ExpireCtx(ctx context.Context, key string, expiration time.Duration) *redis.BoolCmd

func (*GoRedisEX) ExpireGT

func (r *GoRedisEX) ExpireGT(key string, expiration time.Duration) *redis.BoolCmd

func (*GoRedisEX) ExpireGTCtx

func (r *GoRedisEX) ExpireGTCtx(ctx context.Context, key string, expiration time.Duration) *redis.BoolCmd

func (*GoRedisEX) ExpireLT

func (r *GoRedisEX) ExpireLT(key string, expiration time.Duration) *redis.BoolCmd

func (*GoRedisEX) ExpireLTCtx

func (r *GoRedisEX) ExpireLTCtx(ctx context.Context, key string, expiration time.Duration) *redis.BoolCmd

func (*GoRedisEX) ExpireNX

func (r *GoRedisEX) ExpireNX(key string, expiration time.Duration) *redis.BoolCmd

func (*GoRedisEX) ExpireNXCtx

func (r *GoRedisEX) ExpireNXCtx(ctx context.Context, key string, expiration time.Duration) *redis.BoolCmd

func (*GoRedisEX) ExpireTime

func (r *GoRedisEX) ExpireTime(key string) *redis.DurationCmd

func (*GoRedisEX) ExpireTimeCtx

func (r *GoRedisEX) ExpireTimeCtx(ctx context.Context, key string) *redis.DurationCmd

func (*GoRedisEX) ExpireXX

func (r *GoRedisEX) ExpireXX(key string, expiration time.Duration) *redis.BoolCmd

func (*GoRedisEX) ExpireXXCtx

func (r *GoRedisEX) ExpireXXCtx(ctx context.Context, key string, expiration time.Duration) *redis.BoolCmd

func (*GoRedisEX) Get

func (r *GoRedisEX) Get(key string) *redis.StringCmd

func (*GoRedisEX) GetCtx

func (r *GoRedisEX) GetCtx(ctx context.Context, key string) *redis.StringCmd

func (*GoRedisEX) GetScan

func (r *GoRedisEX) GetScan(key string, v any) *zservice.Error

查询到的内容直接转结构体

func (*GoRedisEX) HDel

func (r *GoRedisEX) HDel(key string, fields ...string) *redis.IntCmd

func (*GoRedisEX) HDelCtx

func (r *GoRedisEX) HDelCtx(ctx context.Context, key string, fields ...string) *redis.IntCmd

func (*GoRedisEX) HExists

func (r *GoRedisEX) HExists(key, field string) *redis.BoolCmd

func (*GoRedisEX) HExistsCtx

func (r *GoRedisEX) HExistsCtx(ctx context.Context, key, field string) *redis.BoolCmd

func (*GoRedisEX) HGet

func (r *GoRedisEX) HGet(key, field string) *redis.StringCmd

func (*GoRedisEX) HGetAll

func (r *GoRedisEX) HGetAll(key string) *redis.MapStringStringCmd

func (*GoRedisEX) HGetAllCtx

func (r *GoRedisEX) HGetAllCtx(ctx context.Context, key string) *redis.MapStringStringCmd

func (*GoRedisEX) HGetCtx

func (r *GoRedisEX) HGetCtx(ctx context.Context, key, field string) *redis.StringCmd

func (*GoRedisEX) HIncrBy

func (r *GoRedisEX) HIncrBy(key, field string, incr int64) *redis.IntCmd

func (*GoRedisEX) HIncrByCtx

func (r *GoRedisEX) HIncrByCtx(ctx context.Context, key, field string, incr int64) *redis.IntCmd

func (*GoRedisEX) HIncrByFloat

func (r *GoRedisEX) HIncrByFloat(key, field string, incr float64) *redis.FloatCmd

func (*GoRedisEX) HIncrByFloatCtx

func (r *GoRedisEX) HIncrByFloatCtx(ctx context.Context, key, field string, incr float64) *redis.FloatCmd

func (*GoRedisEX) HKeys

func (r *GoRedisEX) HKeys(key string) *redis.StringSliceCmd

func (*GoRedisEX) HKeysCtx

func (r *GoRedisEX) HKeysCtx(ctx context.Context, key string) *redis.StringSliceCmd

func (*GoRedisEX) HLen

func (r *GoRedisEX) HLen(key string) *redis.IntCmd

func (*GoRedisEX) HLenCtx

func (r *GoRedisEX) HLenCtx(ctx context.Context, key string) *redis.IntCmd

func (*GoRedisEX) HMGet

func (r *GoRedisEX) HMGet(key string, fields ...string) *redis.SliceCmd

func (*GoRedisEX) HMGetCtx

func (r *GoRedisEX) HMGetCtx(ctx context.Context, key string, fields ...string) *redis.SliceCmd

func (*GoRedisEX) HMSet

func (r *GoRedisEX) HMSet(key string, values ...interface{}) *redis.BoolCmd

func (*GoRedisEX) HMSetCtx

func (r *GoRedisEX) HMSetCtx(ctx context.Context, key string, values ...interface{}) *redis.BoolCmd

func (*GoRedisEX) HRandField

func (r *GoRedisEX) HRandField(key string, count int) *redis.StringSliceCmd

func (*GoRedisEX) HRandFieldCtx

func (r *GoRedisEX) HRandFieldCtx(ctx context.Context, key string, count int) *redis.StringSliceCmd

func (*GoRedisEX) HRandFieldWithValues

func (r *GoRedisEX) HRandFieldWithValues(key string, count int) *redis.KeyValueSliceCmd

func (*GoRedisEX) HRandFieldWithValuesCtx

func (r *GoRedisEX) HRandFieldWithValuesCtx(ctx context.Context, key string, count int) *redis.KeyValueSliceCmd

func (*GoRedisEX) HScan

func (r *GoRedisEX) HScan(key string, cursor uint64, match string, count int64) *redis.ScanCmd

func (*GoRedisEX) HScanCtx

func (r *GoRedisEX) HScanCtx(ctx context.Context, key string, cursor uint64, match string, count int64) *redis.ScanCmd

func (*GoRedisEX) HSet

func (r *GoRedisEX) HSet(key string, values ...interface{}) *redis.IntCmd

func (*GoRedisEX) HSetCtx

func (r *GoRedisEX) HSetCtx(ctx context.Context, key string, values ...interface{}) *redis.IntCmd

func (*GoRedisEX) HSetNX

func (r *GoRedisEX) HSetNX(key, field string, value interface{}) *redis.BoolCmd

func (*GoRedisEX) HSetNxCtx

func (r *GoRedisEX) HSetNxCtx(ctx context.Context, key, field string, value interface{}) *redis.BoolCmd

func (*GoRedisEX) HVals

func (r *GoRedisEX) HVals(key string) *redis.StringSliceCmd

func (*GoRedisEX) HValsCtx

func (r *GoRedisEX) HValsCtx(ctx context.Context, key string) *redis.StringSliceCmd

func (*GoRedisEX) IsNotFoundErr

func (r *GoRedisEX) IsNotFoundErr(e error) bool

是否是空数据错误

func (*GoRedisEX) Keys

func (r *GoRedisEX) Keys(pattern string) *redis.StringSliceCmd

注意,返回数据包含 key 前缀

func (*GoRedisEX) KeysCtx

func (r *GoRedisEX) KeysCtx(ctx context.Context, pattern string) *redis.StringSliceCmd

注意,返回数据包含 key 前缀

func (*GoRedisEX) LIndex

func (r *GoRedisEX) LIndex(key string, index int64) *redis.StringCmd

func (*GoRedisEX) LIndexCtx

func (r *GoRedisEX) LIndexCtx(ctx context.Context, key string, index int64) *redis.StringCmd

func (*GoRedisEX) LInsert

func (r *GoRedisEX) LInsert(key string, op string, pivot any, value any) *redis.IntCmd

func (*GoRedisEX) LInsertAfter

func (r *GoRedisEX) LInsertAfter(key string, pivot any, value any) *redis.IntCmd

func (*GoRedisEX) LInsertAfterCtx

func (r *GoRedisEX) LInsertAfterCtx(ctx context.Context, key string, pivot any, value any) *redis.IntCmd

func (*GoRedisEX) LInsertBefore

func (r *GoRedisEX) LInsertBefore(key string, pivot any, value any) *redis.IntCmd

func (*GoRedisEX) LInsertBeforeCtx

func (r *GoRedisEX) LInsertBeforeCtx(ctx context.Context, key string, pivot any, value any) *redis.IntCmd

func (*GoRedisEX) LInsertCtx

func (r *GoRedisEX) LInsertCtx(ctx context.Context, key string, op string, pivot any, value any) *redis.IntCmd

func (*GoRedisEX) LLen

func (r *GoRedisEX) LLen(key string) *redis.IntCmd

func (*GoRedisEX) LLenCtx

func (r *GoRedisEX) LLenCtx(ctx context.Context, key string) *redis.IntCmd

func (*GoRedisEX) LMPop

func (r *GoRedisEX) LMPop(ctx context.Context, direction string, count int64, keys ...string) *redis.KeyValuesCmd

func (*GoRedisEX) LMPopCtx

func (r *GoRedisEX) LMPopCtx(ctx context.Context, direction string, count int64, keys ...string) *redis.KeyValuesCmd

func (*GoRedisEX) LPop

func (r *GoRedisEX) LPop(key string) *redis.StringCmd

func (*GoRedisEX) LPopCount

func (r *GoRedisEX) LPopCount(key string, count int) *redis.StringSliceCmd

func (*GoRedisEX) LPopCountCtx

func (r *GoRedisEX) LPopCountCtx(ctx context.Context, key string, count int) *redis.StringSliceCmd

func (*GoRedisEX) LPopCtx

func (r *GoRedisEX) LPopCtx(ctx context.Context, key string) *redis.StringCmd

func (*GoRedisEX) LPos

func (r *GoRedisEX) LPos(key string, element string, args redis.LPosArgs) *redis.IntCmd

func (*GoRedisEX) LPosCount

func (r *GoRedisEX) LPosCount(key string, element string, count int64, args redis.LPosArgs) *redis.IntSliceCmd

func (*GoRedisEX) LPosCountCtx

func (r *GoRedisEX) LPosCountCtx(ctx context.Context, key string, element string, count int64, args redis.LPosArgs) *redis.IntSliceCmd

func (*GoRedisEX) LPosCtx

func (r *GoRedisEX) LPosCtx(ctx context.Context, key string, element string, args redis.LPosArgs) *redis.IntCmd

func (*GoRedisEX) LPush

func (r *GoRedisEX) LPush(key string, values ...any) *redis.IntCmd

func (*GoRedisEX) LPushCtx

func (r *GoRedisEX) LPushCtx(ctx context.Context, key string, values ...any) *redis.IntCmd

func (*GoRedisEX) LPushX

func (r *GoRedisEX) LPushX(key string, values ...any) *redis.IntCmd

func (*GoRedisEX) LPushXCtx

func (r *GoRedisEX) LPushXCtx(ctx context.Context, key string, values ...any) *redis.IntCmd

func (*GoRedisEX) LRange

func (r *GoRedisEX) LRange(key string, start, stop int64) *redis.StringSliceCmd

func (*GoRedisEX) LRangeCtx

func (r *GoRedisEX) LRangeCtx(ctx context.Context, key string, start, stop int64) *redis.StringSliceCmd

func (*GoRedisEX) LRem

func (r *GoRedisEX) LRem(key string, count int64, value interface{}) *redis.IntCmd

func (*GoRedisEX) LRemCtx

func (r *GoRedisEX) LRemCtx(ctx context.Context, key string, count int64, value interface{}) *redis.IntCmd

func (*GoRedisEX) LSet

func (r *GoRedisEX) LSet(key string, index int64, value interface{}) *redis.StatusCmd

func (*GoRedisEX) LSetCtx

func (r *GoRedisEX) LSetCtx(ctx context.Context, key string, index int64, value interface{}) *redis.StatusCmd

func (*GoRedisEX) LTrim

func (r *GoRedisEX) LTrim(key string, start, stop int64) *redis.StatusCmd

func (*GoRedisEX) LTrimCtx

func (r *GoRedisEX) LTrimCtx(ctx context.Context, key string, start, stop int64) *redis.StatusCmd

func (*GoRedisEX) Lock

func (r *GoRedisEX) Lock(key string, timeout ...time.Duration) (func(), *zservice.Error)

加锁 timeout 默认 1分钟, 已经加锁的直接返回错误

func (*GoRedisEX) LockCtx

func (r *GoRedisEX) LockCtx(ctx context.Context, key string, timeout ...time.Duration) (func(), *zservice.Error)

func (*GoRedisEX) LockOrWait added in v0.1.8

func (r *GoRedisEX) LockOrWait(key string, opt LockOrWaitOption) (func(), *zservice.Error)

加锁,等待直到超时, timeout[0]等待时间 timeout[1]超时时间

func (*GoRedisEX) LockOrWaitCtx added in v0.1.8

func (r *GoRedisEX) LockOrWaitCtx(ctx context.Context, key string, opt LockOrWaitOption) (func(), *zservice.Error)

func (*GoRedisEX) Migrate

func (r *GoRedisEX) Migrate(host, port, key string, db int, timeout time.Duration) *redis.StatusCmd

func (*GoRedisEX) MigrateCtx

func (r *GoRedisEX) MigrateCtx(ctx context.Context, host, port, key string, db int, timeout time.Duration) *redis.StatusCmd

func (*GoRedisEX) Move

func (r *GoRedisEX) Move(key string, db int) *redis.BoolCmd

func (*GoRedisEX) MoveCtx

func (r *GoRedisEX) MoveCtx(ctx context.Context, key string, db int) *redis.BoolCmd

func (*GoRedisEX) ObjectEncoding

func (r *GoRedisEX) ObjectEncoding(key string) *redis.StringCmd

func (*GoRedisEX) ObjectEncodingCtx

func (r *GoRedisEX) ObjectEncodingCtx(ctx context.Context, key string) *redis.StringCmd

func (*GoRedisEX) ObjectFreq

func (r *GoRedisEX) ObjectFreq(key string) *redis.IntCmd

func (*GoRedisEX) ObjectFreqCtx

func (r *GoRedisEX) ObjectFreqCtx(ctx context.Context, key string) *redis.IntCmd

func (*GoRedisEX) ObjectIdleTime

func (r *GoRedisEX) ObjectIdleTime(key string) *redis.DurationCmd

func (*GoRedisEX) ObjectIdleTimeCtx

func (r *GoRedisEX) ObjectIdleTimeCtx(ctx context.Context, key string) *redis.DurationCmd

func (*GoRedisEX) ObjectRefCount

func (r *GoRedisEX) ObjectRefCount(key string) *redis.IntCmd

func (*GoRedisEX) ObjectRefCountCtx

func (r *GoRedisEX) ObjectRefCountCtx(ctx context.Context, key string) *redis.IntCmd

func (*GoRedisEX) PExpire

func (r *GoRedisEX) PExpire(key string, expiration time.Duration) *redis.BoolCmd

func (*GoRedisEX) PExpireAt

func (r *GoRedisEX) PExpireAt(key string, t time.Time) *redis.BoolCmd

func (*GoRedisEX) PExpireAtCtx

func (r *GoRedisEX) PExpireAtCtx(ctx context.Context, key string, t time.Time) *redis.BoolCmd

func (*GoRedisEX) PExpireCtx

func (r *GoRedisEX) PExpireCtx(ctx context.Context, key string, expiration time.Duration) *redis.BoolCmd

func (*GoRedisEX) PExpireTime

func (r *GoRedisEX) PExpireTime(key string) *redis.DurationCmd

func (*GoRedisEX) PExpireTimeCtx

func (r *GoRedisEX) PExpireTimeCtx(ctx context.Context, key string) *redis.DurationCmd

func (*GoRedisEX) PTTL

func (r *GoRedisEX) PTTL(key string) *redis.DurationCmd

func (*GoRedisEX) PTTLCtx

func (r *GoRedisEX) PTTLCtx(ctx context.Context, key string) *redis.DurationCmd

func (*GoRedisEX) Persist

func (r *GoRedisEX) Persist(key string) *redis.BoolCmd

func (*GoRedisEX) PersistCtx

func (r *GoRedisEX) PersistCtx(ctx context.Context, key string) *redis.BoolCmd

func (*GoRedisEX) Pub added in v0.1.13

func (r *GoRedisEX) Pub(channel string, data []byte) *zservice.Error

func (*GoRedisEX) PubCtx added in v0.1.13

func (r *GoRedisEX) PubCtx(ctx *zservice.Context, channel string, data []byte) *zservice.Error

func (*GoRedisEX) Publish added in v0.1.13

func (r *GoRedisEX) Publish(channel string, message any) *redis.IntCmd

func (*GoRedisEX) PublishCtx added in v0.1.13

func (r *GoRedisEX) PublishCtx(ctx context.Context, channel string, message any) *redis.IntCmd

func (*GoRedisEX) RPop

func (r *GoRedisEX) RPop(key string) *redis.StringCmd

func (*GoRedisEX) RPopCount

func (r *GoRedisEX) RPopCount(key string, count int) *redis.StringSliceCmd

func (*GoRedisEX) RPopCountCtx

func (r *GoRedisEX) RPopCountCtx(ctx context.Context, key string, count int) *redis.StringSliceCmd

func (*GoRedisEX) RPopCtx

func (r *GoRedisEX) RPopCtx(ctx context.Context, key string) *redis.StringCmd

func (*GoRedisEX) RPopLPush

func (r *GoRedisEX) RPopLPush(source, destination string) *redis.StringCmd

func (*GoRedisEX) RPopLPushCtx

func (r *GoRedisEX) RPopLPushCtx(ctx context.Context, source, destination string) *redis.StringCmd

func (*GoRedisEX) RPush

func (r *GoRedisEX) RPush(key string, values ...any) *redis.IntCmd

func (*GoRedisEX) RPushCtx

func (r *GoRedisEX) RPushCtx(ctx context.Context, key string, values ...any) *redis.IntCmd

func (*GoRedisEX) RPushX

func (r *GoRedisEX) RPushX(key string, values ...any) *redis.IntCmd

func (*GoRedisEX) RPushXCtx

func (r *GoRedisEX) RPushXCtx(ctx context.Context, key string, values ...any) *redis.IntCmd

func (*GoRedisEX) RandomKey

func (r *GoRedisEX) RandomKey() *redis.StringCmd

func (*GoRedisEX) RandomKeyCtx

func (r *GoRedisEX) RandomKeyCtx(ctx context.Context) *redis.StringCmd

func (*GoRedisEX) Rename

func (r *GoRedisEX) Rename(key, newkey string) *redis.StatusCmd

func (*GoRedisEX) RenameCtx

func (r *GoRedisEX) RenameCtx(ctx context.Context, key, newkey string) *redis.StatusCmd

func (*GoRedisEX) RenameNX

func (r *GoRedisEX) RenameNX(key, newkey string) *redis.BoolCmd

func (*GoRedisEX) RenameNXCtx

func (r *GoRedisEX) RenameNXCtx(ctx context.Context, key, newkey string) *redis.BoolCmd

func (*GoRedisEX) Restore

func (r *GoRedisEX) Restore(key string, ttl time.Duration, value string) *redis.StatusCmd

func (*GoRedisEX) RestoreCtx

func (r *GoRedisEX) RestoreCtx(ctx context.Context, key string, ttl time.Duration, value string) *redis.StatusCmd

func (*GoRedisEX) RestoreReplace

func (r *GoRedisEX) RestoreReplace(key string, ttl time.Duration, value string) *redis.StatusCmd

func (*GoRedisEX) RestoreReplaceCtx

func (r *GoRedisEX) RestoreReplaceCtx(ctx context.Context, key string, ttl time.Duration, value string) *redis.StatusCmd

func (*GoRedisEX) SAdd added in v0.1.8

func (r *GoRedisEX) SAdd(key string, members ...interface{}) *redis.IntCmd

func (*GoRedisEX) SAddCtx added in v0.1.8

func (r *GoRedisEX) SAddCtx(ctx context.Context, key string, members ...interface{}) *redis.IntCmd

func (*GoRedisEX) SCard added in v0.1.8

func (r *GoRedisEX) SCard(key string) *redis.IntCmd

func (*GoRedisEX) SCardCtx added in v0.1.8

func (r *GoRedisEX) SCardCtx(ctx context.Context, key string) *redis.IntCmd

func (*GoRedisEX) SDiff added in v0.1.8

func (r *GoRedisEX) SDiff(keys ...string) *redis.StringSliceCmd

func (*GoRedisEX) SDiffCtx added in v0.1.8

func (r *GoRedisEX) SDiffCtx(ctx context.Context, keys ...string) *redis.StringSliceCmd

func (*GoRedisEX) SDiffStore added in v0.1.8

func (r *GoRedisEX) SDiffStore(destination string, keys ...string) *redis.IntCmd

func (*GoRedisEX) SDiffStoreCtx added in v0.1.8

func (r *GoRedisEX) SDiffStoreCtx(ctx context.Context, destination string, keys ...string) *redis.IntCmd

func (*GoRedisEX) SInter added in v0.1.8

func (r *GoRedisEX) SInter(keys ...string) *redis.StringSliceCmd

func (*GoRedisEX) SInterCtx added in v0.1.8

func (r *GoRedisEX) SInterCtx(ctx context.Context, keys ...string) *redis.StringSliceCmd

func (*GoRedisEX) SInterStore added in v0.1.8

func (r *GoRedisEX) SInterStore(destination string, keys ...string) *redis.IntCmd

func (*GoRedisEX) SInterStoreCtx added in v0.1.8

func (r *GoRedisEX) SInterStoreCtx(ctx context.Context, destination string, keys ...string) *redis.IntCmd

func (*GoRedisEX) SIsMember added in v0.1.8

func (r *GoRedisEX) SIsMember(key string, member interface{}) *redis.BoolCmd

func (*GoRedisEX) SIsMemberCtx added in v0.1.8

func (r *GoRedisEX) SIsMemberCtx(ctx context.Context, key string, member interface{}) *redis.BoolCmd

func (*GoRedisEX) SMIsMember added in v0.1.8

func (r *GoRedisEX) SMIsMember(key string, members ...interface{}) *redis.BoolSliceCmd

func (*GoRedisEX) SMIsMemberCtx added in v0.1.8

func (r *GoRedisEX) SMIsMemberCtx(ctx context.Context, key string, members ...interface{}) *redis.BoolSliceCmd

func (*GoRedisEX) SMembers added in v0.1.8

func (r *GoRedisEX) SMembers(key string) *redis.StringSliceCmd

func (*GoRedisEX) SMembersCtx added in v0.1.8

func (r *GoRedisEX) SMembersCtx(ctx context.Context, key string) *redis.StringSliceCmd

func (*GoRedisEX) SMembersMap added in v0.1.8

func (r *GoRedisEX) SMembersMap(key string) *redis.StringStructMapCmd

func (*GoRedisEX) SMembersMapCtx added in v0.1.8

func (r *GoRedisEX) SMembersMapCtx(ctx context.Context, key string) *redis.StringStructMapCmd

func (*GoRedisEX) SMove added in v0.1.8

func (r *GoRedisEX) SMove(source, destination string, member interface{}) *redis.BoolCmd

func (*GoRedisEX) SMoveCtx added in v0.1.8

func (r *GoRedisEX) SMoveCtx(ctx context.Context, source, destination string, member interface{}) *redis.BoolCmd

func (*GoRedisEX) SPop added in v0.1.8

func (r *GoRedisEX) SPop(key string) *redis.StringCmd

func (*GoRedisEX) SPopCtx added in v0.1.8

func (r *GoRedisEX) SPopCtx(ctx context.Context, key string) *redis.StringCmd

func (*GoRedisEX) SPopN added in v0.1.8

func (r *GoRedisEX) SPopN(key string, count int64) *redis.StringSliceCmd

func (*GoRedisEX) SPopNCtx added in v0.1.8

func (r *GoRedisEX) SPopNCtx(ctx context.Context, key string, count int64) *redis.StringSliceCmd

func (*GoRedisEX) SRandMember added in v0.1.8

func (r *GoRedisEX) SRandMember(key string) *redis.StringCmd

func (*GoRedisEX) SRandMemberCtx added in v0.1.8

func (r *GoRedisEX) SRandMemberCtx(ctx context.Context, key string) *redis.StringCmd

func (*GoRedisEX) SRandMemberN added in v0.1.8

func (r *GoRedisEX) SRandMemberN(key string, count int64) *redis.StringSliceCmd

func (*GoRedisEX) SRandMemberNCtx added in v0.1.8

func (r *GoRedisEX) SRandMemberNCtx(ctx context.Context, key string, count int64) *redis.StringSliceCmd

func (*GoRedisEX) SRem added in v0.1.8

func (r *GoRedisEX) SRem(key string, members ...interface{}) *redis.IntCmd

func (*GoRedisEX) SRemCtx added in v0.1.8

func (r *GoRedisEX) SRemCtx(ctx context.Context, key string, members ...interface{}) *redis.IntCmd

func (*GoRedisEX) SScan added in v0.1.8

func (r *GoRedisEX) SScan(key string, cursor uint64, match string, count int64) *redis.ScanCmd

func (*GoRedisEX) SScanCtx added in v0.1.8

func (r *GoRedisEX) SScanCtx(ctx context.Context, key string, cursor uint64, match string, count int64) *redis.ScanCmd

func (*GoRedisEX) SUnion added in v0.1.8

func (r *GoRedisEX) SUnion(keys ...string) *redis.StringSliceCmd

func (*GoRedisEX) SUnionCtx added in v0.1.8

func (r *GoRedisEX) SUnionCtx(ctx context.Context, keys ...string) *redis.StringSliceCmd

func (*GoRedisEX) Scan

func (r *GoRedisEX) Scan(cursor uint64, match string, count int64) *redis.ScanCmd

注意,返回数据包含 key 前缀

func (*GoRedisEX) ScanCtx

func (r *GoRedisEX) ScanCtx(ctx context.Context, cursor uint64, match string, count int64) *redis.ScanCmd

func (*GoRedisEX) ScanType

func (r *GoRedisEX) ScanType(cursor uint64, match string, count int64, keyType string) *redis.ScanCmd

注意,返回数据包含 key 前缀

func (*GoRedisEX) ScanTypeCtx

func (r *GoRedisEX) ScanTypeCtx(ctx context.Context, cursor uint64, match string, count int64, keyType string) *redis.ScanCmd

func (*GoRedisEX) Set

func (r *GoRedisEX) Set(key string, value string) *redis.StatusCmd

func (*GoRedisEX) SetCtx

func (r *GoRedisEX) SetCtx(ctx context.Context, key string, value string) *redis.StatusCmd

func (*GoRedisEX) SetEX

func (r *GoRedisEX) SetEX(key string, value string, expiration time.Duration) *redis.StatusCmd

func (*GoRedisEX) SetExCtx

func (r *GoRedisEX) SetExCtx(ctx context.Context, key string, value string, expiration time.Duration) *redis.StatusCmd

func (*GoRedisEX) SetNX

func (r *GoRedisEX) SetNX(key string, value string, expiration time.Duration) *redis.BoolCmd

func (*GoRedisEX) SetNXCtx

func (r *GoRedisEX) SetNXCtx(ctx context.Context, key string, value string, expiration time.Duration) *redis.BoolCmd

func (*GoRedisEX) SetScan added in v0.1.8

func (r *GoRedisEX) SetScan(key string, v any) *zservice.Error

将结构体转为json字符串并存储

func (*GoRedisEX) SetScanEX added in v0.1.8

func (r *GoRedisEX) SetScanEX(key string, v any, expiration time.Duration) *zservice.Error

将结构体转为json字符串并存储

func (*GoRedisEX) Sort

func (r *GoRedisEX) Sort(ctx context.Context, key string, sort *redis.Sort) *redis.StringSliceCmd

func (*GoRedisEX) SortCtx

func (r *GoRedisEX) SortCtx(ctx context.Context, key string, sort *redis.Sort) *redis.StringSliceCmd

func (*GoRedisEX) SortInterfaces

func (r *GoRedisEX) SortInterfaces(ctx context.Context, key string, sort *redis.Sort) *redis.SliceCmd

func (*GoRedisEX) SortInterfacesCtx

func (r *GoRedisEX) SortInterfacesCtx(ctx context.Context, key string, sort *redis.Sort) *redis.SliceCmd

func (*GoRedisEX) SortRO

func (r *GoRedisEX) SortRO(ctx context.Context, key string, sort *redis.Sort) *redis.StringSliceCmd

func (*GoRedisEX) SortROCtx

func (r *GoRedisEX) SortROCtx(ctx context.Context, key string, sort *redis.Sort) *redis.StringSliceCmd

func (*GoRedisEX) SortStore

func (r *GoRedisEX) SortStore(ctx context.Context, key, store string, sort *redis.Sort) *redis.IntCmd

func (*GoRedisEX) SortStoreCtx

func (r *GoRedisEX) SortStoreCtx(ctx context.Context, key, store string, sort *redis.Sort) *redis.IntCmd

func (*GoRedisEX) Sub added in v0.1.13

func (r *GoRedisEX) Sub(channel string, cb func(*zservice.Context, string, []byte)) *redis.PubSub

订阅消息,返回取消函数

func (*GoRedisEX) SubCtx added in v0.1.13

func (r *GoRedisEX) SubCtx(ctx *zservice.Context, channel string, cb func(*zservice.Context, string, []byte)) *redis.PubSub

func (*GoRedisEX) TTL

func (r *GoRedisEX) TTL(key string) *redis.DurationCmd

func (*GoRedisEX) TTLCtx

func (r *GoRedisEX) TTLCtx(ctx context.Context, key string) *redis.DurationCmd

func (*GoRedisEX) Touch

func (r *GoRedisEX) Touch(keys ...string) *redis.IntCmd

func (*GoRedisEX) TouchCtx

func (r *GoRedisEX) TouchCtx(ctx context.Context, keys ...string) *redis.IntCmd

func (*GoRedisEX) Type

func (r *GoRedisEX) Type(key string) *redis.StatusCmd

func (*GoRedisEX) TypeCtx

func (r *GoRedisEX) TypeCtx(ctx context.Context, key string) *redis.StatusCmd

type GormEX

type GormEX struct {
	*gorm.DB
}

func NewGormEX

func NewGormEX(opt DBServiceOption) *GormEX

func (*GormEX) IsNotFoundErr

func (ex *GormEX) IsNotFoundErr(e error) bool

type HasTableValueOption

type HasTableValueOption struct {
	Tab      any
	RK       string
	SQLConds []any
}

type LockOrWaitOption added in v0.1.8

type LockOrWaitOption struct {
	RetryCount    uint32        // 重试次数 def:10
	RetryInterval time.Duration // 单次重试间隔 def: 10ms
	Timeout       time.Duration // 上锁超时时间 def: 1s
}

type PubsubBody added in v0.1.13

type PubsubBody struct {
	S2S string `json:"s2s"` // 上下文
	Val []byte `json:"val"` // 内存数据
}

redis 消息订阅发布参数

type SaveTableValueOption added in v0.1.2

type SaveTableValueOption struct {
	Tab any    // 表
	RK  string // 缓存的 Redis
}

Jump to

Keyboard shortcuts

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