Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update github.com/hashicorp/golang-lru to v2 #3993

Merged
merged 1 commit into from
Aug 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ require (
github.com/gomodule/redigo v1.8.2
github.com/gorilla/handlers v1.5.1
github.com/gorilla/mux v1.8.0
github.com/hashicorp/golang-lru v0.5.4
github.com/hashicorp/golang-lru/arc/v2 v2.0.5
github.com/klauspost/compress v1.16.5
github.com/mitchellh/mapstructure v1.1.2
github.com/opencontainers/go-digest v1.0.0
Expand Down Expand Up @@ -80,5 +80,6 @@ require (
cloud.google.com/go/iam v0.12.0 // indirect
github.com/google/go-cmp v0.5.9 // indirect
github.com/googleapis/enterprise-certificate-proxy v0.2.3 // indirect
github.com/hashicorp/golang-lru/v2 v2.0.5 // indirect
golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 // indirect
)
6 changes: 4 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -195,8 +195,10 @@ github.com/gorilla/mux v1.8.0 h1:i40aqfkR1h2SlN9hojwV5ZA91wcXFOvkdNIeFDP5koI=
github.com/gorilla/mux v1.8.0/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So=
github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
github.com/hashicorp/golang-lru v0.5.4 h1:YDjusn29QI/Das2iO9M0BHnIbxPeyuCHsjMW+lJfyTc=
github.com/hashicorp/golang-lru v0.5.4/go.mod h1:iADmTwqILo4mZ8BN3D2Q6+9jd8WM5uGBxy+E8yxSoD4=
github.com/hashicorp/golang-lru/arc/v2 v2.0.5 h1:l2zaLDubNhW4XO3LnliVj0GXO3+/CGNJAg1dcN2Fpfw=
github.com/hashicorp/golang-lru/arc/v2 v2.0.5/go.mod h1:ny6zBSQZi2JxIeYcv7kt2sH2PXJtirBN7RDhRpxPkxU=
github.com/hashicorp/golang-lru/v2 v2.0.5 h1:wW7h1TG88eUIJ2i69gaE3uNVtEPIagzhGvHgwfx2Vm4=
github.com/hashicorp/golang-lru/v2 v2.0.5/go.mod h1:QeFd9opnmA6QUJc5vARoKUSoFhyfM2/ZepoAG6RGpeM=
github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
github.com/inconshreveable/mousetrap v1.0.1 h1:U3uMjPSQEBMNp1lFxmllqCPM6P5u/Xq7Pgzkat/bFNc=
github.com/inconshreveable/mousetrap v1.0.1/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
Expand Down
18 changes: 5 additions & 13 deletions registry/storage/cache/memory/memory.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"github.com/distribution/distribution/v3"
"github.com/distribution/distribution/v3/reference"
"github.com/distribution/distribution/v3/registry/storage/cache"
lru "github.com/hashicorp/golang-lru"
"github.com/hashicorp/golang-lru/arc/v2"
"github.com/opencontainers/go-digest"
)

Expand All @@ -26,7 +26,7 @@ type descriptorCacheKey struct {
}

type inMemoryBlobDescriptorCacheProvider struct {
lru *lru.ARCCache
lru *arc.ARCCache[descriptorCacheKey, distribution.Descriptor]
}

// NewInMemoryBlobDescriptorCacheProvider returns a new mapped-based cache for
Expand All @@ -35,7 +35,7 @@ func NewInMemoryBlobDescriptorCacheProvider(size int) cache.BlobDescriptorCacheP
if size <= 0 {
size = math.MaxInt
}
lruCache, err := lru.NewARC(size)
lruCache, err := arc.NewARC[descriptorCacheKey, distribution.Descriptor](size)
if err != nil {
// NewARC can only fail if size is <= 0, so this unreachable
panic(err)
Expand Down Expand Up @@ -66,11 +66,7 @@ func (imbdcp *inMemoryBlobDescriptorCacheProvider) Stat(ctx context.Context, dgs
}
descriptor, ok := imbdcp.lru.Get(key)
if ok {
// Type assertion not really necessary, but included in case
// it's necessary for the fuzzer
if desc, ok := descriptor.(distribution.Descriptor); ok {
return desc, nil
}
return descriptor, nil
}
return distribution.Descriptor{}, distribution.ErrBlobUnknown
}
Expand Down Expand Up @@ -130,11 +126,7 @@ func (rsimbdcp *repositoryScopedInMemoryBlobDescriptorCache) Stat(ctx context.Co
}
descriptor, ok := rsimbdcp.parent.lru.Get(key)
if ok {
// Type assertion not really necessary, but included in case
// it's necessary for the fuzzer
if desc, ok := descriptor.(distribution.Descriptor); ok {
return desc, nil
}
return descriptor, nil
}
return distribution.Descriptor{}, distribution.ErrBlobUnknown
}
Expand Down
23 changes: 0 additions & 23 deletions vendor/github.com/hashicorp/golang-lru/.gitignore

This file was deleted.

223 changes: 0 additions & 223 deletions vendor/github.com/hashicorp/golang-lru/2q.go

This file was deleted.

25 changes: 0 additions & 25 deletions vendor/github.com/hashicorp/golang-lru/README.md

This file was deleted.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading