MCPcopy Create free account
hub / github.com/antchfx/xmlquery / getQuery

Function getQuery

cache.go:24–43  ·  view source on GitHub ↗
(expr string)

Source from the content-addressed store, hash-verified

22)
23
24func getQuery(expr string) (*xpath.Expr, error) {
25 if DisableSelectorCache || SelectorCacheMaxEntries <= 0 {
26 return xpath.Compile(expr)
27 }
28 cacheOnce.Do(func() {
29 cache = lru.New(SelectorCacheMaxEntries)
30 })
31 cacheMutex.Lock()
32 defer cacheMutex.Unlock()
33 if v, ok := cache.Get(expr); ok {
34 return v.(*xpath.Expr), nil
35 }
36 v, err := xpath.Compile(expr)
37 if err != nil {
38 return nil, err
39 }
40 cache.Add(expr, v)
41 return v, nil
42
43}

Callers 3

QueryAllFunction · 0.85
QueryFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…