// Reset resets the timeout for an item with the specified id. Returns truth
// if the item with the specified id was found and was reset.
Reset resets the timeout for an item with the specified id. Returns truth
if the item with the specified id was found and was reset.
// Reset resets the timeout for an item with the specified id . Returns truth // if the item with the specified id was found and was reset .
func (ttl *TTL) Reset(id ItemID, timeout time.Duration) (ok bool) {
	ttl.mu.Lock()
	item, exists := ttl.ids[id]
	if !exists {
		ttl.mu.Unlock()
		return false
	}
	if _, removed := ttl.remove(id); !removed {
		panic("mapped item not in list")
	}
	item.timeoutAt = time.Now().Add(timeout)
	ttl.add(item)
	ttl.ids[item.id] = item
	if !ttl.running {
		go func() {
			go ttl.timerFunc()
			ttl.resetchan <- struct{}{}
		}()
	}
	ttl.mu.Unlock()
	return true
}
func ( ttl * TTL ) Reset ( id ItemID , timeout time . Duration ) ( ok bool ) { ttl . mu . Lock ( ) item , exists := ttl . ids [ id ] if ! exists { ttl . mu . Unlock ( ) return false } if _ , removed := ttl . remove ( id ) ; ! removed { panic ( " " ) } item . timeoutAt = time . Now ( ) . Add ( timeout ) ttl . add ( item ) ttl . ids [ item . id ] = item if ! ttl . running { go func ( ) { go ttl . timerFunc ( ) ttl . resetchan <- struct { } { } } ( ) } ttl . mu . Unlock ( ) return true }
Reset resets the timeout for an item with the specified id.
Reset resets the timeout for an item with the specified id .