package context import ( "time" "github.com/patrickmn/go-cache" ) type RepositoryInformation struct { // Headers to include in every response Headers map[string]string CNAME string } func repoInfoKey(owner, name string) string { return owner + ":" + name } func (c *CacheContext) GetRepositoryInformation(owner, repoName string) *RepositoryInformation { data, found := c.RepositoryInformationCache.Get(repoInfoKey(owner, repoName)) if !found { return nil } typedData := data.(RepositoryInformation) return &typedData } func (c *CacheContext) SetRepositoryInformation(owner, repoName string, info RepositoryInformation) { c.RepositoryInformationCache.Set( repoInfoKey(owner, repoName), info, cache.DefaultExpiration, ) } func MakeRepoInfoCache() cache.Cache { return *cache.New(24*time.Hour, 12*time.Hour) }