package httpserver import ( "fmt" "github.com/patrickmn/go-cache" ) type CachedResource struct { Data []byte Ctype string Rcode int } func NewCachedResource(data []byte, ctype string, rcode int) *CachedResource { return &CachedResource{ Data: data, Ctype: ctype, Rcode: rcode, } } func (c *Controller) CacheResource(key string, resource *CachedResource) { c.cache.Set(key, resource, cache.DefaultExpiration) } func (c *Controller) GetResource(key string) *CachedResource { resource, found := c.cache.Get(key) if found { fmt.Printf("Cache Hit! Found resource for URI: %s\n", key) return resource.(*CachedResource) } return nil }