Documentation
¶
Index ¶
- type ExpiringCache
- func (c *ExpiringCache) Clear()
- func (c *ExpiringCache) Close()
- func (c *ExpiringCache) Delete(key string)
- func (c *ExpiringCache) Get(key string) (interface{}, bool)
- func (c *ExpiringCache) Set(key string, value interface{})
- func (c *ExpiringCache) SetWithTTL(key string, value interface{}, ttl time.Duration)
- func (c *ExpiringCache) Size() int
- type Option
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ExpiringCache ¶ added in v1.5.0
type ExpiringCache struct {
// contains filtered or unexported fields
}
缓存结构体
func DefaultCache ¶ added in v1.5.0
func DefaultCache() *ExpiringCache
func (*ExpiringCache) Get ¶ added in v1.5.0
func (c *ExpiringCache) Get(key string) (interface{}, bool)
获取缓存项
func (*ExpiringCache) Set ¶ added in v1.5.0
func (c *ExpiringCache) Set(key string, value interface{})
设置缓存项,使用默认过期时间
func (*ExpiringCache) SetWithTTL ¶ added in v1.5.0
func (c *ExpiringCache) SetWithTTL(key string, value interface{}, ttl time.Duration)
设置缓存项,指定过期时间
type Option ¶ added in v1.5.0
type Option func(*ExpiringCache)
选项函数,用于配置缓存
func WithCleanupInterval ¶ added in v1.5.0
WithCleanupInterval 设置清理间隔
func WithEvictionCallback ¶ added in v1.5.0
WithEvictionCallback 设置淘汰回调函数
func WithMaxSize ¶ added in v1.5.0
WithMaxSize 设置最大缓存大小,用于LRU淘汰
Click to show internal directories.
Click to hide internal directories.