INNER CODE UNIT · Go
func
cc1a2b/JShunter · internal/jshunter/cache.go:54
func (c *DiskCache) keyFor(u string) string {
h := sha256.Sum256([]byte(u))
return hex.EncodeToString(h[:])
}
func (c *DiskCache) bodyPath(u string) string {
return filepath.Join(c.dir, c.keyFor(u)+".body")
}
func (c *DiskCache) metaPath(u string) string {
return filepath.Join(c.dir, c.keyFor(u)+".meta")
}
// Lookup returns the cached entry if present. Caller decides whether to
// short-circuit (use as-is) or revalidate via If-None-Match.
func (c *DiskCache) Lookup(u string) (body []byte, meta *cacheMeta, ok bool) {
if c == nil {
return nil, nil, false