Files
EdgeNode/internal/caches/item.go

32 lines
513 B
Go
Raw Normal View History

2020-10-04 14:30:42 +08:00
package caches
import "time"
type ItemType = int
const (
ItemTypeFile ItemType = 1
ItemTypeMemory ItemType = 2
)
2020-10-04 14:30:42 +08:00
type Item struct {
Type ItemType
2021-01-13 12:02:50 +08:00
Key string
ExpiredAt int64
HeaderSize int64
BodySize int64
MetaSize int64
2020-10-04 14:30:42 +08:00
}
func (this *Item) IsExpired() bool {
return this.ExpiredAt < time.Now().Unix()
}
2021-01-13 12:02:50 +08:00
func (this *Item) TotalSize() int64 {
return this.Size() + this.MetaSize + int64(len(this.Key))
}
func (this *Item) Size() int64 {
return this.HeaderSize + this.BodySize
}