Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrKeyExpired = errors.New("key expired") ErrKeyNotExist = errors.New("key not exist") )
Functions ¶
This section is empty.
Types ¶
type Cache ¶
type Cache interface {
IsExist(key string) bool
Get(key string) (string, error)
Put(key string, value string, expiration time.Duration) error
Delete(key string) error
BatchDelete(prefix string) error
}
Cache 缓存接口
func NewMemoryCache ¶
func NewMemoryCache() Cache
func NewRedisWithClient ¶
func NewRedisWithClient(redisClient redis.UniversalClient, keyPrefix string) Cache
NewRedisWithClient 使用redis连接创建缓存实例
type MemoryCache ¶
type MemoryCache struct {
// contains filtered or unexported fields
}
MemoryCache 内存缓存
func (*MemoryCache) BatchDelete ¶
func (c *MemoryCache) BatchDelete(prefix string) error
BatchDelete 批量删除
Click to show internal directories.
Click to hide internal directories.