// Add adds specified value to TTL with the specified timeout. Returns an id
// under which the item was stored.
Add adds specified value to TTL with the specified timeout. Returns an id
under which the item was stored.
// Add adds specified value to TTL with the specified timeout . Returns an id // under which the item was stored .
func (ttl *TTL) Add(value interface{}, timeout time.Duration) (id ItemID) {
	ttl.mu.Lock()
	ttl.nextid++
	id = ttl.nextid
	p := &Item{
		id:        id,
		timeoutAt: time.Now().Add(timeout),
		Value:     value,
	}
	ttl.ids[id] = p
	ttl.add(p)
	if !ttl.running {
		go func() {
			go ttl.timerFunc()
			ttl.resetchan <- struct{}{}
		}()
	}
	ttl.mu.Unlock()
	return
}
func ( ttl * TTL ) Add ( value interface { } , timeout time . Duration ) ( id ItemID ) { ttl . mu . Lock ( ) ttl . nextid ++ id = ttl . nextid p := & Item { id : id , timeoutAt : time . Now ( ) . Add ( timeout ) , Value : value , } ttl . ids [ id ] = p ttl . add ( p ) if ! ttl . running { go func ( ) { go ttl . timerFunc ( ) ttl . resetchan <- struct { } { } } ( ) } ttl . mu . Unlock ( ) return }
Add adds specified value to TTL with the specified timeout.
Add adds specified value to TTL with the specified timeout .