Skip to content

Commit a0773d1

Browse files
committed
vendor: update simplelru to v2
Signed-off-by: Tonis Tiigi <[email protected]>
1 parent 1568159 commit a0773d1

File tree

7 files changed

+8
-592
lines changed

7 files changed

+8
-592
lines changed

cache/contenthash/checksum.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import (
1212
"sync"
1313

1414
iradix "github.com/hashicorp/go-immutable-radix/v2"
15-
"github.com/hashicorp/golang-lru/simplelru"
15+
simplelru "github.com/hashicorp/golang-lru/v2/simplelru"
1616
"github.com/moby/buildkit/cache"
1717
"github.com/moby/buildkit/session"
1818
"github.com/moby/buildkit/snapshot"
@@ -31,7 +31,7 @@ var defaultManagerOnce sync.Once
3131

3232
func getDefaultManager() *cacheManager {
3333
defaultManagerOnce.Do(func() {
34-
lru, _ := simplelru.NewLRU(20, nil) // error is impossible on positive size
34+
lru, _ := simplelru.NewLRU[string, *cacheContext](20, nil) // error is impossible on positive size
3535
defaultManager = &cacheManager{lru: lru, locker: locker.New()}
3636
})
3737
return defaultManager
@@ -85,7 +85,7 @@ type includedPath struct {
8585

8686
type cacheManager struct {
8787
locker *locker.Locker
88-
lru *simplelru.LRU
88+
lru *simplelru.LRU[string, *cacheContext]
8989
lruMu sync.Mutex
9090
}
9191

@@ -110,10 +110,10 @@ func (cm *cacheManager) GetCacheContext(ctx context.Context, md cache.RefMetadat
110110
cm.lruMu.Unlock()
111111
if ok {
112112
cm.locker.Unlock(md.ID())
113-
v.(*cacheContext).mu.Lock() // locking is required because multiple ImmutableRefs can reach this code; however none of them use the linkMap.
114-
v.(*cacheContext).linkMap = map[string][][]byte{}
115-
v.(*cacheContext).mu.Unlock()
116-
return v.(*cacheContext), nil
113+
v.mu.Lock() // locking is required because multiple ImmutableRefs can reach this code; however none of them use the linkMap.
114+
v.linkMap = map[string][][]byte{}
115+
v.mu.Unlock()
116+
return v, nil
117117
}
118118
cc, err := newCacheContext(md)
119119
if err != nil {

go.mod

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ require (
4242
github.com/hashicorp/go-cleanhttp v0.5.2
4343
github.com/hashicorp/go-immutable-radix/v2 v2.1.0
4444
github.com/hashicorp/go-multierror v1.1.1
45-
github.com/hashicorp/golang-lru v0.5.4
45+
github.com/hashicorp/golang-lru/v2 v2.0.0
4646
github.com/in-toto/in-toto-golang v0.5.0
4747
github.com/klauspost/compress v1.17.4
4848
github.com/mitchellh/hashstructure/v2 v2.0.2
@@ -148,7 +148,6 @@ require (
148148
github.com/hanwen/go-fuse/v2 v2.4.0 // indirect
149149
github.com/hashicorp/errwrap v1.1.0 // indirect
150150
github.com/hashicorp/go-retryablehttp v0.7.5 // indirect
151-
github.com/hashicorp/golang-lru/v2 v2.0.0 // indirect
152151
github.com/jmespath/go-jmespath v0.4.0 // indirect
153152
github.com/kylelemons/godebug v1.1.0 // indirect
154153
github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect

go.sum

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -249,8 +249,6 @@ github.com/hashicorp/go-retryablehttp v0.7.5 h1:bJj+Pj19UZMIweq/iie+1u5YCdGrnxCT
249249
github.com/hashicorp/go-retryablehttp v0.7.5/go.mod h1:Jy/gPYAdjqffZ/yFGCFV2doI5wjtH1ewM9u8iYVjtX8=
250250
github.com/hashicorp/go-uuid v1.0.3 h1:2gKiV6YVmrJ1i2CKKa9obLvRieoRGviZFL26PcT/Co8=
251251
github.com/hashicorp/go-uuid v1.0.3/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro=
252-
github.com/hashicorp/golang-lru v0.5.4 h1:YDjusn29QI/Das2iO9M0BHnIbxPeyuCHsjMW+lJfyTc=
253-
github.com/hashicorp/golang-lru v0.5.4/go.mod h1:iADmTwqILo4mZ8BN3D2Q6+9jd8WM5uGBxy+E8yxSoD4=
254252
github.com/hashicorp/golang-lru/v2 v2.0.0 h1:Lf+9eD8m5pncvHAOCQj49GSN6aQI8XGfI5OpXNkoWaA=
255253
github.com/hashicorp/golang-lru/v2 v2.0.0/go.mod h1:QeFd9opnmA6QUJc5vARoKUSoFhyfM2/ZepoAG6RGpeM=
256254
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=

0 commit comments

Comments
 (0)