mirror of
https://github.com/TeaOSLab/EdgeNode.git
synced 2025-11-03 23:20:25 +08:00
45 lines
847 B
Go
45 lines
847 B
Go
// Copyright 2021 Liuxiangchao iwind.liu@gmail.com. All rights reserved.
|
|
|
|
package caches
|
|
|
|
type ListInterface interface {
|
|
// Init 初始化
|
|
Init() error
|
|
|
|
// Reset 重置数据
|
|
Reset() error
|
|
|
|
// Add 添加内容
|
|
Add(hash string, item *Item) error
|
|
|
|
// Exist 检查内容是否存在
|
|
Exist(hash string) (bool, error)
|
|
|
|
// CleanPrefix 清除某个前缀的缓存
|
|
CleanPrefix(prefix string) error
|
|
|
|
// Remove 删除内容
|
|
Remove(hash string) error
|
|
|
|
// Purge 清理过期数据
|
|
Purge(count int, callback func(hash string) error) error
|
|
|
|
// CleanAll 清除所有缓存
|
|
CleanAll() error
|
|
|
|
// Stat 统计
|
|
Stat(check func(hash string) bool) (*Stat, error)
|
|
|
|
// Count 总数量
|
|
Count() (int64, error)
|
|
|
|
// OnAdd 添加事件
|
|
OnAdd(f func(item *Item))
|
|
|
|
// OnRemove 删除事件
|
|
OnRemove(f func(item *Item))
|
|
|
|
// Close 关闭
|
|
Close() error
|
|
}
|