// AddWithExpire stores a key value pair in the cache. If the key was already present,
// it is moved to the front.  Additionally, the given expiration time is used (overriding the
// default ttl).
13517
func (lru *TTLRUCache) AddWithExpire(key, val interface{}, expiration time.Time) {
	lru.lock.Lock()
	defer lru.lock.Unlock()

	if etriple, ok := lru.mapping[key]; ok {
		etriple.val = val
		lru.order.MoveToFront(&etriple.orderelement)
		lru.timeorder.MoveToBack(&etriple.timeelement)
		etriple.expiration = expiration
		return
	}

	etriple := lru.triplePool.Get().(*triple)
	etriple.key = key
	etriple.val = val
	etriple.expiration = expiration
	etriple.orderelement.Value = etriple
	etriple.timeelement.Value = etriple
	lru.order.MoveToFront(&etriple.orderelement)
	lru.timeorder.MoveToBack(&etriple.timeelement)
	lru.mapping[key] = etriple

	for lru.order.Len() > lru.capacity {
		element := lru.order.Back()
		etriple := element.Value.(*triple)
		lru.order.Remove(element)
		lru.timeorder.Remove(&etriple.timeelement)
		delete(lru.mapping, etriple.key)
		lru.triplePool.Put(etriple)
	}
}
498718
func (n *Namespace) SetExpiry(expires time.Time) {
	n.Metadata.SetExpiry(expires)
}
732739
func (s *CreateApiKeyInput) SetExpires(v int64) *CreateApiKeyInput {
	s.Expires = &v
	return s
}
1057991
func Expiry(clock clockwork.Clock, ttl time.Duration) time.Time {
	if ttl == 0 {
		return time.Time{}
	}
	return clock.Now().UTC().Add(ttl)
}
517263
func (s *CopyObjectInput) SetExpires(v time.Time) *CopyObjectInput {
	s.Expires = &v
	return s
}
1237031
func (s *HeadObjectOutput) SetExpires(v string) *HeadObjectOutput {
	s.Expires = &v
	return s
}
1262345
func (v *vaultClient) extendExpiration(ttlSeconds int) {
	v.currentExpirationLock.Lock()
	v.currentExpiration = time.Now().Add(time.Duration(ttlSeconds) * time.Second)
	v.currentExpirationLock.Unlock()
}
1022079
func (r *RedisStorer) ResetExpiry(key string) error {
	return r.client.Expire(key, r.maxAge).Err()
}
1129095
func (c *LRUExpireCache) Add(key interface{}, value interface{}, ttl time.Duration) {
	c.lock.Lock()
	defer c.lock.Unlock()
	c.cache.Add(key, &cacheEntry{value, c.clock.Now().Add(ttl)})
}
884475
func (i *Item) SetExpire(ttl int64) {
	if ttl == 0 {
		return
	}
	i.ExpiredAt = i.CreatedAt + ttl*int64(time.Millisecond)
}
443656
func (c *ExpireCache) Add(key interface{}, value interface{}) {
	c.mutex.Lock()
	defer c.mutex.Unlock()

	record := expireRecord{
		Value:    value,
		ExpireAt: time.Now().UTC().Add(c.ttl),
	}
	// Add the record to the cache
	c.cache[key] = &record
}
289733
func (c *RedisCacher) Put(key string, val interface{}, expire int64) error {
	key = c.prefix + key
	if expire == 0 {
		if err := c.c.Set(key, com.ToStr(val)).Err(); err != nil {
			return err
		}
	} else {
		dur, err := time.ParseDuration(com.ToStr(expire) + "s")
		if err != nil {
			return err
		}
		if err = c.c.SetEx(key, dur, com.ToStr(val)).Err(); err != nil {
			return err
		}
	}

	if c.occupyMode {
		return nil
	}
	return c.c.HSet(c.hsetName, key, "0").Err()
}
337138
func (d *Delay) GetExpiration(key string) time.Time {
	d.lock.RLock()
	expires := d.delay[key]
	d.lock.RUnlock()
	return expires
}
139946
func (s *DomainSummary) SetExpiry(v time.Time) *DomainSummary {
	s.Expiry = &v
	return s
}
1013334
func (s *CreateStreamingURLOutput) SetExpires(v time.Time) *CreateStreamingURLOutput {
	s.Expires = &v
	return s
}
831186
func (c *cookies) Expire(key string, expire time.Time) {
	ck := c.Get(key)
	if ck != nil {
		ck.Expires = expire
		ck.MaxAge = int(expire.Sub(time.Now()).Seconds())
		c.Set(ck)
	}
}
1208968
func (cache *Cache) GetIntWithExpiration(key int64) (value []byte, expireAt uint32, err error) {
	var bKey [8]byte
	binary.LittleEndian.PutUint64(bKey[:], uint64(key))
	return cache.GetWithExpiration(bKey[:])
}