// Retrieve the Status and Headers for a given key path func (c *Cache) Header(key string) (Header, error) { path := headerPrefix + formatPrefix + hashKey(key) f, err := c.fs.Open(path) if err != nil { if vfs.IsNotExist(err) { return Header{}, ErrNotFoundInCache } return Header{}, err } return readHeaders(bufio.NewReader(f)) }
// Retrieve returns a cached Resource for the given key func (c *Cache) Retrieve(key string) (*Resource, error) { f, err := c.fs.Open(bodyPrefix + formatPrefix + hashKey(key)) if err != nil { if vfs.IsNotExist(err) { return nil, ErrNotFoundInCache } return nil, err } h, err := c.Header(key) if err != nil { if vfs.IsNotExist(err) { return nil, ErrNotFoundInCache } return nil, err } res := NewResource(h.StatusCode, f, h.Header) if staleTime, exists := c.stale[key]; exists { if !res.DateAfter(staleTime) { log.Printf("stale marker of %s found", staleTime) res.MarkStale() } } return res, nil }