// NewShardedCacheWithTTL creates a sharded cache system with TTL based on specified Cache constructor
// Which everytime will return the true values about a cache hit
// and never will leak memory
// ttl is used for expiration of a key from cache
493159
func NewShardedCacheWithTTL(ttl time.Duration, f func() Cache) *ShardedTTL {
	return &ShardedTTL{
		cache:  NewShardedNoTS(f),
		setAts: map[string]map[string]time.Time{},
		ttl:    ttl,
	}
}
294459
func (c *CachePolicy) GetRecentTTL() time.Duration {
	if c.RecentTTL == nil {
		return defaults.RecentCacheTTL
	}
	return *c.RecentTTL
}
534046
func (t *Task) SetTTL(ttl time.Duration) *Task {
	t.ttl = ttl
	return t
}
841733
func (m *BaseShardManager) GetShard(
	key string) (
	shardId int,
	conn net2.ManagedConn,
	err error) {

	m.rwMutex.RLock()
	defer m.rwMutex.RUnlock()

	shardId = m.getShardId(key, len(m.shardStates))
	if shardId == -1 {
		return
	}

	state := m.shardStates[shardId]
	if state.State != ActiveServer {
		m.logInfo("Memcache shard ", shardId, " is not in active state.")
		connSkippedByAddr.Add(state.Address, 1)
		return
	}

	entry := &ShardMapping{}
	m.fillEntryWithConnection(state.Address, entry)
	conn, err = entry.Connection, entry.ConnErr

	return
}
633440
func (r *GoRedisStore) SetIfNotExistsWithTTL(key string, value int64, ttl time.Duration) (bool, error) {
	key = r.prefix + key

	updated, err := r.client.SetNX(key, value, 0).Result()
	if err != nil {
		return false, err
	}

	ttlSeconds := time.Duration(ttl.Seconds())

	// An `EXPIRE 0` will delete the key immediately, so make sure that we set
	// expiry for a minimum of one second out so that our results stay in the
	// store.
	if ttlSeconds < 1 {
		ttlSeconds = 1
	}

	err = r.client.Expire(key, ttlSeconds*time.Second).Err()
	return updated, err
}
513694
func (s *ResourceRecordSet) SetTTL(v int64) *ResourceRecordSet {
	s.TTL = &v
	return s
}
1135842
func (l *Limiter) SetHeaderEntryExpirationTTL(ttl time.Duration) *Limiter {
	l.Lock()
	l.headerEntryExpirationTTL = ttl
	l.Unlock()

	return l
}
255766
func (s *IndexService) Ttl(ttl string) *IndexService {
	s.ttl = ttl
	return s
}
1039573
func (cache *DiskBlockCacheLocal) getMetadataLocked(
	blockID kbfsblock.ID, metered bool) (
	metadata DiskBlockCacheMetadata, err error) {
	var hitMeter, missMeter *CountMeter
	if metered {
		hitMeter = cache.hitMeter
		missMeter = cache.missMeter
	}

	metadataBytes, err := cache.metaDb.GetWithMeter(
		blockID.Bytes(), hitMeter, missMeter)
	if err != nil {
		return DiskBlockCacheMetadata{}, err
	}
	err = cache.config.Codec().Decode(metadataBytes, &metadata)
	return metadata, err
}
1093310
func (l *lru) CacheTTL(taskID string) (time.Duration, error) {
	return l.ttl, nil
}
213225
func (c *EtcdGroupService) GroupCreateWithTTL(ctx context.Context, groupName string, ttlTime time.Duration) error {
	ctxT, cancel := context.WithTimeout(ctx, transactionTimeout)
	defer cancel()
	lease, err := clientInstance.Grant(ctxT, int64(ttlTime.Seconds()))
	if err != nil {
		return err
	}
	return c.createGroup(ctx, groupName, lease.ID)
}
907414
func (r *RedigoStore) SetIfNotExistsWithTTL(key string, value int64, ttl time.Duration) (bool, error) {
	key = r.prefix + key

	conn, err := r.getConn()
	if err != nil {
		return false, err
	}
	defer conn.Close()

	v, err := redis.Int64(conn.Do("SETNX", key, value))
	if err != nil {
		return false, err
	}

	updated := v == 1

	ttlSeconds := int(ttl.Seconds())

	// An `EXPIRE 0` will delete the key immediately, so make sure that we set
	// expiry for a minimum of one second out so that our results stay in the
	// store.
	if ttlSeconds < 1 {
		ttlSeconds = 1
	}

	if _, err := conn.Do("EXPIRE", key, ttlSeconds); err != nil {
		return updated, err
	}

	return updated, nil
}
323570
func (s *IndexService) TTL(ttl string) *IndexService {
	s.ttl = ttl
	return s
}
1101047
func (db *RedisDB) TTL(k string) time.Duration {
	db.master.Lock()
	defer db.master.Unlock()
	return db.ttl[k]
}
1291397
func (s *sticky) CacheHits(ns string, version int, taskID string) (uint64, error) {
	if cache, ok := s.metricCache[taskID]; ok {
		return cache.cacheHits(ns, version)
	}
	return 0, ErrCacheDoesNotExist
}
840892
func NewMemoryWithTTL(ttl time.Duration) *MemoryTTL {
	return &MemoryTTL{
		cache:  NewMemoryNoTS(),
		setAts: map[string]time.Time{},
		ttl:    ttl,
	}
}
915805
func (s *DnsRecord) SetTTL(v int64) *DnsRecord {
	s.TTL = &v
	return s
}