mirror of
https://github.com/stashapp/stash.git
synced 2025-12-18 21:04:37 +03:00
Update xpath dependency (#507)
This commit is contained in:
12
vendor/github.com/antchfx/htmlquery/cache.go
generated
vendored
12
vendor/github.com/antchfx/htmlquery/cache.go
generated
vendored
@@ -3,9 +3,8 @@ package htmlquery
|
||||
import (
|
||||
"sync"
|
||||
|
||||
"github.com/golang/groupcache/lru"
|
||||
|
||||
"github.com/antchfx/xpath"
|
||||
"github.com/golang/groupcache/lru"
|
||||
)
|
||||
|
||||
// DisableSelectorCache will disable caching for the query selector if value is true.
|
||||
@@ -16,8 +15,9 @@ var DisableSelectorCache = false
|
||||
var SelectorCacheMaxEntries = 50
|
||||
|
||||
var (
|
||||
cacheOnce sync.Once
|
||||
cache *lru.Cache
|
||||
cacheOnce sync.Once
|
||||
cache *lru.Cache
|
||||
cacheMutex sync.Mutex
|
||||
)
|
||||
|
||||
func getQuery(expr string) (*xpath.Expr, error) {
|
||||
@@ -25,8 +25,10 @@ func getQuery(expr string) (*xpath.Expr, error) {
|
||||
return xpath.Compile(expr)
|
||||
}
|
||||
cacheOnce.Do(func() {
|
||||
cache = lru.New(50)
|
||||
cache = lru.New(SelectorCacheMaxEntries)
|
||||
})
|
||||
cacheMutex.Lock()
|
||||
defer cacheMutex.Unlock()
|
||||
if v, ok := cache.Get(expr); ok {
|
||||
return v.(*xpath.Expr), nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user