 Documentation
      ¶
      Documentation
      ¶
    
    
  
    
  
    Index ¶
- func DeleteContext(ctx context.Context, cache Cache, key string) error
- func GetContext(ctx context.Context, cache Cache, key string) interface{}
- func IsExistContext(ctx context.Context, cache Cache, key string) bool
- func SetContext(ctx context.Context, cache Cache, key string, val interface{}, ...) error
- type Cache
- type ContextCache
- type Memcache
- type Memory
- type Redis
- func (r *Redis) Delete(key string) error
- func (r *Redis) DeleteContext(ctx context.Context, key string) error
- func (r *Redis) Get(key string) interface{}
- func (r *Redis) GetContext(ctx context.Context, key string) interface{}
- func (r *Redis) IsExist(key string) bool
- func (r *Redis) IsExistContext(ctx context.Context, key string) bool
- func (r *Redis) Set(key string, val interface{}, timeout time.Duration) error
- func (r *Redis) SetConn(conn redis.UniversalClient)
- func (r *Redis) SetContext(ctx context.Context, key string, val interface{}, timeout time.Duration) error
- func (r *Redis) SetRedisCtx(ctx context.Context)
 
- type RedisOpts
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DeleteContext ¶ added in v2.1.5
DeleteContext delete value in cache.
func GetContext ¶ added in v2.1.5
GetContext get value from cache
func IsExistContext ¶ added in v2.1.5
IsExistContext check value exists in cache.
Types ¶
type Cache ¶
type Cache interface {
	Get(key string) interface{}
	Set(key string, val interface{}, timeout time.Duration) error
	IsExist(key string) bool
	Delete(key string) error
}
    Cache interface
type ContextCache ¶ added in v2.1.5
type ContextCache interface {
	Cache
	GetContext(ctx context.Context, key string) interface{}
	SetContext(ctx context.Context, key string, val interface{}, timeout time.Duration) error
	IsExistContext(ctx context.Context, key string) bool
	DeleteContext(ctx context.Context, key string) error
}
    ContextCache interface
type Memcache ¶
type Memcache struct {
	// contains filtered or unexported fields
}
    Memcache struct contains *memcache.Client
type Memory ¶
Memory struct contains *memcache.Client
type Redis ¶
type Redis struct {
	// contains filtered or unexported fields
}
    Redis .redis cache
func (*Redis) DeleteContext ¶ added in v2.1.5
DeleteContext 删除
func (*Redis) GetContext ¶ added in v2.1.5
GetContext 获取一个值
func (*Redis) IsExistContext ¶ added in v2.1.5
IsExistContext 判断key是否存在
func (*Redis) SetContext ¶ added in v2.1.5
func (r *Redis) SetContext(ctx context.Context, key string, val interface{}, timeout time.Duration) error
SetContext 设置一个值
func (*Redis) SetRedisCtx ¶ added in v2.1.3
SetRedisCtx 设置redis ctx 参数
type RedisOpts ¶
type RedisOpts struct {
	Host        string `json:"host"         yml:"host"`
	Username    string `json:"username"                        yaml:"username"`
	Password    string `json:"password"     yml:"password"`
	Database    int    `json:"database"     yml:"database"`
	MaxIdle     int    `json:"max_idle"     yml:"max_idle"`
	MaxActive   int    `json:"max_active"   yml:"max_active"`
	IdleTimeout int    `json:"idle_timeout" yml:"idle_timeout"` // second
	UseTLS      bool   `json:"use_tls"      yml:"use_tls"`      // 是否使用TLS
}
    RedisOpts redis 连接属性
 Click to show internal directories. 
   Click to hide internal directories.