重构缓存

This commit is contained in:
yangjiechina
2023-12-09 17:18:04 +08:00
parent a849b496a2
commit 631c13303c
4 changed files with 77 additions and 37 deletions

View File

@@ -31,6 +31,8 @@ type MemoryPool interface {
FreeTail()
Data() ([]byte, []byte)
Clear()
}
func NewMemoryPool(capacity int) MemoryPool {
@@ -177,3 +179,14 @@ func (m *memoryPool) Data() ([]byte, []byte) {
}
}
func (m *memoryPool) Clear() {
m.capacity = cap(m.data)
m.head = 0
m.tail = 0
m.markIndex = 0
m.mark = false
m.blockQueue.Clear()
}