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 ¶
type ExpiringCache struct {
// contains filtered or unexported fields
}
缓存结构体
func DefaultCache ¶
func DefaultCache() *ExpiringCache
func (*ExpiringCache) Set ¶
func (c *ExpiringCache) Set(key string, value interface{})
设置缓存项,使用默认过期时间
func (*ExpiringCache) SetWithTTL ¶
func (c *ExpiringCache) SetWithTTL(key string, value interface{}, ttl time.Duration)
设置缓存项,指定过期时间
type Option ¶
type Option func(*ExpiringCache)
选项函数,用于配置缓存
func WithCleanupInterval ¶
WithCleanupInterval 设置清理间隔
func WithEvictionCallback ¶
WithEvictionCallback 设置淘汰回调函数
Click to show internal directories.
Click to hide internal directories.