Documentation
¶
Index ¶
- func Get(ctx context.Context, key RedisKey) (string, error)
- func GetAny(ctx context.Context, key RedisKey, object any) error
- func GetAnyWithJson(ctx context.Context, key RedisKey, object any) error
- func GetBytes(ctx context.Context, key RedisKey) ([]byte, error)
- func LockWithDeadline(ctx context.Context, key string, lockTtl time.Duration, ...) error
- func LockWithMaxRetry(ctx context.Context, key string, lockTtl time.Duration, ...) error
- func MGet(ctx context.Context, keys ...RedisKey) ([]string, error)
- func MGetAny(ctx context.Context, object any, keys ...RedisKey) error
- func MSet(ctx context.Context, data map[RedisKey]string) error
- func MSetBytes(ctx context.Context, data map[RedisKey][]byte) error
- func RawClient() redis.UniversalClient
- func RawLockClient() *redislock.Client
- func Set(ctx context.Context, key RedisKey, value string, expiration ...time.Duration) error
- func SetAny(ctx context.Context, key RedisKey, value interface{}, ...) error
- func SetAnyWithJson(ctx context.Context, key RedisKey, value any, expiration ...time.Duration) error
- func SetBytes(ctx context.Context, key RedisKey, value []byte, expiration ...time.Duration) error
- func TryLock(key string, lockTtl time.Duration, executable func()) error
- func TryLockWithContext(ctx context.Context, key string, lockTtl time.Duration, executable func()) error
- type RedisKey
- type RedisModule
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func LockWithDeadline ¶
func LockWithDeadline(ctx context.Context, key string, lockTtl time.Duration, retryDeadline time.Time, retryInterval int, executable func()) error
LockWithDeadline 持续尝试获取锁 request lockTtl 获得锁之后的持续时长(超时自动释放)
retryDeadline 重试持续时间 retryInterval 重试间隔(millisecond)
func LockWithMaxRetry ¶
func LockWithMaxRetry(ctx context.Context, key string, lockTtl time.Duration, retryMax, retryInterval int, executable func()) error
LockWithMaxRetry 持续尝试获取锁 request lockTtl 获得锁之后的持续时长(超时自动释放)
retryMax 尝试获取锁最大重试次数 intervalMil 重试间隔(millisecond)
func RawLockClient ¶
func SetAny ¶
func SetAny(ctx context.Context, key RedisKey, value interface{}, expiration ...time.Duration) error
SetAny 原始RedisClient Set指令 适用于设置基本类型&实现BinaryMarshaler的复杂结构体
func SetAnyWithJson ¶
func SetAnyWithJson(ctx context.Context, key RedisKey, value any, expiration ...time.Duration) error
SetAnyWithJson 设置其他类型值 设置任何类型,将被以json格式进行编码存储
Types ¶
type RedisModule ¶
type RedisModule struct {
RedisConfig *redis.UniversalOptions
RedisModuleConfig *declaration.ModuleConfig
// instance *redis.Client
RedisInterceptor func(instance interface{})
}
func (*RedisModule) ModuleConfig ¶
func (r *RedisModule) ModuleConfig() *declaration.ModuleConfig
func (*RedisModule) Register ¶
func (r *RedisModule) Register() (interface{}, error)
func (*RedisModule) Unregister ¶
func (r *RedisModule) Unregister(maxWaitSeconds uint) (gracefully bool, err error)
Click to show internal directories.
Click to hide internal directories.