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

Method CleanMatchPrefix

internal/caches/list_memory.go:166–199  ·  view source on GitHub ↗

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

(prefix string)

Source from the content-addressed store, hash-verified

164
165// CleanMatchPrefix 清理通配符匹配的缓存数据,类似于 https://*.example.com/prefix/
166func (this *MemoryList) CleanMatchPrefix(prefix string) error {
167 u, err := url.Parse(prefix)
168 if err != nil {
169 return nil
170 }
171
172 var host = u.Host
173 hostPart, _, err := net.SplitHostPort(host)
174 if err == nil && len(hostPart) > 0 {
175 host = hostPart
176 }
177 if len(host) == 0 {
178 return nil
179 }
180 var requestURI = u.RequestURI()
181 var isRootPath = requestURI == "/"
182
183 this.locker.RLock()
184 defer this.locker.RUnlock()
185
186 // TODO 需要优化性能,支持千万级数据低于1s的处理速度
187 for _, itemMap := range this.itemMaps {
188 for _, item := range itemMap {
189 if configutils.MatchDomain(host, item.Host) {
190 var itemRequestURI = item.RequestURI()
191 if isRootPath || strings.HasPrefix(itemRequestURI, requestURI) {
192 item.ExpiresAt = 0
193 }
194 }
195 }
196 }
197
198 return nil
199}
200
201func (this *MemoryList) Remove(hash string) error {
202 this.locker.Lock()

Callers

nothing calls this directly

Calls 4

ParseMethod · 0.80
RequestURIMethod · 0.80
RLockMethod · 0.80
RUnlockMethod · 0.80

Tested by

no test coverage detected