mirror of
https://github.com/weaveworks/scope.git
synced 2026-08-18 11:56:39 +00:00
refactor: camlistore lru package moved location
This commit is contained in:
@@ -5,7 +5,7 @@ import (
|
||||
"regexp"
|
||||
"strings"
|
||||
|
||||
"github.com/camlistore/camlistore/pkg/lru"
|
||||
"camlistore.org/pkg/lru"
|
||||
|
||||
"github.com/weaveworks/scope/report"
|
||||
)
|
||||
|
||||
Generated
Vendored
Generated
Vendored
+3
-2
@@ -24,7 +24,7 @@ import (
|
||||
|
||||
// Cache is an LRU cache, safe for concurrent access.
|
||||
type Cache struct {
|
||||
maxEntries int
|
||||
maxEntries int // zero means no limit
|
||||
|
||||
mu sync.Mutex
|
||||
ll *list.List
|
||||
@@ -38,6 +38,7 @@ type entry struct {
|
||||
}
|
||||
|
||||
// New returns a new cache with the provided maximum items.
|
||||
// A maxEntries of 0 means no limit.
|
||||
func New(maxEntries int) *Cache {
|
||||
return &Cache{
|
||||
maxEntries: maxEntries,
|
||||
@@ -63,7 +64,7 @@ func (c *Cache) Add(key string, value interface{}) {
|
||||
ele := c.ll.PushFront(&entry{key, value})
|
||||
c.cache[key] = ele
|
||||
|
||||
if c.ll.Len() > c.maxEntries {
|
||||
if c.maxEntries > 0 && c.ll.Len() > c.maxEntries {
|
||||
c.removeOldest()
|
||||
}
|
||||
}
|
||||
Vendored
+9
-9
@@ -8,6 +8,15 @@
|
||||
"revision": "75cd24fc2f2c",
|
||||
"branch": "default"
|
||||
},
|
||||
{
|
||||
"importpath": "camlistore.org/pkg/lru",
|
||||
"repository": "https://github.com/camlistore/old-cam-snapshot",
|
||||
"vcs": "git",
|
||||
"revision": "a5a65f0d8b2281c4cc8c259ba882dd0ec851427f",
|
||||
"branch": "master",
|
||||
"path": "/pkg/lru",
|
||||
"notests": true
|
||||
},
|
||||
{
|
||||
"importpath": "github.com/Azure/go-ansiterm",
|
||||
"repository": "https://github.com/Azure/go-ansiterm",
|
||||
@@ -238,15 +247,6 @@
|
||||
"path": "/statsd",
|
||||
"notests": true
|
||||
},
|
||||
{
|
||||
"importpath": "github.com/camlistore/camlistore/pkg/lru",
|
||||
"repository": "https://github.com/camlistore/camlistore",
|
||||
"vcs": "git",
|
||||
"revision": "f9dcdfb07a66d3cc07176b50e1a6cbee879e1b90",
|
||||
"branch": "master",
|
||||
"path": "/pkg/lru",
|
||||
"notests": true
|
||||
},
|
||||
{
|
||||
"importpath": "github.com/certifi/gocertifi",
|
||||
"repository": "https://github.com/certifi/gocertifi",
|
||||
|
||||
Reference in New Issue
Block a user