Set the expiration date

@param  \DateTime|string  $expired
@return void
554999
public function setExpired($expired)
    {
        if ($expired instanceof DateTime) {
            $this->expired = $expired;
            return;
        } elseif ($expired instanceof Model) {
            $this->expired = $expired->deleted_at ?: $expired->updated_at;
            return;
        }

        $this->expired = new DateTime($expired);
    }
980064
public function setDateEnd( $date )
	{
		if ( $date == $this->getDateEnd() ) { return; }

		$this->_checkDateFormat($date);

		$this->_values['end'] = ( $date !== null ? (string) $date : null );

		$this->setModified();
	}
547489
public function setExpiry(?\DateTimeImmutable $expiry = null): void
    {
        $date = new \DateTimeImmutable();
        $expiry = $expiry ?: $date;

        $this->setHeader('Date', $date->setTimezone(new \DateTimeZone('UTC'))->format('D, d M Y H:i:s \G\M\T'));
        $this->setHeader('Expires', $expiry->setTimezone(new \DateTimeZone('UTC'))->format('D, d M Y H:i:s \G\M\T'));

        if ($expiry <= $date) {
            $this->setHeader('Cache-Control', 'no-cache, no-store, must-revalidate, max-age=0');

            return;
        }

        $maxAge = $expiry->getTimestamp() - $date->getTimestamp();
        $this->setHeader('Cache-Control', 'public, max-age=' . $maxAge);
    }
727608
public function setExpirationInterval($expiration_interval)
    {
        $allowedValues = $this->getExpirationIntervalAllowableValues();
        if (!is_null($expiration_interval) && !in_array($expiration_interval, $allowedValues, true)) {
            throw new \InvalidArgumentException(
                sprintf(
                    "Invalid value for 'expiration_interval', must be one of '%s'",
                    implode("', '", $allowedValues)
                )
            );
        }
        $this->container['expiration_interval'] = $expiration_interval;

        return $this;
    }
161546
public function setExpireDate(DateTimeInterface $dt)
    {
        $this->expire_time = (int)$dt->format('U') - time();
        return $this;
    }
573214
public function set(string $value, int $expire = 0): bool
    {
        return parent::setString($value, $expire);
    }
547239
public function set($key, $value, $expire = null)
    {
        if (null === $expire) {
            $expire = $this->_expire;
        }
        return $this->_mc->set($key, $value, 0, $expire);
    }
62759
public function redisSet($key, $value, $expiration = null)
    {
        if ($this->isSingle()) {
            RedisKit::set($key, $value, $expiration);
        }
    }
667163
public function setExpire($expire)
    {
        if (!$expire instanceof DateTime) {
            if (is_integer($expire)) {
                $expire = (new DateTime())->setTimestamp($expire);
            } else {
                $expire = new DateTime($expire);
            }
        }
        $this->expire = $expire;

        return $this;
    }
853281
public static function expire($expiredrequests) {
        global $DB;

        $ids = array_keys($expiredrequests);

        if (count($ids) > 0) {
            list($insql, $inparams) = $DB->get_in_or_equal($ids);
            $initialparams = array(api::DATAREQUEST_STATUS_EXPIRED, time());
            $params = array_merge($initialparams, $inparams);

            $update = "UPDATE {" . self::TABLE . "}
                          SET status = ?, timemodified = ?
                        WHERE id $insql";

            if ($DB->execute($update, $params)) {
                $fs = get_file_storage();

                foreach ($expiredrequests as $id => $userid) {
                    $usercontext = \context_user::instance($userid);
                    $fs->delete_area_files($usercontext->id, 'tool_dataprivacy', 'export', $id);
                }
            }
        }
    }
557815
public function setTimeExpire( $timestamp )
	{
		if( $timestamp !== null )
		{
			$timestamp = (string) $timestamp;
			$this->_checkDateFormat( $timestamp );
		}

		$this->_values['expire'] = $timestamp;
		$this->setModified();
	}
498495
public function set($key, $value, $expiration = 300) {

    	if(false === ('-' . intval($expiration) == '-' . $expiration)) {
			return trigger_error(sprintf('Argument 3 passed to %s() must be of the type integer, "%s" given', __METHOD__, gettype($expiration)), E_USER_ERROR);
		}
    	
    	$this -> call() -> set($key, $value, $expiration);
    	return $this;
    }
19342
public void setExpiry(Date expire) {
        addField(SubscribeOptionFields.expire, FormField.Type.text_single);
        setAnswer(SubscribeOptionFields.expire.getFieldName(), XmppDateTime.formatXEP0082Date(expire));
    }
1309714
protected function setValue($key, $value, $expiration = 0, $serializer = self::REDIS_SERIALIZER_NONE)
    {
        if (self::REDIS_SERIALIZER_PHP === $serializer) {
            $value = serialize($value);
        }

        return $this->redis->setex($key, $expiration, $value);
    }
885866
protected function setCache($cachename,$value,$expired=0){
        $file = $this->cachedir . $cachename . '.cache';
        $data = array(
                'value' => $value,
                'expired' => $expired ? time() + $expired : 0
        );
        return file_put_contents( $file, serialize($data) ) ? true : false;
    }
176975
public function setExpire($expire)
    {
        // 一年内认为是相对时间
        if ($expire < 31536001 && $expire != 0) {
            $expire += time();
        }

        $this->expire = $expire;
        return $this;
    }
1032496
public function set($key, $value, $expiration = 300) {

		if(false === is_string($key) && false === is_array($key)) {
   			return trigger_error(sprintf('Argument 1 passed to %s() must be of the type string or array, "%s" given', __METHOD__, gettype($key)), E_USER_ERROR);
   		}

   		if(0 === strlen($key)) {
   			return trigger_error(sprintf('Argument 1 passed to %s() may not be an empty string', __METHOD__), E_USER_ERROR);
   		}
   		
		$this -> expire($key);
		apcu_add($key, $value, $expiration);

		return $this;
	}