Documentation ¶
Index ¶
Constants ¶
View Source
const ( CacheTypeMem = "mem" CacheTypeRedis = "redis" )
Variables ¶
This section is empty.
Functions ¶
func InitRedis ¶
func InitRedis(c *ConfigRedis) error
Types ¶
type CacheRedis ¶
type CacheRedis struct {
// contains filtered or unexported fields
}
func (*CacheRedis) Close ¶
func (c *CacheRedis) Close() error
func (*CacheRedis) Ping ¶
func (c *CacheRedis) Ping() (string, error)
type ConfigRedis ¶
type ICache ¶
type ICache interface { Set(key string, val interface{}, expiration time.Duration) error Get(key string) (string, error) GetBytes(key string) ([]byte, error) // 获取缓存的 bytes // GetKey() string // 生成key值 Ping() (string, error) Close() error // 关闭连接 }
抽象 cache 类
func NewMemCache ¶
func NewMemCache() ICache
func NewRedisCache ¶
func NewRedisCache(c *ConfigRedis) (ICache, error)
Click to show internal directories.
Click to hide internal directories.