refactor: camlistore lru package moved location

This commit is contained in:
Bryan Boreham
2019-09-23 10:43:17 +00:00
parent e7e9e97943
commit ad34c5fd26
4 changed files with 13 additions and 12 deletions
+1 -1
View File
@@ -5,7 +5,7 @@ import (
"regexp"
"strings"
"github.com/camlistore/camlistore/pkg/lru"
"camlistore.org/pkg/lru"
"github.com/weaveworks/scope/report"
)
@@ -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()
}
}
+9 -9
View File
@@ -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",