// CacheExpires helper function to determine remaining time before repeating a request.
430187
func CacheExpires(r *http.Response) (time.Time) {
	// Figure out when the cache expires.
	var expires time.Time
	now, err := time.Parse(time.RFC1123, r.Header.Get("date"))
	if err != nil {
		return time.Now()
	}
	respCacheControl := parseCacheControl(r.Header)
	
	if maxAge, ok := respCacheControl["max-age"]; ok {
		lifetime, err := time.ParseDuration(maxAge + "s")
		if err != nil {
			expires = now
		}
		expires = now.Add(lifetime)
	} else {
		expiresHeader := r.Header.Get("Expires")
		if expiresHeader != "" {
			expires, err = time.Parse(time.RFC1123, expiresHeader)
			if err != nil {
				expires = now
			}
		}
	}
	return expires
}
990504
func (e *cacheEntryExpiry) Reset() {
	e.Expires = time.Now().Add(e.TTL)
}
607956
func (p *ProcessProvider) IsExpired() bool {
	if p.staticCreds {
		return false
	}
	return p.Expiry.IsExpired()
}
1155774
func UpdateExpiration(w http.ResponseWriter, r *http.Request, expires time.Duration) {
	Default.UpdateExpiration(w, r, expires)
}
157159
func (s *Service) ExpireSession(ctx context.Context, key string) error {
	return nil
}
337138
func (d *Delay) GetExpiration(key string) time.Time {
	d.lock.RLock()
	expires := d.delay[key]
	d.lock.RUnlock()
	return expires
}
389342
func (c *CacheTTL) SetExpire(key string, data interface{}, ttl int64) error {
	if key == "" {
		return nil
	}

	c.itemsMu.Lock()
	defer c.itemsMu.Unlock()

	if data == nil {
		delete(c.items, key)
		return nil
	}

	// return oldest item when the cache reaches maximum size
	if len(c.deleteQueue) >= c.maxSize {
		c.deleteOldest()
	}

	item := eurekache.NewItem()
	item.SetExpire(ttl)
	item.Value = data
	c.items[key] = item
	c.deleteQueue = append(c.deleteQueue, key)
	return nil
}
746605
func (c *Client) Expire(key string, seconds uint64) (bool, error) {
	var ret bool
	err := c.command(
		&ret,
		[]byte("EXPIRE"),
		[]byte(key),
		to.Bytes(seconds),
	)
	return ret, err
}
15966
func (s *sigHead) cache() (err error) {
	if !s.clean {
		s.Protected, err = s.protected.Base64()
		if err != nil {
			return err
		}
		s.Unprotected, err = s.unprotected.Base64()
		if err != nil {
			return err
		}
	}
	s.clean = true
	return nil
}
1263216
func (peer *Peer) expire() {
	unmark := make(map[common.Hash]struct{})
	peer.known.Each(func(v interface{}) bool {
		if !peer.host.isEnvelopeCached(v.(common.Hash)) {
			unmark[v.(common.Hash)] = struct{}{}
		}
		return true
	})
	// Dump all known but no longer cached
	for hash := range unmark {
		peer.known.Remove(hash)
	}
}
118738
func (c *Cache) cleanExpired() {
	for {
		c.Lock()
		if c.ttlIdx.Len() == 0 {
			c.Unlock()
			time.Sleep(c.ttl)
			continue
		}
		ci := c.ttlIdx.Back().Value.(*cachedItem)
		now := time.Now()
		if now.Before(ci.expiryTime) {
			c.Unlock()
			time.Sleep(ci.expiryTime.Sub(now))
			continue
		}
		c.remove(ci.itemID)
		c.Unlock()
	}
}
527673
func (c *asyncClient) Expire(arg0 string, arg1 int64) (result FutureBool, err Error) {
	arg0bytes := []byte(arg0)
	arg1bytes := []byte(fmt.Sprintf("%d", arg1))

	var resp *PendingResponse
	resp, err = c.conn.QueueRequest(&EXPIRE, [][]byte{arg0bytes, arg1bytes})
	if err == nil {
		result = resp.future.(FutureBool)
	}
	return result, err

}
844362
func (c *ExpireCache) Get(key interface{}) (interface{}, bool) {
	c.mutex.Lock()
	defer c.mutex.Unlock()

	record, ok := c.cache[key]
	if !ok {
		c.stats.Miss++
		return nil, ok
	}

	// Since this was recently accessed, keep it in
	// the cache by resetting the expire time
	record.ExpireAt = time.Now().UTC().Add(c.ttl)

	c.stats.Hit++
	return record.Value, ok
}
76084
func (s *storage) ExpireAfter(expireAfter time.Duration) ExpirableStorage {
	newStorage := *s
	newStorage.expireAfter = expireAfter
	return &newStorage
}
92873
func (t *TombstoneGC) PendingExpiration() bool {
	t.Lock()
	defer t.Unlock()

	return len(t.expires) > 0
}
1282338
func (cache *Cache) ExpiredCount() (count int64) {
	for i := range cache.segments {
		count += atomic.LoadInt64(&cache.segments[i].totalExpired)
	}
	return
}
1020206
func (cache *HealthStatusCache) DeleteExpired() {
	cache.mu.Lock()
	defer cache.mu.Unlock()
	for key, item := range cache.data {
		if item.Expired() {
			cache.delete(key)
		}
	}
}