Documentation ¶
Overview ¶
yeeCache 文件缓存类
yeeCache 内存缓存类
Index ¶
- Constants
- func FileTtlCache(fileName string, f func() (b []byte, ttl time.Duration, err error)) (b []byte, err error)
- type Item
- type KV
- type MemoryCache
- func (c MemoryCache) Add(k string, v interface{}, d time.Duration) error
- func (c MemoryCache) Delete(k string)
- func (c MemoryCache) DeleteExpired()
- func (c MemoryCache) Flush()
- func (c MemoryCache) Get(k string) (interface{}, bool)
- func (c MemoryCache) ItemCount() int
- func (c MemoryCache) Items() map[string]Item
- func (c MemoryCache) Replace(k string, v interface{}, d time.Duration) error
- func (c MemoryCache) Set(k string, v interface{}, d time.Duration)
- func (c MemoryCache) SetDefault(k string, v interface{})
Constants ¶
View Source
const ( DefaultExpiration time.Duration = 0 NoExpiration time.Duration = -1 )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type MemoryCache ¶
type MemoryCache struct {
// contains filtered or unexported fields
}
MemoryCache 内存缓存
func NewMemoryCache ¶
func NewMemoryCache(defaultExpiration, cleanupInterval time.Duration) *MemoryCache
NewMemoryCache 初始化内存缓存
func NewMemoryCacheWithMap ¶
func NewMemoryCacheWithMap(defaultExpiration, cleanupInterval time.Duration, items map[string]Item) *MemoryCache
NewMemoryCache 初始化内存缓存 可以传入map数据
func (MemoryCache) ItemCount ¶
func (c MemoryCache) ItemCount() int
ItemCount 获取已缓存的数量 其中包含了那些已经过期但是没有被清理的
func (MemoryCache) SetDefault ¶
func (c MemoryCache) SetDefault(k string, v interface{})
SetDefault 默认过期时间
Click to show internal directories.
Click to hide internal directories.