Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type FirstSeenCache ¶
type FirstSeenCache struct {
// contains filtered or unexported fields
}
FirstSeenCache 是一个时间缓存,仅在消息首次添加时标记其过期时间。
func (*FirstSeenCache) Add ¶
func (tc *FirstSeenCache) Add(s string) bool
Add 将消息添加到缓存中 参数: - s: 消息字符串 返回值: - bool: 是否成功添加消息
func (*FirstSeenCache) Has ¶
func (tc *FirstSeenCache) Has(s string) bool
Has 检查消息是否存在于缓存中 参数: - s: 消息字符串 返回值: - bool: 消息是否存在
type LastSeenCache ¶
type LastSeenCache struct {
// contains filtered or unexported fields
}
LastSeenCache 是一个时间缓存,在添加或检查消息存在时,延长其过期时间。
func (*LastSeenCache) Add ¶
func (tc *LastSeenCache) Add(s string) bool
Add 将消息添加到缓存中,并延长其过期时间。 参数: - s: 消息字符串 返回值: - bool: 是否成功添加消息(如果消息已存在,返回 false)
func (*LastSeenCache) Has ¶
func (tc *LastSeenCache) Has(s string) bool
Has 检查消息是否存在于缓存中,并延长其过期时间。 参数: - s: 消息字符串 返回值: - bool: 消息是否存在
type TimeCache ¶
type TimeCache interface {
// Add 将 id 添加到缓存中,如果该 id 不存在
// 如果 id 是新添加的,返回 true
// 根据实现策略,可能会或不会更新现有条目的过期时间
Add(string) bool
// Has 检查缓存中是否存在 id
// 根据实现策略,可能会或不会更新现有条目的过期时间
Has(string) bool
// Done 表示用户不再使用此缓存,可以停止后台线程并释放资源
Done()
}
TimeCache 是一个最近看到的消息(通过 id)的缓存接口
func NewTimeCache ¶
NewTimeCache 创建一个默认的 ("first seen") 缓存实现 参数: - ttl: 条目的存活时间 返回值: - TimeCache: 一个实现了 TimeCache 接口的缓存实例
Click to show internal directories.
Click to hide internal directories.