aboutsummaryrefslogtreecommitdiffstats
path: root/cache/lru_id_cache.go
diff options
context:
space:
mode:
authorMichael Muré <batolettre@gmail.com>2022-11-19 11:33:12 +0100
committerMichael Muré <batolettre@gmail.com>2022-11-28 17:20:25 +0100
commit0ac39a7ab5db077fcf0df827e32bf6e625e980da (patch)
treee453d6fd244cb322bdc6305c0088aa3c0331b075 /cache/lru_id_cache.go
parentc6bb6b9c7ecddb679966b1561e2e909a9ee5e8cd (diff)
downloadgit-bug-0ac39a7ab5db077fcf0df827e32bf6e625e980da.tar.gz
WIP
Diffstat (limited to 'cache/lru_id_cache.go')
-rw-r--r--cache/lru_id_cache.go36
1 files changed, 18 insertions, 18 deletions
diff --git a/cache/lru_id_cache.go b/cache/lru_id_cache.go
index fda12ca6..0e5e31a7 100644
--- a/cache/lru_id_cache.go
+++ b/cache/lru_id_cache.go
@@ -8,49 +8,49 @@ import (
"github.com/MichaelMure/git-bug/entity"
)
-type LRUIdCache struct {
- parentCache *lru.Cache
+type lruIdCache struct {
+ lru *lru.Cache
}
-func NewLRUIdCache() *LRUIdCache {
+func newLRUIdCache() *lruIdCache {
// we can ignore the error here as it would only fail if the size is negative.
cache, _ := lru.New(math.MaxInt32)
- return &LRUIdCache{
+ return &lruIdCache{
cache,
}
}
-func (c *LRUIdCache) Add(id entity.Id) bool {
- return c.parentCache.Add(id, nil)
+func (c *lruIdCache) Add(id entity.Id) bool {
+ return c.lru.Add(id, nil)
}
-func (c *LRUIdCache) Contains(id entity.Id) bool {
- return c.parentCache.Contains(id)
+func (c *lruIdCache) Contains(id entity.Id) bool {
+ return c.lru.Contains(id)
}
-func (c *LRUIdCache) Get(id entity.Id) bool {
- _, present := c.parentCache.Get(id)
+func (c *lruIdCache) Get(id entity.Id) bool {
+ _, present := c.lru.Get(id)
return present
}
-func (c *LRUIdCache) GetOldest() (entity.Id, bool) {
- id, _, present := c.parentCache.GetOldest()
+func (c *lruIdCache) GetOldest() (entity.Id, bool) {
+ id, _, present := c.lru.GetOldest()
return id.(entity.Id), present
}
-func (c *LRUIdCache) GetOldestToNewest() (ids []entity.Id) {
- interfaceKeys := c.parentCache.Keys()
+func (c *lruIdCache) GetOldestToNewest() (ids []entity.Id) {
+ interfaceKeys := c.lru.Keys()
for _, id := range interfaceKeys {
ids = append(ids, id.(entity.Id))
}
return
}
-func (c *LRUIdCache) Len() int {
- return c.parentCache.Len()
+func (c *lruIdCache) Len() int {
+ return c.lru.Len()
}
-func (c *LRUIdCache) Remove(id entity.Id) bool {
- return c.parentCache.Remove(id)
+func (c *lruIdCache) Remove(id entity.Id) bool {
+ return c.lru.Remove(id)
}