mirror of
https://github.com/project-zot/zot.git
synced 2026-06-16 04:17:55 +08:00
chore: update the version of go-lru we use to the latest available (#1141)
We are now using v2.0.1 in the cve cache logic. Unfortunately we are also using v0.5.4 indirectly, as it is required for gqlgen, see: https://github.com/99designs/gqlgen/blob/e6114a2c6af22bcdc92180660a58e6125e7946ad/go.mod#L7 Signed-off-by: Andrei Aaron <aaaron@luxoft.com>
This commit is contained in:
@@ -1,19 +1,19 @@
|
||||
package trivy
|
||||
|
||||
import (
|
||||
lru "github.com/hashicorp/golang-lru"
|
||||
lru "github.com/hashicorp/golang-lru/v2"
|
||||
|
||||
cvemodel "zotregistry.io/zot/pkg/extensions/search/cve/model"
|
||||
"zotregistry.io/zot/pkg/log"
|
||||
)
|
||||
|
||||
type CveCache struct {
|
||||
cache *lru.Cache
|
||||
cache *lru.Cache[string, map[string]cvemodel.CVE]
|
||||
log log.Logger
|
||||
}
|
||||
|
||||
func NewCveCache(size int, log log.Logger) *CveCache {
|
||||
cache, _ := lru.New(size)
|
||||
cache, _ := lru.New[string, map[string]cvemodel.CVE](size)
|
||||
|
||||
return &CveCache{cache: cache, log: log}
|
||||
}
|
||||
@@ -23,12 +23,7 @@ func (cveCache *CveCache) Add(image string, cveMap map[string]cvemodel.CVE) {
|
||||
}
|
||||
|
||||
func (cveCache *CveCache) Get(image string) map[string]cvemodel.CVE {
|
||||
value, ok := cveCache.cache.Get(image)
|
||||
if !ok {
|
||||
return nil
|
||||
}
|
||||
|
||||
cveMap, ok := value.(map[string]cvemodel.CVE)
|
||||
cveMap, ok := cveCache.cache.Get(image)
|
||||
if !ok {
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user