mirror of
				https://github.com/TeaOSLab/EdgeNode.git
				synced 2025-11-04 07:40:56 +08:00 
			
		
		
		
	优化代码
This commit is contained in:
		@@ -223,7 +223,7 @@ func (this *MemoryStorage) openWriter(key string, expiresAt int64, status int, h
 | 
			
		||||
		delete(this.writingKeyMap, key)
 | 
			
		||||
		this.locker.Unlock()
 | 
			
		||||
 | 
			
		||||
		if valueItem != nil && valueItem.IsDone {
 | 
			
		||||
		if valueItem != nil {
 | 
			
		||||
			valueItem.TotalSize = int64(len(valueItem.HeaderValue) + len(valueItem.BodyValue) + len(key) + 256 /** meta size **/)
 | 
			
		||||
 | 
			
		||||
			atomic.AddInt64(&this.usedSize, valueItem.TotalSize)
 | 
			
		||||
 
 | 
			
		||||
@@ -138,7 +138,7 @@ func (this *MemoryWriter) Close() error {
 | 
			
		||||
func (this *MemoryWriter) Discard() error {
 | 
			
		||||
	// 需要在Locker之外
 | 
			
		||||
	defer this.once.Do(func() {
 | 
			
		||||
		this.endFunc(nil)
 | 
			
		||||
		this.endFunc(this.item)
 | 
			
		||||
	})
 | 
			
		||||
 | 
			
		||||
	this.storage.locker.Lock()
 | 
			
		||||
 
 | 
			
		||||
@@ -4,7 +4,6 @@ import (
 | 
			
		||||
	"github.com/TeaOSLab/EdgeNode/internal/utils"
 | 
			
		||||
	"github.com/TeaOSLab/EdgeNode/internal/utils/expires"
 | 
			
		||||
	"github.com/TeaOSLab/EdgeNode/internal/utils/fasttime"
 | 
			
		||||
	"github.com/iwind/TeaGo/logs"
 | 
			
		||||
	"sort"
 | 
			
		||||
	"sync"
 | 
			
		||||
)
 | 
			
		||||
@@ -150,7 +149,6 @@ func (this *IPList) ContainsIPStrings(ipStrings []string) (item *IPItem, found b
 | 
			
		||||
 | 
			
		||||
func (this *IPList) SetDeleted() {
 | 
			
		||||
	this.isDeleted = true
 | 
			
		||||
	logs.Println("set deleted:", this.isDeleted) // TODO
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (this *IPList) addItem(item *IPItem, sortable bool) {
 | 
			
		||||
 
 | 
			
		||||
@@ -12,6 +12,7 @@ func setMaxMemory(memoryGB int) {
 | 
			
		||||
	if memoryGB <= 0 {
 | 
			
		||||
		memoryGB = 1
 | 
			
		||||
	}
 | 
			
		||||
	var maxMemoryBytes = (int64(memoryGB) << 30) * 80 / 100 // 默认 80%
 | 
			
		||||
 | 
			
		||||
	var maxMemoryBytes = (int64(memoryGB) << 30) * 75 / 100 // 默认 75%
 | 
			
		||||
	debug.SetMemoryLimit(maxMemoryBytes)
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user