Documentation
¶
Index ¶
- Variables
- func AutoDelete[T any](key string, context ...redis.Cmdable) (int64, error)
- func AutoGet[T any](key string, context ...redis.Cmdable) (*T, error)
- func AutoGetWithGetter[T any](key string, getter func() (*T, error), context ...redis.Cmdable) (*T, error)
- func AutoSet[T any](key string, value T, context ...redis.Cmdable) error
- func Close() error
- func Decrease(key string, context ...redis.Cmdable) (int64, error)
- func Del(key string, context ...redis.Cmdable) (int64, error)
- func DelMapField(key string, field string, context ...redis.Cmdable) error
- func Exist(key string, context ...redis.Cmdable) (int64, error)
- func Expire(key string, time time.Duration, context ...redis.Cmdable) (bool, error)
- func Get[T any](key string, context ...redis.Cmdable) (*T, error)
- func GetMap[V any](key string, context ...redis.Cmdable) (map[string]V, error)
- func GetMapField[T any](key string, field string, context ...redis.Cmdable) (*T, error)
- func GetMapFieldString(key string, field string, context ...redis.Cmdable) (string, error)
- func GetString(key string, context ...redis.Cmdable) (string, error)
- func Increase(key string, context ...redis.Cmdable) (int64, error)
- func InitRedisClient(addr, username, password string, useSsl bool, db int) error
- func InitRedisSentinelClient(sentinels []string, ...) error
- func Lock(key string, expire time.Duration, tryLockTimeout time.Duration, ...) error
- func Publish(channel string, message any, context ...redis.Cmdable) error
- func ScanKeys(match string, context ...redis.Cmdable) ([]string, error)
- func ScanKeysAsync(match string, fn func([]string) error, context ...redis.Cmdable) error
- func ScanMap[V any](key string, match string, context ...redis.Cmdable) (map[string]V, error)
- func ScanMapAsync[V any](key string, match string, fn func(map[string]V) error, ...) error
- func SetExpire(key string, time time.Duration, context ...redis.Cmdable) error
- func SetMapField(key string, v map[string]any, context ...redis.Cmdable) error
- func SetMapOneField(key string, field string, value any, context ...redis.Cmdable) error
- func SetNX[T any](key string, value T, expire time.Duration, context ...redis.Cmdable) (bool, error)
- func Store(key string, value any, time time.Duration, context ...redis.Cmdable) error
- func Subscribe[T any](channel string) (<-chan T, func())
- func Transaction(fn func(redis.Pipeliner) error) error
- func Unlock(key string, context ...redis.Cmdable) error
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrDBNotInit = errors.New("redis client not init") ErrNotFound = errors.New("key not found") )
View Source
var (
ErrLockTimeout = errors.New("lock timeout")
)
Functions ¶
func AutoDelete ¶
Delete the value with key
func AutoGetWithGetter ¶
func AutoGetWithGetter[T any](key string, getter func() (*T, error), context ...redis.Cmdable) (*T, error)
Get the value with key, fallback to getter if not found, and set the value to cache
func DelMapField ¶
DelMapField delete the map field with key
func GetMapField ¶
GetMapField get the map field with key
func GetMapFieldString ¶
GetMapFieldString get the string
func InitRedisClient ¶
func InitRedisSentinelClient ¶
func Lock ¶
func Lock(key string, expire time.Duration, tryLockTimeout time.Duration, context ...redis.Cmdable) error
Lock key, expire time takes responsibility for expiration time try_lock_timeout takes responsibility for the timeout of trying to lock
func ScanKeysAsync ¶
ScanKeysAsync scan the keys with match pattern, format like "key*"
func ScanMapAsync ¶
func ScanMapAsync[V any](key string, match string, fn func(map[string]V) error, context ...redis.Cmdable) error
ScanMapAsync scan the map with match pattern, format like "key*"
func SetMapField ¶
SetMapField set the map field with key
func SetMapOneField ¶
SetMapOneField set the map field with key
func SetNX ¶
func SetNX[T any](key string, value T, expire time.Duration, context ...redis.Cmdable) (bool, error)
SetNX set the key-value pair with expire time
func Transaction ¶
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.