(i *item, now time.Time)
| 173 | } |
| 174 | |
| 175 | func (c *Cache) shouldPrefetch(i *item, now time.Time) bool { |
| 176 | if c.prefetch <= 0 { |
| 177 | return false |
| 178 | } |
| 179 | i.Update(c.duration, now) |
| 180 | threshold := int(math.Ceil(float64(c.percentage) / 100 * float64(i.origTTL))) |
| 181 | return i.Hits() >= c.prefetch && i.ttl(now) <= threshold |
| 182 | } |
| 183 | |
| 184 | // Name implements the Handler interface. |
| 185 | func (c *Cache) Name() string { return "cache" } |