hash_helper

package
v1.0.17 Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2025 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultTag          = "redis"
	DefaultTagHashKey   = "redis_hash_key"
	DefaultTagHashField = "redis_hash_field"
)

Variables

View Source
var (
	ErrorNoTagFound                = errors.New("no tag found")
	ErrorCacheDataIsNil            = errors.New("CacheData is nil")
	ErrorCacheDataIsEmpty          = errors.New("CacheData is empty")
	ErrorCacheDataIsError          = errors.New("CacheData is error")
	ErrorCacheDataExistedEmptyData = errors.New("CacheData existed empty data")
)

Functions

This section is empty.

Types

type HashHelper

type HashHelper struct {
	*base.Base
}

HashHelper Redis Hash类型助手类

func NewHashHelper

func NewHashHelper(b *base.Base) *HashHelper

NewHashHelper 实例化

func (HashHelper) HDel

func (s HashHelper) HDel(key, field string) (v *gvar.Var, err error)

HDel 删除一个或多个哈希表字段

func (HashHelper) HDelM

func (s HashHelper) HDelM(key string, fields []string) (v *gvar.Var, err error)

func (HashHelper) HDelOnlyError

func (s HashHelper) HDelOnlyError(key, field string) (err error)

func (HashHelper) HExists

func (s HashHelper) HExists(key, field string) (v *gvar.Var, err error)

HExists 查看哈希表 key 中,指定的字段是否存在。

func (HashHelper) HExistsBool added in v1.0.17

func (s HashHelper) HExistsBool(key, field string) (b bool, err error)

func (HashHelper) HExistsNoError

func (s HashHelper) HExistsNoError(key, field string) (v *gvar.Var)

func (HashHelper) HGet

func (s HashHelper) HGet(key, field string) (v *gvar.Var, err error)

HGet 获取存储在哈希表中指定字段的值。

func (HashHelper) HGetAll added in v1.0.17

func (s HashHelper) HGetAll(key string) (v *gvar.Var, err error)

HGetAll 获取在哈希表中指定 key 的所有字段和值

func (HashHelper) HIncrby

func (s HashHelper) HIncrby(key string, field string, increment int64) (v *gvar.Var, err error)

HIncrby 为哈希表 key 中的指定字段的整数值加上增量 increment 。

func (HashHelper) HIncrbyFloat added in v1.0.17

func (s HashHelper) HIncrbyFloat(key string, field string, increment float64) (v *gvar.Var, err error)

HIncrbyFloat 为哈希表 key 中的指定字段的浮点数值加上增量 increment 。

func (HashHelper) HKeys added in v1.0.17

func (s HashHelper) HKeys(key string) (v *gvar.Var, err error)

HKeys 获取所有哈希表中的字段

func (HashHelper) HLen added in v1.0.17

func (s HashHelper) HLen(key string) (v *gvar.Var, err error)

HLen 获取哈希表中字段的数量

func (HashHelper) HMGet

func (s HashHelper) HMGet(key string, fields []string) (v *gvar.Var, err error)

HMGet 获取所有给定字段的值

func (HashHelper) HMSet

func (s HashHelper) HMSet(key string, fv g.Map) (v *gvar.Var, err error)

HMSet 同时将多个 field-value (域-值)对设置到哈希表 key 中。

func (HashHelper) HScan

func (s HashHelper) HScan(key string, field string, callback func(key string, fieldVals g.MapStrStr) error, count ...int) (err error)

HScan 迭代哈希表中的键值对。批量获取field 【注意】field里需要有通配符 比如:a:*

func (HashHelper) HSet

func (s HashHelper) HSet(key, field string, value interface{}) (v *gvar.Var, err error)

HSet 将哈希表 key 中的字段 field 的值设为 value 。

func (HashHelper) HSetNx

func (s HashHelper) HSetNx(key, field string, value interface{}) (v *gvar.Var, err error)

HSetNx 只有在字段 field 不存在时,设置哈希表字段的值。

func (HashHelper) HVals added in v1.0.17

func (s HashHelper) HVals(key string) (v *gvar.Var, err error)

HVals 获取哈希表中所有值

type HashMapIUDHelper added in v1.0.9

type HashMapIUDHelper struct {
	*base.Base
	// contains filtered or unexported fields
}

func NewHashMapIUDHelper added in v1.0.9

func NewHashMapIUDHelper(b *base.Base) *HashMapIUDHelper

func (*HashMapIUDHelper) IUD added in v1.0.9

func (s *HashMapIUDHelper) IUD(key string, fv g.Map, matchPattern ...string) (err error)

IUD 插入更新删除

func (*HashMapIUDHelper) IUDScript added in v1.0.10

func (s *HashMapIUDHelper) IUDScript(key string, fv g.Map) (err error)

IUDScript 插入更新删除

type HashStructHelper

type HashStructHelper[T any] struct {
	*base.Base
	// contains filtered or unexported fields
}

func NewHashStructHelper

func NewHashStructHelper[T any](b *base.Base) *HashStructHelper[T]

func (*HashStructHelper[T]) Get

func (s *HashStructHelper[T]) Get(key string) (data *T, err error)

Get 获取数据到结构体 For example:

type User struct {
    Name string `redis_hash_field:"name"`
    Age  int    `redis_hash_field:"age"`
}

func (*HashStructHelper[T]) Set

func (s *HashStructHelper[T]) Set(key string, data *T) (err error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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