Files
EdgeNode/internal/caches/storage_interface.go

62 lines
1.6 KiB
Go
Raw Permalink Normal View History

2020-10-04 14:30:42 +08:00
package caches
2020-10-05 16:55:14 +08:00
import (
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs"
)
2020-10-04 14:30:42 +08:00
// StorageInterface 缓存存储接口
2020-10-04 14:30:42 +08:00
type StorageInterface interface {
// Init 初始化
2020-10-04 14:30:42 +08:00
Init() error
// OpenReader 读取缓存
OpenReader(key string, useStale bool, isPartial bool) (reader Reader, err error)
2020-10-04 14:30:42 +08:00
// OpenWriter 打开缓存写入器等待写入
// size 和 maxSize 可能为-1
2022-11-19 17:23:45 +08:00
OpenWriter(key string, expiresAt int64, status int, headerSize int, bodySize int64, maxSize int64, isPartial bool) (Writer, error)
2022-04-14 09:36:02 +08:00
// OpenFlushWriter 打开从其他媒介直接刷入的写入器
2022-11-19 17:23:45 +08:00
OpenFlushWriter(key string, expiresAt int64, status int, headerSize int, bodySize int64) (Writer, error)
2020-10-04 14:30:42 +08:00
// Delete 删除某个键值对应的缓存
2020-10-04 14:30:42 +08:00
Delete(key string) error
// Stat 统计缓存
2020-10-04 14:30:42 +08:00
Stat() (*Stat, error)
// TotalDiskSize 消耗的磁盘尺寸
TotalDiskSize() int64
// TotalMemorySize 内存尺寸
TotalMemorySize() int64
// CleanAll 清除所有缓存
2020-10-04 14:30:42 +08:00
CleanAll() error
// Purge 批量删除缓存
// urlType 值为file|dir
2020-12-23 21:28:50 +08:00
Purge(keys []string, urlType string) error
2020-10-04 14:30:42 +08:00
// Stop 停止缓存策略
2020-10-04 14:30:42 +08:00
Stop()
// Policy 获取当前存储的Policy
2020-10-04 14:30:42 +08:00
Policy() *serverconfigs.HTTPCachePolicy
2020-10-05 16:55:14 +08:00
// UpdatePolicy 修改策略
UpdatePolicy(newPolicy *serverconfigs.HTTPCachePolicy)
// CanUpdatePolicy 检查策略是否可以更新
CanUpdatePolicy(newPolicy *serverconfigs.HTTPCachePolicy) bool
// AddToList 将缓存添加到列表
2020-10-05 16:55:14 +08:00
AddToList(item *Item)
// IgnoreKey 忽略某个Key即不缓存某个Key
IgnoreKey(key string, maxSize int64)
2022-04-04 19:45:57 +08:00
// CanSendfile 是否支持Sendfile
CanSendfile() bool
2020-10-04 14:30:42 +08:00
}