内存缓存去除不必要的lock

This commit is contained in:
刘祥超
2021-03-03 14:28:54 +08:00
parent 9d30b9e699
commit 54e115f1c9

View File

@@ -38,20 +38,14 @@ func NewMemoryWriter(m map[uint64]*MemoryItem, key string, expiredAt int64, stat
// 写入数据
func (this *MemoryWriter) WriteHeader(data []byte) (n int, err error) {
this.headerSize += int64(len(data))
this.locker.Lock()
this.item.HeaderValue = append(this.item.HeaderValue, data...)
this.locker.Unlock()
return len(data), nil
}
// 写入数据
func (this *MemoryWriter) Write(data []byte) (n int, err error) {
this.bodySize += int64(len(data))
this.locker.Lock()
this.item.BodyValue = append(this.item.BodyValue, data...)
this.locker.Unlock()
return len(data), nil
}