// setting the TTL on published records is an experimental feature.
// as such, i'm using the context to wire it through to avoid changing too
// much code along the way.
19514
func checkCtxTTL(ctx context.Context) (time.Duration, bool) {
	v := ctx.Value("ipns-publish-ttl")
	if v == nil {
		return 0, false
	}

	d, ok := v.(time.Duration)
	return d, ok
}
1261834
func (s *Server) setEtcd(key, value string, ttl uint64) {
	if _, err := s.EtcdClient.Set(key, value, ttl); err != nil {
		log.Println(err)
	}
	if s.logLevel == "debug" {
		log.Println("set", key, "->", value)
	}
}
1051628
func (c *LicenseV3) SetExpiry(t time.Time) {
	c.Metadata.SetExpiry(t)
}
1010132
func (m *Miniredis) TTL(k string) time.Duration {
	return m.DB(m.selectedDB).TTL(k)
}
1086831
func (_ENS *ENSSession) SetTTL(node [32]byte, ttl uint64) (*types.Transaction, error) {
	return _ENS.Contract.SetTTL(&_ENS.TransactOpts, node, ttl)
}
394636
func (s *GetDetectorOutput) SetFindingPublishingFrequency(v string) *GetDetectorOutput {
	s.FindingPublishingFrequency = &v
	return s
}
1365086
func (s *TestDNSAnswerInput) SetRecordType(v string) *TestDNSAnswerInput {
	s.RecordType = &v
	return s
}
1312541
func (_ENSRegistry *ENSRegistryTransactor) SetTTL(opts *bind.TransactOpts, node [32]byte, ttl uint64) (*types.Transaction, error) {
	return _ENSRegistry.contract.Transact(opts, "setTTL", node, ttl)
}
900831
func (s *PutRecordInput) SetRecord(v *Record) *PutRecordInput {
	s.Record = v
	return s
}
229051
func WithTTL(t time.Duration) Option {
	return func(o *Options) {
		o.TTL = t
	}
}
1305433
func SetPublishKey(publishKey string) RequestFunc {
	return func(ctx context.Context, pub *amqp.Publishing, _ *amqp.Delivery) context.Context {
		return context.WithValue(ctx, ContextKeyPublishKey, publishKey)
	}
}
1297971
func TTL(d time.Duration) Option {
	return func(c Cache) error {
		switch oc := c.(type) {
		case *cache:
			oc.ttl = d
			return nil
		default:
			return errors.New(ErrIllegalCache, errorMessages)
		}
	}
}
350199
func (s *CreateBranchInput) SetTtl(v string) *CreateBranchInput {
	s.Ttl = &v
	return s
}
408344
func (c *Cache) setTTL(r services.Resource) {
	if c.OnlyRecent.Enabled || (c.PreferRecent.Enabled && c.PreferRecent.NeverExpires) {
		return
	}
	// honor expiry set in the resource
	if !r.Expiry().IsZero() {
		return
	}
	// set max TTL on the resources
	r.SetTTL(c.Clock, c.PreferRecent.MaxTTL)
}
1206310
func (r *Service) TTL(key string) (seconds int64, hasExpiration bool, found bool) {
	c := r.pool.Get()
	defer c.Close()
	redisVal, err := c.Do("TTL", r.Config.Prefix+key)
	if err != nil {
		return -2, false, false
	}
	seconds = redisVal.(int64)
	// if -1 means the key has unlimited life time.
	hasExpiration = seconds > -1
	// if -2 means key does not exist.
	found = !(c.Err() != nil || seconds == -2)
	return
}
853847
func (b *RawElementData) SetRecorded(value interface{}) {
	b.recorded = value
	b.recordedSet = true
}
443928
func (e *Eurekache) SetExpire(key string, data interface{}, ttl int64) {
	ch := make(chan bool, 1)
	// set cache
	go func() {
		for _, c := range e.caches {
			c.SetExpire(key, data, ttl)
		}
		ch <- true
	}()

	// set cache or timeout
	select {
	case <-ch:
		return
	case <-time.After(e.writeTimeout):
		return
	}
}