diff options
author | Michael Muré <batolettre@gmail.com> | 2022-12-23 01:48:14 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-12-23 01:48:14 +0100 |
commit | 0a5a0ec1ef4ad98bc2116a953e201f96474941ab (patch) | |
tree | 660a9b17b5247fe2f954bfa814cce3193c5afa23 /cache/lru_id_cache.go | |
parent | 108518530e822e3bdf59c8bfc333ad0bbe2d5fc8 (diff) | |
parent | 95911100823b5c809225d664de74ad2d64e91972 (diff) | |
download | git-bug-0a5a0ec1ef4ad98bc2116a953e201f96474941ab.tar.gz |
Merge pull request #938 from MichaelMure/cache-reorg
Generic cache layer
Diffstat (limited to 'cache/lru_id_cache.go')
-rw-r--r-- | cache/lru_id_cache.go | 36 |
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) } |