// update expire time
771978
func (r *RedisCache) Touch(key string, expire int64) (err error) {
	if _, err = r.do("EXPIRE", key, expire); err != nil {
		return
	}

	if r.occupyMode {
		return
	}

	_, err = r.do("HSET", r.key(GC_HASH_KEY), r.key(key), (time.Now().Unix() + expire))

	return nil
}
485661
func (s *Simple) update(key string, atv *atomicTimedValue) *TimedValue {
	value, err := s.config.Lookup(key)
	if err == nil {
		tv := newTimedValue(value, nil, s.config.GoodStaleDuration, s.config.GoodExpiryDuration)
		atv.av.Store(tv)
		return tv
	}

	// lookup gave us an error
	atomic.AddInt64(&s.stats.LookupErrors, 1)
	staleDuration := s.config.BadStaleDuration
	expiryDuration := s.config.BadExpiryDuration

	// new error overwrites previous error, and also used when initial value
	av := atv.av.Load()
	if av == nil || av.(*TimedValue).Err != nil {
		tv := newTimedValue(value, err, staleDuration, expiryDuration)
		atv.av.Store(tv)
		return tv
	}

	// received error this time, but still have old value, and we only replace a
	// good value with an error if the good value has expired
	tv := av.(*TimedValue)
	if tv.IsExpired() {
		tv = newTimedValue(value, err, staleDuration, expiryDuration)
		atv.av.Store(tv)
	}
	return tv
}
189464
func Update(ca *x509.Certificate, priv crypto.Signer) (cert []byte, err error) {
	copy, err := x509.ParseCertificate(ca.Raw)
	if err != nil {
		return
	}

	validity := ca.NotAfter.Sub(ca.NotBefore)
	copy.NotBefore = time.Now().Round(time.Minute).Add(-5 * time.Minute)
	copy.NotAfter = copy.NotBefore.Add(validity)
	cert, err = x509.CreateCertificate(rand.Reader, copy, copy, priv.Public(), priv)
	if err != nil {
		return
	}

	cert = pem.EncodeToMemory(&pem.Block{Type: "CERTIFICATE", Bytes: cert})
	return
}
1155840
func (peer *Peer) update() {
	// Start the tickers for the updates
	expire := time.NewTicker(expirationCycle)
	transmit := time.NewTicker(transmissionCycle)

	// Loop and transmit until termination is requested
	for {
		select {
		case <-expire.C:
			peer.expire()

		case <-transmit.C:
			if err := peer.broadcast(); err != nil {
				log.Trace("broadcast failed", "reason", err, "peer", peer.ID())
				return
			}

		case <-peer.quit:
			return
		}
	}
}
637026
func Update(id string, params *stripe.DisputeParams) (*stripe.Dispute, error) {
	return getC().Update(id, params)
}
860395
func (c *Certificate) SetExpireDate(when time.Duration) error {
	offset := C.long(when / time.Second)
	result := C.X509_gmtime_adj(C.X_X509_get0_notAfter(c.x), offset)
	if result == nil {
		return errors.New("failed to set expire date")
	}
	return nil
}
1237579
func (s *Sessions) UpdateExpirationFasthttp(ctx *fasthttp.RequestCtx, expires time.Duration) error {
	cookieValue := s.decodeCookieValue(GetCookieFasthttp(ctx, s.config.Cookie))
	if cookieValue == "" {
		return ErrNotFound
	}

	// we should also allow it to expire when the browser closed
	err := s.provider.UpdateExpiration(cookieValue, expires)
	if err == nil || expires == -1 {
		s.updateCookieFasthttp(ctx, cookieValue, expires)
	}

	return err
}
1180419
func UpdateExpirationFasthttp(ctx *fasthttp.RequestCtx, expires time.Duration) {
	Default.UpdateExpirationFasthttp(ctx, expires)
}
499027
func (u *Updater) Update(ctx Context) (*Update, error) {
	options := ctx.UpdateOptions()
	update, err := u.update(ctx, options)
	report(ctx, err, update, options)
	return update, err
}
613115
func (su *StatusUpdater) Update(status interface{}) {
	su.Status = status.(string)

	// initialize event ID
	if su.EventID == 0 {
		su.EventID = time.Now().UnixNano()
	}
}
1121653
func (c *Credentials) Expire() {
	c.Lock()
	defer c.Unlock()

	c.forceRefresh = true
}
1202655
func (ema *ExponentialMovingAverage) Update(value float64) float64 {
	now := time.Now()
	a := 1.0 - math.Exp(ema.t.Sub(now).Seconds()/ema.period)
	v := a*value + (1.0-a)*ema.v

	ema.mu.Lock()
	ema.v = v
	ema.t = now
	ema.mu.Unlock()

	return v
}
877277
func (b *Timeout) Update(ok bool) {
	if ok {
		b.errs = 0
		b.current = b.Resync
		return
	}

	b.errs++
	if b.errs == 1 {
		b.current = b.InitialRetry
		return
	}

	b.current *= 2
	if b.current >= b.MaxBackoff {
		b.current = b.MaxBackoff
	}
}
853386
func (r *Redis) SetExpired(key string, value interface{}, expire time.Duration) {
	// log.DebugWithFields(log.Fields{"key": key, "value": value, "expireTime": expire}, "set to cache")

	var buf bytes.Buffer // Stand-in for a network connection
	if err := gob.NewEncoder(&buf).Encode(value); err != nil {
		panic(err)
	}
	conn := r.GetConn()
	defer conn.Close()

	if int64(expire.Seconds()) > int64(0) {
		_, err := conn.Do("SET", key, buf.Bytes(), "EX", int64(expire.Seconds()))
		errors.Panic(err)
	} else {
		_, err := conn.Do("SET", key, buf.Bytes())
		errors.Panic(err)
	}
}
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)
	}
}
1169373
func Update(db DB, table string, src interface{}) error {
	return Default.Update(db, table, src)
}
483353
func (db *Database) OnUpdateExpiration(sid string, newExpires time.Duration) error {
	expirationTime := time.Now().Add(newExpires)
	timeBytes, err := sessions.DefaultTranscoder.Marshal(expirationTime)
	if err != nil {
		return err
	}

	return db.Service.Update(func(tx *bolt.Tx) error {
		expirationName := getExpirationBucketName([]byte(sid))
		root := db.getBucket(tx)
		b := root.Bucket(expirationName)
		if b == nil {
			// golog.Debugf("tried to reset the expiration value for '%s' while its configured lifetime is unlimited or the session is already expired and not found now", sid)
			return sessions.ErrNotFound
		}

		return b.Put(expirationKey, timeBytes)
	})
}