1package backend23import lru "github.com/hashicorp/golang-lru/v2"45// TODO: implement a caching interface.6type cache struct {7 b *Backend8 repos *lru.Cache[string, *repo]9}1011func newCache(b *Backend, size int) *cache {12 if size <= 0 {13 size = 114 }15 c := &cache{b: b}16 cache, _ := lru.New[string, *repo](size)17 c.repos = cache18 return c19}2021func (c *cache) Get(repo string) (*repo, bool) {22 return c.repos.Get(repo)23}2425func (c *cache) Set(repo string, r *repo) {26 c.repos.Add(repo, r)27}2829func (c *cache) Delete(repo string) {30 c.repos.Remove(repo)31}3233func (c *cache) Len() int {34 return c.repos.Len()35}