libyear/pkg/cache/cache.go

24 lines
444 B
Go
Raw Normal View History

2021-04-10 02:01:41 +00:00
package cache
2021-04-11 02:22:06 +00:00
import "git.yetaga.in/alazyreader/libyear/pkg/libyear"
2021-04-10 02:01:41 +00:00
// Cache isn't concurrency-safe, but we don't care about that right now
type Cache struct {
items map[string]libyear.Info
}
func (c *Cache) Get(k string) libyear.Info {
i, ok := c.items[k]
if ok {
return i
}
return libyear.Info{}
}
func (c *Cache) Set(k string, v libyear.Info) {
if c.items == nil {
c.items = make(map[string]libyear.Info)
}
c.items[k] = v
}