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