Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
a2592364
Unverified
Commit
a2592364
authored
Feb 20, 2019
by
Kubernetes Prow Robot
Committed by
GitHub
Feb 20, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #74260 from stafot/update-vendor-dependencies
Update vendor package github.com/hashicorp/golang-lru
parents
8ca0d8c5
df3fbf92
Hide whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
133 additions
and
61 deletions
+133
-61
Godeps.json
Godeps/Godeps.json
+4
-2
Godeps.json
...ing/src/k8s.io/apiextensions-apiserver/Godeps/Godeps.json
+2
-2
Godeps.json
staging/src/k8s.io/apimachinery/Godeps/Godeps.json
+2
-2
Godeps.json
staging/src/k8s.io/apiserver/Godeps/Godeps.json
+2
-2
Godeps.json
staging/src/k8s.io/client-go/Godeps/Godeps.json
+2
-2
Godeps.json
staging/src/k8s.io/cloud-provider/Godeps/Godeps.json
+2
-2
Godeps.json
staging/src/k8s.io/csi-api/Godeps/Godeps.json
+2
-2
Godeps.json
staging/src/k8s.io/kube-aggregator/Godeps/Godeps.json
+2
-2
Godeps.json
staging/src/k8s.io/node-api/Godeps/Godeps.json
+2
-2
Godeps.json
staging/src/k8s.io/sample-apiserver/Godeps/Godeps.json
+2
-2
Godeps.json
staging/src/k8s.io/sample-controller/Godeps/Godeps.json
+2
-2
2q.go
vendor/github.com/hashicorp/golang-lru/2q.go
+16
-5
BUILD
vendor/github.com/hashicorp/golang-lru/BUILD
+1
-0
arc.go
vendor/github.com/hashicorp/golang-lru/arc.go
+8
-8
doc.go
vendor/github.com/hashicorp/golang-lru/doc.go
+21
-0
go.mod
vendor/github.com/hashicorp/golang-lru/go.mod
+1
-0
lru.go
vendor/github.com/hashicorp/golang-lru/lru.go
+12
-16
BUILD
vendor/github.com/hashicorp/golang-lru/simplelru/BUILD
+4
-1
lru.go
vendor/github.com/hashicorp/golang-lru/simplelru/lru.go
+10
-9
lru_interface.go
...ithub.com/hashicorp/golang-lru/simplelru/lru_interface.go
+36
-0
No files found.
Godeps/Godeps.json
View file @
a2592364
...
@@ -2410,11 +2410,13 @@
...
@@ -2410,11 +2410,13 @@
},
},
{
{
"ImportPath"
:
"github.com/hashicorp/golang-lru"
,
"ImportPath"
:
"github.com/hashicorp/golang-lru"
,
"Rev"
:
"a0d98a5f288019575c6d1f4bb1573fef2d1fcdc4"
"Comment"
:
"v0.5.0"
,
"Rev"
:
"20f1fb78b0740ba8c3cb143a61e86ba5c8669768"
},
},
{
{
"ImportPath"
:
"github.com/hashicorp/golang-lru/simplelru"
,
"ImportPath"
:
"github.com/hashicorp/golang-lru/simplelru"
,
"Rev"
:
"a0d98a5f288019575c6d1f4bb1573fef2d1fcdc4"
"Comment"
:
"v0.5.0"
,
"Rev"
:
"20f1fb78b0740ba8c3cb143a61e86ba5c8669768"
},
},
{
{
"ImportPath"
:
"github.com/hashicorp/hcl"
,
"ImportPath"
:
"github.com/hashicorp/hcl"
,
...
...
staging/src/k8s.io/apiextensions-apiserver/Godeps/Godeps.json
View file @
a2592364
...
@@ -508,11 +508,11 @@
...
@@ -508,11 +508,11 @@
},
},
{
{
"ImportPath"
:
"github.com/hashicorp/golang-lru"
,
"ImportPath"
:
"github.com/hashicorp/golang-lru"
,
"Rev"
:
"
a0d98a5f288019575c6d1f4bb1573fef2d1fcdc4
"
"Rev"
:
"
20f1fb78b0740ba8c3cb143a61e86ba5c8669768
"
},
},
{
{
"ImportPath"
:
"github.com/hashicorp/golang-lru/simplelru"
,
"ImportPath"
:
"github.com/hashicorp/golang-lru/simplelru"
,
"Rev"
:
"
a0d98a5f288019575c6d1f4bb1573fef2d1fcdc4
"
"Rev"
:
"
20f1fb78b0740ba8c3cb143a61e86ba5c8669768
"
},
},
{
{
"ImportPath"
:
"github.com/imdario/mergo"
,
"ImportPath"
:
"github.com/imdario/mergo"
,
...
...
staging/src/k8s.io/apimachinery/Godeps/Godeps.json
View file @
a2592364
...
@@ -76,11 +76,11 @@
...
@@ -76,11 +76,11 @@
},
},
{
{
"ImportPath"
:
"github.com/hashicorp/golang-lru"
,
"ImportPath"
:
"github.com/hashicorp/golang-lru"
,
"Rev"
:
"
a0d98a5f288019575c6d1f4bb1573fef2d1fcdc4
"
"Rev"
:
"
20f1fb78b0740ba8c3cb143a61e86ba5c8669768
"
},
},
{
{
"ImportPath"
:
"github.com/hashicorp/golang-lru/simplelru"
,
"ImportPath"
:
"github.com/hashicorp/golang-lru/simplelru"
,
"Rev"
:
"
a0d98a5f288019575c6d1f4bb1573fef2d1fcdc4
"
"Rev"
:
"
20f1fb78b0740ba8c3cb143a61e86ba5c8669768
"
},
},
{
{
"ImportPath"
:
"github.com/json-iterator/go"
,
"ImportPath"
:
"github.com/json-iterator/go"
,
...
...
staging/src/k8s.io/apiserver/Godeps/Godeps.json
View file @
a2592364
...
@@ -488,11 +488,11 @@
...
@@ -488,11 +488,11 @@
},
},
{
{
"ImportPath"
:
"github.com/hashicorp/golang-lru"
,
"ImportPath"
:
"github.com/hashicorp/golang-lru"
,
"Rev"
:
"
a0d98a5f288019575c6d1f4bb1573fef2d1fcdc4
"
"Rev"
:
"
20f1fb78b0740ba8c3cb143a61e86ba5c8669768
"
},
},
{
{
"ImportPath"
:
"github.com/hashicorp/golang-lru/simplelru"
,
"ImportPath"
:
"github.com/hashicorp/golang-lru/simplelru"
,
"Rev"
:
"
a0d98a5f288019575c6d1f4bb1573fef2d1fcdc4
"
"Rev"
:
"
20f1fb78b0740ba8c3cb143a61e86ba5c8669768
"
},
},
{
{
"ImportPath"
:
"github.com/imdario/mergo"
,
"ImportPath"
:
"github.com/imdario/mergo"
,
...
...
staging/src/k8s.io/client-go/Godeps/Godeps.json
View file @
a2592364
...
@@ -148,11 +148,11 @@
...
@@ -148,11 +148,11 @@
},
},
{
{
"ImportPath"
:
"github.com/hashicorp/golang-lru"
,
"ImportPath"
:
"github.com/hashicorp/golang-lru"
,
"Rev"
:
"
a0d98a5f288019575c6d1f4bb1573fef2d1fcdc4
"
"Rev"
:
"
20f1fb78b0740ba8c3cb143a61e86ba5c8669768
"
},
},
{
{
"ImportPath"
:
"github.com/hashicorp/golang-lru/simplelru"
,
"ImportPath"
:
"github.com/hashicorp/golang-lru/simplelru"
,
"Rev"
:
"
a0d98a5f288019575c6d1f4bb1573fef2d1fcdc4
"
"Rev"
:
"
20f1fb78b0740ba8c3cb143a61e86ba5c8669768
"
},
},
{
{
"ImportPath"
:
"github.com/imdario/mergo"
,
"ImportPath"
:
"github.com/imdario/mergo"
,
...
...
staging/src/k8s.io/cloud-provider/Godeps/Godeps.json
View file @
a2592364
...
@@ -56,11 +56,11 @@
...
@@ -56,11 +56,11 @@
},
},
{
{
"ImportPath"
:
"github.com/hashicorp/golang-lru"
,
"ImportPath"
:
"github.com/hashicorp/golang-lru"
,
"Rev"
:
"
a0d98a5f288019575c6d1f4bb1573fef2d1fcdc4
"
"Rev"
:
"
20f1fb78b0740ba8c3cb143a61e86ba5c8669768
"
},
},
{
{
"ImportPath"
:
"github.com/hashicorp/golang-lru/simplelru"
,
"ImportPath"
:
"github.com/hashicorp/golang-lru/simplelru"
,
"Rev"
:
"
a0d98a5f288019575c6d1f4bb1573fef2d1fcdc4
"
"Rev"
:
"
20f1fb78b0740ba8c3cb143a61e86ba5c8669768
"
},
},
{
{
"ImportPath"
:
"github.com/json-iterator/go"
,
"ImportPath"
:
"github.com/json-iterator/go"
,
...
...
staging/src/k8s.io/csi-api/Godeps/Godeps.json
View file @
a2592364
...
@@ -60,11 +60,11 @@
...
@@ -60,11 +60,11 @@
},
},
{
{
"ImportPath"
:
"github.com/hashicorp/golang-lru"
,
"ImportPath"
:
"github.com/hashicorp/golang-lru"
,
"Rev"
:
"
a0d98a5f288019575c6d1f4bb1573fef2d1fcdc4
"
"Rev"
:
"
20f1fb78b0740ba8c3cb143a61e86ba5c8669768
"
},
},
{
{
"ImportPath"
:
"github.com/hashicorp/golang-lru/simplelru"
,
"ImportPath"
:
"github.com/hashicorp/golang-lru/simplelru"
,
"Rev"
:
"
a0d98a5f288019575c6d1f4bb1573fef2d1fcdc4
"
"Rev"
:
"
20f1fb78b0740ba8c3cb143a61e86ba5c8669768
"
},
},
{
{
"ImportPath"
:
"github.com/json-iterator/go"
,
"ImportPath"
:
"github.com/json-iterator/go"
,
...
...
staging/src/k8s.io/kube-aggregator/Godeps/Godeps.json
View file @
a2592364
...
@@ -160,11 +160,11 @@
...
@@ -160,11 +160,11 @@
},
},
{
{
"ImportPath"
:
"github.com/hashicorp/golang-lru"
,
"ImportPath"
:
"github.com/hashicorp/golang-lru"
,
"Rev"
:
"
a0d98a5f288019575c6d1f4bb1573fef2d1fcdc4
"
"Rev"
:
"
20f1fb78b0740ba8c3cb143a61e86ba5c8669768
"
},
},
{
{
"ImportPath"
:
"github.com/hashicorp/golang-lru/simplelru"
,
"ImportPath"
:
"github.com/hashicorp/golang-lru/simplelru"
,
"Rev"
:
"
a0d98a5f288019575c6d1f4bb1573fef2d1fcdc4
"
"Rev"
:
"
20f1fb78b0740ba8c3cb143a61e86ba5c8669768
"
},
},
{
{
"ImportPath"
:
"github.com/imdario/mergo"
,
"ImportPath"
:
"github.com/imdario/mergo"
,
...
...
staging/src/k8s.io/node-api/Godeps/Godeps.json
View file @
a2592364
...
@@ -60,11 +60,11 @@
...
@@ -60,11 +60,11 @@
},
},
{
{
"ImportPath"
:
"github.com/hashicorp/golang-lru"
,
"ImportPath"
:
"github.com/hashicorp/golang-lru"
,
"Rev"
:
"
a0d98a5f288019575c6d1f4bb1573fef2d1fcdc4
"
"Rev"
:
"
20f1fb78b0740ba8c3cb143a61e86ba5c8669768
"
},
},
{
{
"ImportPath"
:
"github.com/hashicorp/golang-lru/simplelru"
,
"ImportPath"
:
"github.com/hashicorp/golang-lru/simplelru"
,
"Rev"
:
"
a0d98a5f288019575c6d1f4bb1573fef2d1fcdc4
"
"Rev"
:
"
20f1fb78b0740ba8c3cb143a61e86ba5c8669768
"
},
},
{
{
"ImportPath"
:
"github.com/json-iterator/go"
,
"ImportPath"
:
"github.com/json-iterator/go"
,
...
...
staging/src/k8s.io/sample-apiserver/Godeps/Godeps.json
View file @
a2592364
...
@@ -152,11 +152,11 @@
...
@@ -152,11 +152,11 @@
},
},
{
{
"ImportPath"
:
"github.com/hashicorp/golang-lru"
,
"ImportPath"
:
"github.com/hashicorp/golang-lru"
,
"Rev"
:
"
a0d98a5f288019575c6d1f4bb1573fef2d1fcdc4
"
"Rev"
:
"
20f1fb78b0740ba8c3cb143a61e86ba5c8669768
"
},
},
{
{
"ImportPath"
:
"github.com/hashicorp/golang-lru/simplelru"
,
"ImportPath"
:
"github.com/hashicorp/golang-lru/simplelru"
,
"Rev"
:
"
a0d98a5f288019575c6d1f4bb1573fef2d1fcdc4
"
"Rev"
:
"
20f1fb78b0740ba8c3cb143a61e86ba5c8669768
"
},
},
{
{
"ImportPath"
:
"github.com/imdario/mergo"
,
"ImportPath"
:
"github.com/imdario/mergo"
,
...
...
staging/src/k8s.io/sample-controller/Godeps/Godeps.json
View file @
a2592364
...
@@ -64,11 +64,11 @@
...
@@ -64,11 +64,11 @@
},
},
{
{
"ImportPath"
:
"github.com/hashicorp/golang-lru"
,
"ImportPath"
:
"github.com/hashicorp/golang-lru"
,
"Rev"
:
"
a0d98a5f288019575c6d1f4bb1573fef2d1fcdc4
"
"Rev"
:
"
20f1fb78b0740ba8c3cb143a61e86ba5c8669768
"
},
},
{
{
"ImportPath"
:
"github.com/hashicorp/golang-lru/simplelru"
,
"ImportPath"
:
"github.com/hashicorp/golang-lru/simplelru"
,
"Rev"
:
"
a0d98a5f288019575c6d1f4bb1573fef2d1fcdc4
"
"Rev"
:
"
20f1fb78b0740ba8c3cb143a61e86ba5c8669768
"
},
},
{
{
"ImportPath"
:
"github.com/imdario/mergo"
,
"ImportPath"
:
"github.com/imdario/mergo"
,
...
...
vendor/github.com/hashicorp/golang-lru/2q.go
View file @
a2592364
...
@@ -30,9 +30,9 @@ type TwoQueueCache struct {
...
@@ -30,9 +30,9 @@ type TwoQueueCache struct {
size
int
size
int
recentSize
int
recentSize
int
recent
*
simplelru
.
LRU
recent
simplelru
.
LRUCache
frequent
*
simplelru
.
LRU
frequent
simplelru
.
LRUCache
recentEvict
*
simplelru
.
LRU
recentEvict
simplelru
.
LRUCache
lock
sync
.
RWMutex
lock
sync
.
RWMutex
}
}
...
@@ -84,7 +84,8 @@ func New2QParams(size int, recentRatio float64, ghostRatio float64) (*TwoQueueCa
...
@@ -84,7 +84,8 @@ func New2QParams(size int, recentRatio float64, ghostRatio float64) (*TwoQueueCa
return
c
,
nil
return
c
,
nil
}
}
func
(
c
*
TwoQueueCache
)
Get
(
key
interface
{})
(
interface
{},
bool
)
{
// Get looks up a key's value from the cache.
func
(
c
*
TwoQueueCache
)
Get
(
key
interface
{})
(
value
interface
{},
ok
bool
)
{
c
.
lock
.
Lock
()
c
.
lock
.
Lock
()
defer
c
.
lock
.
Unlock
()
defer
c
.
lock
.
Unlock
()
...
@@ -105,6 +106,7 @@ func (c *TwoQueueCache) Get(key interface{}) (interface{}, bool) {
...
@@ -105,6 +106,7 @@ func (c *TwoQueueCache) Get(key interface{}) (interface{}, bool) {
return
nil
,
false
return
nil
,
false
}
}
// Add adds a value to the cache.
func
(
c
*
TwoQueueCache
)
Add
(
key
,
value
interface
{})
{
func
(
c
*
TwoQueueCache
)
Add
(
key
,
value
interface
{})
{
c
.
lock
.
Lock
()
c
.
lock
.
Lock
()
defer
c
.
lock
.
Unlock
()
defer
c
.
lock
.
Unlock
()
...
@@ -160,12 +162,15 @@ func (c *TwoQueueCache) ensureSpace(recentEvict bool) {
...
@@ -160,12 +162,15 @@ func (c *TwoQueueCache) ensureSpace(recentEvict bool) {
c
.
frequent
.
RemoveOldest
()
c
.
frequent
.
RemoveOldest
()
}
}
// Len returns the number of items in the cache.
func
(
c
*
TwoQueueCache
)
Len
()
int
{
func
(
c
*
TwoQueueCache
)
Len
()
int
{
c
.
lock
.
RLock
()
c
.
lock
.
RLock
()
defer
c
.
lock
.
RUnlock
()
defer
c
.
lock
.
RUnlock
()
return
c
.
recent
.
Len
()
+
c
.
frequent
.
Len
()
return
c
.
recent
.
Len
()
+
c
.
frequent
.
Len
()
}
}
// Keys returns a slice of the keys in the cache.
// The frequently used keys are first in the returned slice.
func
(
c
*
TwoQueueCache
)
Keys
()
[]
interface
{}
{
func
(
c
*
TwoQueueCache
)
Keys
()
[]
interface
{}
{
c
.
lock
.
RLock
()
c
.
lock
.
RLock
()
defer
c
.
lock
.
RUnlock
()
defer
c
.
lock
.
RUnlock
()
...
@@ -174,6 +179,7 @@ func (c *TwoQueueCache) Keys() []interface{} {
...
@@ -174,6 +179,7 @@ func (c *TwoQueueCache) Keys() []interface{} {
return
append
(
k1
,
k2
...
)
return
append
(
k1
,
k2
...
)
}
}
// Remove removes the provided key from the cache.
func
(
c
*
TwoQueueCache
)
Remove
(
key
interface
{})
{
func
(
c
*
TwoQueueCache
)
Remove
(
key
interface
{})
{
c
.
lock
.
Lock
()
c
.
lock
.
Lock
()
defer
c
.
lock
.
Unlock
()
defer
c
.
lock
.
Unlock
()
...
@@ -188,6 +194,7 @@ func (c *TwoQueueCache) Remove(key interface{}) {
...
@@ -188,6 +194,7 @@ func (c *TwoQueueCache) Remove(key interface{}) {
}
}
}
}
// Purge is used to completely clear the cache.
func
(
c
*
TwoQueueCache
)
Purge
()
{
func
(
c
*
TwoQueueCache
)
Purge
()
{
c
.
lock
.
Lock
()
c
.
lock
.
Lock
()
defer
c
.
lock
.
Unlock
()
defer
c
.
lock
.
Unlock
()
...
@@ -196,13 +203,17 @@ func (c *TwoQueueCache) Purge() {
...
@@ -196,13 +203,17 @@ func (c *TwoQueueCache) Purge() {
c
.
recentEvict
.
Purge
()
c
.
recentEvict
.
Purge
()
}
}
// Contains is used to check if the cache contains a key
// without updating recency or frequency.
func
(
c
*
TwoQueueCache
)
Contains
(
key
interface
{})
bool
{
func
(
c
*
TwoQueueCache
)
Contains
(
key
interface
{})
bool
{
c
.
lock
.
RLock
()
c
.
lock
.
RLock
()
defer
c
.
lock
.
RUnlock
()
defer
c
.
lock
.
RUnlock
()
return
c
.
frequent
.
Contains
(
key
)
||
c
.
recent
.
Contains
(
key
)
return
c
.
frequent
.
Contains
(
key
)
||
c
.
recent
.
Contains
(
key
)
}
}
func
(
c
*
TwoQueueCache
)
Peek
(
key
interface
{})
(
interface
{},
bool
)
{
// Peek is used to inspect the cache value of a key
// without updating recency or frequency.
func
(
c
*
TwoQueueCache
)
Peek
(
key
interface
{})
(
value
interface
{},
ok
bool
)
{
c
.
lock
.
RLock
()
c
.
lock
.
RLock
()
defer
c
.
lock
.
RUnlock
()
defer
c
.
lock
.
RUnlock
()
if
val
,
ok
:=
c
.
frequent
.
Peek
(
key
);
ok
{
if
val
,
ok
:=
c
.
frequent
.
Peek
(
key
);
ok
{
...
...
vendor/github.com/hashicorp/golang-lru/BUILD
View file @
a2592364
...
@@ -5,6 +5,7 @@ go_library(
...
@@ -5,6 +5,7 @@ go_library(
srcs = [
srcs = [
"2q.go",
"2q.go",
"arc.go",
"arc.go",
"doc.go",
"lru.go",
"lru.go",
],
],
importmap = "k8s.io/kubernetes/vendor/github.com/hashicorp/golang-lru",
importmap = "k8s.io/kubernetes/vendor/github.com/hashicorp/golang-lru",
...
...
vendor/github.com/hashicorp/golang-lru/arc.go
View file @
a2592364
...
@@ -18,11 +18,11 @@ type ARCCache struct {
...
@@ -18,11 +18,11 @@ type ARCCache struct {
size
int
// Size is the total capacity of the cache
size
int
// Size is the total capacity of the cache
p
int
// P is the dynamic preference towards T1 or T2
p
int
// P is the dynamic preference towards T1 or T2
t1
*
simplelru
.
LRU
// T1 is the LRU for recently accessed items
t1
simplelru
.
LRUCache
// T1 is the LRU for recently accessed items
b1
*
simplelru
.
LRU
// B1 is the LRU for evictions from t1
b1
simplelru
.
LRUCache
// B1 is the LRU for evictions from t1
t2
*
simplelru
.
LRU
// T2 is the LRU for frequently accessed items
t2
simplelru
.
LRUCache
// T2 is the LRU for frequently accessed items
b2
*
simplelru
.
LRU
// B2 is the LRU for evictions from t2
b2
simplelru
.
LRUCache
// B2 is the LRU for evictions from t2
lock
sync
.
RWMutex
lock
sync
.
RWMutex
}
}
...
@@ -60,11 +60,11 @@ func NewARC(size int) (*ARCCache, error) {
...
@@ -60,11 +60,11 @@ func NewARC(size int) (*ARCCache, error) {
}
}
// Get looks up a key's value from the cache.
// Get looks up a key's value from the cache.
func
(
c
*
ARCCache
)
Get
(
key
interface
{})
(
interface
{},
bool
)
{
func
(
c
*
ARCCache
)
Get
(
key
interface
{})
(
value
interface
{},
ok
bool
)
{
c
.
lock
.
Lock
()
c
.
lock
.
Lock
()
defer
c
.
lock
.
Unlock
()
defer
c
.
lock
.
Unlock
()
//
F
f the value is contained in T1 (recent), then
//
I
f the value is contained in T1 (recent), then
// promote it to T2 (frequent)
// promote it to T2 (frequent)
if
val
,
ok
:=
c
.
t1
.
Peek
(
key
);
ok
{
if
val
,
ok
:=
c
.
t1
.
Peek
(
key
);
ok
{
c
.
t1
.
Remove
(
key
)
c
.
t1
.
Remove
(
key
)
...
@@ -153,7 +153,7 @@ func (c *ARCCache) Add(key, value interface{}) {
...
@@ -153,7 +153,7 @@ func (c *ARCCache) Add(key, value interface{}) {
// Remove from B2
// Remove from B2
c
.
b2
.
Remove
(
key
)
c
.
b2
.
Remove
(
key
)
// Add the key to the frequntly used list
// Add the key to the frequ
e
ntly used list
c
.
t2
.
Add
(
key
,
value
)
c
.
t2
.
Add
(
key
,
value
)
return
return
}
}
...
@@ -247,7 +247,7 @@ func (c *ARCCache) Contains(key interface{}) bool {
...
@@ -247,7 +247,7 @@ func (c *ARCCache) Contains(key interface{}) bool {
// Peek is used to inspect the cache value of a key
// Peek is used to inspect the cache value of a key
// without updating recency or frequency.
// without updating recency or frequency.
func
(
c
*
ARCCache
)
Peek
(
key
interface
{})
(
interface
{},
bool
)
{
func
(
c
*
ARCCache
)
Peek
(
key
interface
{})
(
value
interface
{},
ok
bool
)
{
c
.
lock
.
RLock
()
c
.
lock
.
RLock
()
defer
c
.
lock
.
RUnlock
()
defer
c
.
lock
.
RUnlock
()
if
val
,
ok
:=
c
.
t1
.
Peek
(
key
);
ok
{
if
val
,
ok
:=
c
.
t1
.
Peek
(
key
);
ok
{
...
...
vendor/github.com/hashicorp/golang-lru/doc.go
0 → 100644
View file @
a2592364
// Package lru provides three different LRU caches of varying sophistication.
//
// Cache is a simple LRU cache. It is based on the
// LRU implementation in groupcache:
// https://github.com/golang/groupcache/tree/master/lru
//
// TwoQueueCache tracks frequently used and recently used entries separately.
// This avoids a burst of accesses from taking out frequently used entries,
// at the cost of about 2x computational overhead and some extra bookkeeping.
//
// ARCCache is an adaptive replacement cache. It tracks recent evictions as
// well as recent usage in both the frequent and recent caches. Its
// computational overhead is comparable to TwoQueueCache, but the memory
// overhead is linear with the size of the cache.
//
// ARC has been patented by IBM, so do not use it if that is problematic for
// your program.
//
// All caches in this package take locks while operating, and are therefore
// thread-safe for consumers.
package
lru
vendor/github.com/hashicorp/golang-lru/go.mod
0 → 100644
View file @
a2592364
module github.com/hashicorp/golang-lru
vendor/github.com/hashicorp/golang-lru/lru.go
View file @
a2592364
// This package provides a simple LRU cache. It is based on the
// LRU implementation in groupcache:
// https://github.com/golang/groupcache/tree/master/lru
package
lru
package
lru
import
(
import
(
...
@@ -11,11 +8,11 @@ import (
...
@@ -11,11 +8,11 @@ import (
// Cache is a thread-safe fixed size LRU cache.
// Cache is a thread-safe fixed size LRU cache.
type
Cache
struct
{
type
Cache
struct
{
lru
*
simplelru
.
LRU
lru
simplelru
.
LRUCache
lock
sync
.
RWMutex
lock
sync
.
RWMutex
}
}
// New creates an LRU of the given size
// New creates an LRU of the given size
.
func
New
(
size
int
)
(
*
Cache
,
error
)
{
func
New
(
size
int
)
(
*
Cache
,
error
)
{
return
NewWithEvict
(
size
,
nil
)
return
NewWithEvict
(
size
,
nil
)
}
}
...
@@ -33,7 +30,7 @@ func NewWithEvict(size int, onEvicted func(key interface{}, value interface{}))
...
@@ -33,7 +30,7 @@ func NewWithEvict(size int, onEvicted func(key interface{}, value interface{}))
return
c
,
nil
return
c
,
nil
}
}
// Purge is used to completely clear the cache
// Purge is used to completely clear the cache
.
func
(
c
*
Cache
)
Purge
()
{
func
(
c
*
Cache
)
Purge
()
{
c
.
lock
.
Lock
()
c
.
lock
.
Lock
()
c
.
lru
.
Purge
()
c
.
lru
.
Purge
()
...
@@ -41,30 +38,30 @@ func (c *Cache) Purge() {
...
@@ -41,30 +38,30 @@ func (c *Cache) Purge() {
}
}
// Add adds a value to the cache. Returns true if an eviction occurred.
// Add adds a value to the cache. Returns true if an eviction occurred.
func
(
c
*
Cache
)
Add
(
key
,
value
interface
{})
bool
{
func
(
c
*
Cache
)
Add
(
key
,
value
interface
{})
(
evicted
bool
)
{
c
.
lock
.
Lock
()
c
.
lock
.
Lock
()
defer
c
.
lock
.
Unlock
()
defer
c
.
lock
.
Unlock
()
return
c
.
lru
.
Add
(
key
,
value
)
return
c
.
lru
.
Add
(
key
,
value
)
}
}
// Get looks up a key's value from the cache.
// Get looks up a key's value from the cache.
func
(
c
*
Cache
)
Get
(
key
interface
{})
(
interface
{},
bool
)
{
func
(
c
*
Cache
)
Get
(
key
interface
{})
(
value
interface
{},
ok
bool
)
{
c
.
lock
.
Lock
()
c
.
lock
.
Lock
()
defer
c
.
lock
.
Unlock
()
defer
c
.
lock
.
Unlock
()
return
c
.
lru
.
Get
(
key
)
return
c
.
lru
.
Get
(
key
)
}
}
// C
heck if a key is in the cache, without updating the recent-ness
// C
ontains checks if a key is in the cache, without updating the
// or deleting it for being stale.
//
recent-ness
or deleting it for being stale.
func
(
c
*
Cache
)
Contains
(
key
interface
{})
bool
{
func
(
c
*
Cache
)
Contains
(
key
interface
{})
bool
{
c
.
lock
.
RLock
()
c
.
lock
.
RLock
()
defer
c
.
lock
.
RUnlock
()
defer
c
.
lock
.
RUnlock
()
return
c
.
lru
.
Contains
(
key
)
return
c
.
lru
.
Contains
(
key
)
}
}
//
R
eturns the key value (or undefined if not found) without updating
//
Peek r
eturns the key value (or undefined if not found) without updating
// the "recently used"-ness of the key.
// the "recently used"-ness of the key.
func
(
c
*
Cache
)
Peek
(
key
interface
{})
(
interface
{},
bool
)
{
func
(
c
*
Cache
)
Peek
(
key
interface
{})
(
value
interface
{},
ok
bool
)
{
c
.
lock
.
RLock
()
c
.
lock
.
RLock
()
defer
c
.
lock
.
RUnlock
()
defer
c
.
lock
.
RUnlock
()
return
c
.
lru
.
Peek
(
key
)
return
c
.
lru
.
Peek
(
key
)
...
@@ -73,16 +70,15 @@ func (c *Cache) Peek(key interface{}) (interface{}, bool) {
...
@@ -73,16 +70,15 @@ func (c *Cache) Peek(key interface{}) (interface{}, bool) {
// ContainsOrAdd checks if a key is in the cache without updating the
// ContainsOrAdd checks if a key is in the cache without updating the
// recent-ness or deleting it for being stale, and if not, adds the value.
// recent-ness or deleting it for being stale, and if not, adds the value.
// Returns whether found and whether an eviction occurred.
// Returns whether found and whether an eviction occurred.
func
(
c
*
Cache
)
ContainsOrAdd
(
key
,
value
interface
{})
(
ok
,
evict
bool
)
{
func
(
c
*
Cache
)
ContainsOrAdd
(
key
,
value
interface
{})
(
ok
,
evict
ed
bool
)
{
c
.
lock
.
Lock
()
c
.
lock
.
Lock
()
defer
c
.
lock
.
Unlock
()
defer
c
.
lock
.
Unlock
()
if
c
.
lru
.
Contains
(
key
)
{
if
c
.
lru
.
Contains
(
key
)
{
return
true
,
false
return
true
,
false
}
else
{
evict
:=
c
.
lru
.
Add
(
key
,
value
)
return
false
,
evict
}
}
evicted
=
c
.
lru
.
Add
(
key
,
value
)
return
false
,
evicted
}
}
// Remove removes the provided key from the cache.
// Remove removes the provided key from the cache.
...
...
vendor/github.com/hashicorp/golang-lru/simplelru/BUILD
View file @
a2592364
...
@@ -2,7 +2,10 @@ load("@io_bazel_rules_go//go:def.bzl", "go_library")
...
@@ -2,7 +2,10 @@ load("@io_bazel_rules_go//go:def.bzl", "go_library")
go_library(
go_library(
name = "go_default_library",
name = "go_default_library",
srcs = ["lru.go"],
srcs = [
"lru.go",
"lru_interface.go",
],
importmap = "k8s.io/kubernetes/vendor/github.com/hashicorp/golang-lru/simplelru",
importmap = "k8s.io/kubernetes/vendor/github.com/hashicorp/golang-lru/simplelru",
importpath = "github.com/hashicorp/golang-lru/simplelru",
importpath = "github.com/hashicorp/golang-lru/simplelru",
visibility = ["//visibility:public"],
visibility = ["//visibility:public"],
...
...
vendor/github.com/hashicorp/golang-lru/simplelru/lru.go
View file @
a2592364
...
@@ -36,7 +36,7 @@ func NewLRU(size int, onEvict EvictCallback) (*LRU, error) {
...
@@ -36,7 +36,7 @@ func NewLRU(size int, onEvict EvictCallback) (*LRU, error) {
return
c
,
nil
return
c
,
nil
}
}
// Purge is used to completely clear the cache
// Purge is used to completely clear the cache
.
func
(
c
*
LRU
)
Purge
()
{
func
(
c
*
LRU
)
Purge
()
{
for
k
,
v
:=
range
c
.
items
{
for
k
,
v
:=
range
c
.
items
{
if
c
.
onEvict
!=
nil
{
if
c
.
onEvict
!=
nil
{
...
@@ -47,8 +47,8 @@ func (c *LRU) Purge() {
...
@@ -47,8 +47,8 @@ func (c *LRU) Purge() {
c
.
evictList
.
Init
()
c
.
evictList
.
Init
()
}
}
// Add adds a value to the cache. Returns true if an eviction occured.
// Add adds a value to the cache. Returns true if an eviction occur
r
ed.
func
(
c
*
LRU
)
Add
(
key
,
value
interface
{})
bool
{
func
(
c
*
LRU
)
Add
(
key
,
value
interface
{})
(
evicted
bool
)
{
// Check for existing item
// Check for existing item
if
ent
,
ok
:=
c
.
items
[
key
];
ok
{
if
ent
,
ok
:=
c
.
items
[
key
];
ok
{
c
.
evictList
.
MoveToFront
(
ent
)
c
.
evictList
.
MoveToFront
(
ent
)
...
@@ -78,17 +78,18 @@ func (c *LRU) Get(key interface{}) (value interface{}, ok bool) {
...
@@ -78,17 +78,18 @@ func (c *LRU) Get(key interface{}) (value interface{}, ok bool) {
return
return
}
}
// C
heck
if a key is in the cache, without updating the recent-ness
// C
ontains checks
if a key is in the cache, without updating the recent-ness
// or deleting it for being stale.
// or deleting it for being stale.
func
(
c
*
LRU
)
Contains
(
key
interface
{})
(
ok
bool
)
{
func
(
c
*
LRU
)
Contains
(
key
interface
{})
(
ok
bool
)
{
_
,
ok
=
c
.
items
[
key
]
_
,
ok
=
c
.
items
[
key
]
return
ok
return
ok
}
}
//
R
eturns the key value (or undefined if not found) without updating
//
Peek r
eturns the key value (or undefined if not found) without updating
// the "recently used"-ness of the key.
// the "recently used"-ness of the key.
func
(
c
*
LRU
)
Peek
(
key
interface
{})
(
value
interface
{},
ok
bool
)
{
func
(
c
*
LRU
)
Peek
(
key
interface
{})
(
value
interface
{},
ok
bool
)
{
if
ent
,
ok
:=
c
.
items
[
key
];
ok
{
var
ent
*
list
.
Element
if
ent
,
ok
=
c
.
items
[
key
];
ok
{
return
ent
.
Value
.
(
*
entry
)
.
value
,
true
return
ent
.
Value
.
(
*
entry
)
.
value
,
true
}
}
return
nil
,
ok
return
nil
,
ok
...
@@ -96,7 +97,7 @@ func (c *LRU) Peek(key interface{}) (value interface{}, ok bool) {
...
@@ -96,7 +97,7 @@ func (c *LRU) Peek(key interface{}) (value interface{}, ok bool) {
// Remove removes the provided key from the cache, returning if the
// Remove removes the provided key from the cache, returning if the
// key was contained.
// key was contained.
func
(
c
*
LRU
)
Remove
(
key
interface
{})
bool
{
func
(
c
*
LRU
)
Remove
(
key
interface
{})
(
present
bool
)
{
if
ent
,
ok
:=
c
.
items
[
key
];
ok
{
if
ent
,
ok
:=
c
.
items
[
key
];
ok
{
c
.
removeElement
(
ent
)
c
.
removeElement
(
ent
)
return
true
return
true
...
@@ -105,7 +106,7 @@ func (c *LRU) Remove(key interface{}) bool {
...
@@ -105,7 +106,7 @@ func (c *LRU) Remove(key interface{}) bool {
}
}
// RemoveOldest removes the oldest item from the cache.
// RemoveOldest removes the oldest item from the cache.
func
(
c
*
LRU
)
RemoveOldest
()
(
interface
{},
interface
{},
bool
)
{
func
(
c
*
LRU
)
RemoveOldest
()
(
key
interface
{},
value
interface
{},
ok
bool
)
{
ent
:=
c
.
evictList
.
Back
()
ent
:=
c
.
evictList
.
Back
()
if
ent
!=
nil
{
if
ent
!=
nil
{
c
.
removeElement
(
ent
)
c
.
removeElement
(
ent
)
...
@@ -116,7 +117,7 @@ func (c *LRU) RemoveOldest() (interface{}, interface{}, bool) {
...
@@ -116,7 +117,7 @@ func (c *LRU) RemoveOldest() (interface{}, interface{}, bool) {
}
}
// GetOldest returns the oldest entry
// GetOldest returns the oldest entry
func
(
c
*
LRU
)
GetOldest
()
(
interface
{},
interface
{},
bool
)
{
func
(
c
*
LRU
)
GetOldest
()
(
key
interface
{},
value
interface
{},
ok
bool
)
{
ent
:=
c
.
evictList
.
Back
()
ent
:=
c
.
evictList
.
Back
()
if
ent
!=
nil
{
if
ent
!=
nil
{
kv
:=
ent
.
Value
.
(
*
entry
)
kv
:=
ent
.
Value
.
(
*
entry
)
...
...
vendor/github.com/hashicorp/golang-lru/simplelru/lru_interface.go
0 → 100644
View file @
a2592364
package
simplelru
// LRUCache is the interface for simple LRU cache.
type
LRUCache
interface
{
// Adds a value to the cache, returns true if an eviction occurred and
// updates the "recently used"-ness of the key.
Add
(
key
,
value
interface
{})
bool
// Returns key's value from the cache and
// updates the "recently used"-ness of the key. #value, isFound
Get
(
key
interface
{})
(
value
interface
{},
ok
bool
)
// Check if a key exsists in cache without updating the recent-ness.
Contains
(
key
interface
{})
(
ok
bool
)
// Returns key's value without updating the "recently used"-ness of the key.
Peek
(
key
interface
{})
(
value
interface
{},
ok
bool
)
// Removes a key from the cache.
Remove
(
key
interface
{})
bool
// Removes the oldest entry from cache.
RemoveOldest
()
(
interface
{},
interface
{},
bool
)
// Returns the oldest entry from the cache. #key, value, isFound
GetOldest
()
(
interface
{},
interface
{},
bool
)
// Returns a slice of the keys in the cache, from oldest to newest.
Keys
()
[]
interface
{}
// Returns the number of items in the cache.
Len
()
int
// Clear all cache entries
Purge
()
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment