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

Method CleanMatchKey

internal/caches/list_memory.go:126–163  ·  view source on GitHub ↗

CleanMatchKey 清理通配符匹配的缓存数据,类似于 https://*.example.com/hello

(key string)

Source from the content-addressed store, hash-verified

124
125// CleanMatchKey 清理通配符匹配的缓存数据,类似于 https://*.example.com/hello
126func (this *MemoryList) CleanMatchKey(key string) error {
127 if strings.Contains(key, SuffixAll) {
128 return nil
129 }
130
131 u, err := url.Parse(key)
132 if err != nil {
133 return nil
134 }
135
136 var host = u.Host
137 hostPart, _, err := net.SplitHostPort(host)
138 if err == nil && len(hostPart) > 0 {
139 host = hostPart
140 }
141
142 if len(host) == 0 {
143 return nil
144 }
145 var requestURI = u.RequestURI()
146
147 this.locker.RLock()
148 defer this.locker.RUnlock()
149
150 // TODO 需要优化性能,支持千万级数据低于1s的处理速度
151 for _, itemMap := range this.itemMaps {
152 for _, item := range itemMap {
153 if configutils.MatchDomain(host, item.Host) {
154 var itemRequestURI = item.RequestURI()
155 if itemRequestURI == requestURI || strings.HasPrefix(itemRequestURI, requestURI+SuffixAll) {
156 item.ExpiresAt = 0
157 }
158 }
159 }
160 }
161
162 return nil
163}
164
165// CleanMatchPrefix 清理通配符匹配的缓存数据,类似于 https://*.example.com/prefix/
166func (this *MemoryList) CleanMatchPrefix(prefix string) error {

Callers

nothing calls this directly

Calls 5

ParseMethod · 0.80
RequestURIMethod · 0.80
RLockMethod · 0.80
RUnlockMethod · 0.80
ContainsMethod · 0.45

Tested by

no test coverage detected