Documentation ¶
Index ¶
- Variables
- func Init(addr string)
- func IsRedisNil(err error) bool
- type Cache
- func (cli *Cache) BatchGet(ctx context.Context, shotLimit int, keys ...string) (valuesHit []string, keysMiss []string, err error)
- func (cli *Cache) BatchSave(ctx context.Context, forEachReceiver func(fn func(key, v string) error) error, ...) error
- func (cli *Cache) PipeGet(ctx context.Context, keys ...string) (valuesHit []string, keysMiss []string, err error)
- func (cli *Cache) SingleFlightAPI() SingleFlight
- type H
- type Prefix
- func (p Prefix) AssembleCMD(cmd redis.Cmder) redis.Cmder
- func (p Prefix) ColonStr() string
- func (p Prefix) DialHook(next redis.DialHook) redis.DialHook
- func (p Prefix) MakeKey(key string) string
- func (p Prefix) ProcessHook(next redis.ProcessHook) redis.ProcessHook
- func (p Prefix) ProcessPipelineHook(next redis.ProcessPipelineHook) redis.ProcessPipelineHook
- func (p Prefix) String() string
- type SingleFlight
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrShotLimits = errors.New("error shot limits") ErrTypeError = errors.New("wrong type") )
View Source
var ( MaxRetries = 3 DialTimeout = 100 * time.Millisecond ReadWriteTimeout = 100 * time.Millisecond PoolSize = 200 PoolTimeout = 100 * time.Millisecond IdleTimeout = 60 * time.Minute )
Functions ¶
func IsRedisNil ¶
Types ¶
type Cache ¶
type Cache struct {
*redis.Client
}
func NewClientByRedisCli ¶
func NewClientByRedisCli(cli *redis.Client) *Cache
func NewPrefixedCli ¶
func (*Cache) BatchSave ¶
func (cli *Cache) BatchSave(ctx context.Context, forEachReceiver func(fn func(key, v string) error) error, expiration time.Duration) error
BatchSave save data to redis in batch
func (*Cache) PipeGet ¶
func (cli *Cache) PipeGet(ctx context.Context, keys ...string) (valuesHit []string, keysMiss []string, err error)
PipeGet get values from redis by pipeline
func (*Cache) SingleFlightAPI ¶
func (cli *Cache) SingleFlightAPI() SingleFlight
SingleFlightAPI
usage: ```go sf := cli.SingleFlightAPI() for _, k := range keys { go ... sf.Get(ctx, k) ... } ```
type Prefix ¶
type Prefix string
func (Prefix) AssembleCMD ¶
func (p Prefix) AssembleCMD(cmd redis.Cmder) redis.Cmder
func (Prefix) ProcessHook ¶
func (p Prefix) ProcessHook(next redis.ProcessHook) redis.ProcessHook
func (Prefix) ProcessPipelineHook ¶
func (p Prefix) ProcessPipelineHook(next redis.ProcessPipelineHook) redis.ProcessPipelineHook
type SingleFlight ¶
type SingleFlight struct { *Cache // contains filtered or unexported fields }
func SingleFlightAPI ¶
func SingleFlightAPI() SingleFlight
Click to show internal directories.
Click to hide internal directories.