MCPcopy Create free account
hub / github.com/GoEdgeLab/EdgeNode / init

Method init

internal/stats/user_agent_parser.go:51–69  ·  view source on GitHub ↗

初始化

()

Source from the content-addressed store, hash-verified

49
50// 初始化
51func (this *UserAgentParser) init() {
52 var maxCacheItems = 10_000
53 var systemMemory = memutils.SystemMemoryGB()
54 if systemMemory >= 16 {
55 maxCacheItems = 40_000
56 } else if systemMemory >= 8 {
57 maxCacheItems = 30_000
58 } else if systemMemory >= 4 {
59 maxCacheItems = 20_000
60 }
61 this.maxCacheItems = maxCacheItems
62
63 this.gcTicker = time.NewTicker(5 * time.Second)
64 goman.New(func() {
65 for range this.gcTicker.C {
66 this.GC()
67 }
68 })
69}
70
71// Parse 解析UserAgent
72func (this *UserAgentParser) Parse(userAgent string) (result UserAgentParserResult) {

Callers 1

NewUserAgentParserFunction · 0.45

Calls 2

GCMethod · 0.95
NewFunction · 0.92

Tested by

no test coverage detected