aboutsummaryrefslogtreecommitdiffstats
path: root/cache/repo_cache.go
diff options
context:
space:
mode:
authorvince <vincetiu8@gmail.com>2020-08-25 10:43:42 +0800
committervince <vincetiu8@gmail.com>2020-08-25 11:08:53 +0800
commit4b065029af63c16ffd754ac28190ba4b3125c494 (patch)
tree23a38eab9850b5408d65f33063b1643b4eca5b36 /cache/repo_cache.go
parent6efada43e73c40e0c76c441f84cf02cc00d3eb1b (diff)
downloadgit-bug-4b065029af63c16ffd754ac28190ba4b3125c494.tar.gz
Implement cache eviction and testing
Diffstat (limited to 'cache/repo_cache.go')
-rw-r--r--cache/repo_cache.go16
1 files changed, 4 insertions, 12 deletions
diff --git a/cache/repo_cache.go b/cache/repo_cache.go
index 5fe1b798..f6ff1abe 100644
--- a/cache/repo_cache.go
+++ b/cache/repo_cache.go
@@ -82,6 +82,9 @@ func NewNamedRepoCache(r repository.ClockedRepo, name string) (*RepoCache, error
return &RepoCache{}, err
}
+ presentBugs := NewLRUIdCache(lruCacheSize)
+ c.presentBugs = presentBugs
+
err = c.load()
if err == nil {
return c, nil
@@ -180,22 +183,11 @@ func (c *RepoCache) buildCache() error {
_, _ = fmt.Fprintf(os.Stderr, "Building bug cache... ")
- presentBugs, err := NewLRUIdCache(lruCacheSize, c.onEvict)
- if err != nil {
- return err
- }
- c.presentBugs = presentBugs
-
c.bugExcerpts = make(map[entity.Id]*BugExcerpt)
allBugs := bug.ReadAllLocalBugs(c.repo)
- for i := 0; i < lruCacheSize; i++ {
- if len(allBugs) == 0 {
- break
- }
-
- b := <-allBugs
+ for b := range allBugs {
if b.Err != nil {
return b.Err
}