Files
EdgeNode/internal/caches/list.go

34 lines
647 B
Go
Raw Normal View History

2021-05-19 12:07:35 +08:00
// Copyright 2021 Liuxiangchao iwind.liu@gmail.com. All rights reserved.
2020-10-04 14:30:42 +08:00
2021-05-19 12:07:35 +08:00
package caches
2020-10-04 14:30:42 +08:00
2021-05-19 12:07:35 +08:00
type ListInterface interface {
Init() error
2020-12-23 21:28:50 +08:00
2021-05-19 12:07:35 +08:00
Reset() error
2020-12-23 21:28:50 +08:00
2021-05-19 12:07:35 +08:00
Add(hash string, item *Item) error
2020-10-05 20:23:18 +08:00
2021-05-19 12:07:35 +08:00
Exist(hash string) (bool, error)
2020-10-05 20:23:18 +08:00
2021-05-19 12:07:35 +08:00
// FindKeysWithPrefix 根据前缀进行查找
FindKeysWithPrefix(prefix string) (keys []string, err error)
2020-10-04 14:30:42 +08:00
2021-05-19 12:07:35 +08:00
Remove(hash string) error
2020-10-04 14:30:42 +08:00
2021-05-19 12:07:35 +08:00
Purge(count int, callback func(hash string) error) error
2020-10-04 14:30:42 +08:00
2021-05-19 12:07:35 +08:00
CleanAll() error
2020-10-04 14:30:42 +08:00
2021-05-19 12:07:35 +08:00
Stat(check func(hash string) bool) (*Stat, error)
2020-10-04 14:30:42 +08:00
2021-05-19 12:07:35 +08:00
// Count 总数量
Count() (int64, error)
2020-10-04 14:30:42 +08:00
2021-05-19 12:07:35 +08:00
// OnAdd 添加事件
OnAdd(f func(item *Item))
2020-10-05 20:23:18 +08:00
2021-05-19 12:07:35 +08:00
// OnRemove 删除事件
OnRemove(f func(item *Item))
2020-10-05 20:23:18 +08:00
}