Documentation ¶
Index ¶
- Constants
- func MustParseKeyDuration(s string) time.Duration
- func ParseKeyDuration(s string) (time.Duration, error)
- func RdKey(format string, id ...interface{}) string
- func Uint64ToStringRdKeys(format string, ids []uint64) []string
- type Client
- func (c *Client) DelValues(ctx context.Context, keys ...string) error
- func (c *Client) DistrbLock(ctx context.Context, lockKey string, ttl time.Duration) error
- func (c *Client) DistrbUnLock(ctx context.Context, busKey string) error
- func (c *Client) GetClient() *redis.Client
- func (c *Client) GetString(ctx context.Context, format string, injects ...interface{}) (string, error)
- func (c *Client) PipeRead(ctx context.Context, keys []string) (map[string]string, error)
- func (c *Client) PipeWrite(ctx context.Context, objs []interface{}, kfn KeyFunc, ttl time.Duration) error
- type ICurrencyLocker
- type IRedisHand
- type KeyFunc
Constants ¶
View Source
const (
// TTLForever 没有过期时间
TTLForever = 0
)
Variables ¶
This section is empty.
Functions ¶
func MustParseKeyDuration ¶
MustParseKeyDuration get redis key time expire, if parse got err, expire time return 0
func ParseKeyDuration ¶
ParseKeyDuration get redis key time from string
func Uint64ToStringRdKeys ¶
Uint64ToStringRdKeys []uint64 to []string
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client RedisCache
func (*Client) DistrbLock ¶
DistrbLock 通过Redis增加分布式记录锁设计,防止业务操作短时并发
func (*Client) DistrbUnLock ¶
DistrbUnLock 分布式解锁操作
func (*Client) GetClient ¶
func (c *Client) GetClient() *redis.Client
GetClient get client from Client obj
func (*Client) GetString ¶
func (c *Client) GetString(ctx context.Context, format string, injects ...interface{}) (string, error)
GetString 获取缓存的字符串值,若没有找返回空,若redis失败返回redis操作错误,其他情况正常返回
type ICurrencyLocker ¶
type ICurrencyLocker interface { DistrbLock(ctx context.Context, lockKey string, ttl time.Duration) error DistrbUnLock(ctx context.Context, busKey string) error }
ICurrencyLocker 分布式并发锁接口,支持通过业务操作唯一Key进行短时间锁定
type IRedisHand ¶
type IRedisHand interface { // GetClient 获取实例 GetClient() *redis.Client // PipeWrite 管道写 PipeWrite(ctx context.Context, objs []interface{}, kfn KeyFunc, ttl time.Duration) error // PipeRead 管道读取 PipeRead(ctx context.Context, keys []string) (map[string]string, error) // GetString 按格式获取 GetString(ctx context.Context, keyFormat string, injects ...interface{}) (string, error) // DelValues 通过key批量删除值 DelValues(ctx context.Context, keys ...string) error }
IRedisHand redis interface
Click to show internal directories.
Click to hide internal directories.