Sets the expire date time.

@param \DateTime $expire

@return \BackBee\Cache\DAO\Entity
@codeCoverageIgnore
965629
public function setExpire(\DateTime $expire = null)
    {
        $this->_expire = ($expire) ? $expire : null;

        return $this;
    }
1269041
public function setExpiresOn($date)
    {
        $date = AnDomainAttributeDate::getInstance()->setDate($date);
        $this->set('expiresOn', $date);
    }
1363189
function setCache($cache,$expire=3600)
	{
		$this->cache = $cache;
		$this->if_cache = true;
		$this->expire = $expire;
	}
424285
public function withExpires(DateTime $datetime)
    {
        $datetime->setTimezone(new DateTimeZone('UTC'));

        return $this->withHeader('Expires', $datetime->format('D, d M Y H:i:s') . ' GMT');
    }
923031
private function expirationToDateTime($expires): DateTimeInterface
    {
        if ($expires instanceof DateTimeImmutable) {
            return $expires;
        }

        if ($expires instanceof DateInterval) {
            $expires = (new DateTime)->add($expires);
        } elseif (is_string($expires) || is_int($expires)) {
            $expires = new DateTime(is_numeric($expires) ? '@' . $expires : $expires);
        }

        if (!$expires instanceof DateTimeInterface) {
            throw new InvalidArgumentException(
                'Invalid cookie expiration time. Cannot be converted to DateTimeInterface.'
            );
        }

        return new DateTimeImmutable($expires->format(DateTime::ISO8601), $expires->getTimezone());
    }
1088702
public function set($key, $value, $expire = NULL) {
    $key = $this->createkey($key);
    if (!$this->lockBackend->acquire($key)) {
      $this->lockBackend->wait($key);
      if (!$this->lockBackend->acquire($key)) {
        throw new TempStoreException("Couldn't acquire lock to update item '$key' in '{$this->storage->getCollectionName()}' temporary storage.");
      }
    }

    $value = (object) [
      'owner' => $this->getOwner(),
      'data' => $value,
      'updated' => (int) $this->requestStack->getMasterRequest()->server->get('REQUEST_TIME'),
    ];

    // Fallback to the default expire.
    if (empty($expire)) {
      $expire = $this->expire;
    }

    $this->storage->setWithExpire($key, $value, $expire);
    $this->lockBackend->release($key);
  }
911813
public function put($key, $value, $expire = null)
    {
        return call_user_func_array("set{$this->getPrefix()}_transient", [
            $key,
            $value,
            $expire ?: $this->getDefault('expire'),
        ]);
    }
1247210
public function setDate(\DateTime $date): self
    {
        $date->setTimezone(new \DateTimeZone('UTC'));
        $this->header->set('Date', $date->format('D, d M Y H:i:s') . ' GMT');

        return $this;
    }
328757
public function set(int $value, int $expire = 0): bool
    {
        return parent::setString(strval($value), $expire);
    }
489211
public function expireAfter($key, $expire = 0)
    {
        $val = $this->mem->get($key);

        if (isset($val)) {
            return $this->set($key, $val, $expire);
        }

        return false;
    }
197428
public function set($entityId, $id, \DateTime $expiryTime) {
        $idEntry = $this->manager->find(IdEntity::class, ['entityId' => $entityId, 'id' => $id]);
        if (null == $idEntry) {
            $idEntry = new IdEntity();
        }
        $idEntry->setEntityId($entityId)
            ->setId($id)
            ->setExpiry($expiryTime);
        $this->manager->persist($idEntry);
        $this->manager->flush();
    }
161546
public function setExpireDate(DateTimeInterface $dt)
    {
        $this->expire_time = (int)$dt->format('U') - time();
        return $this;
    }
870140
public function setExpires($date): void
    {
        if ($date instanceof \DateTime) {
            $date = clone $date;
        } else {
            $date = new \DateTime($date);
        }

        $date->setTimezone(new \DateTimeZone('UTC'));
        $this->response->setHeader('Expires', $date->format('D, d M Y H:i:s') . ' GMT');
    }
927450
protected function getExpireTime($expire)
    {
        if ($expire instanceof \DateTime) {
            $expire = $expire->getTimestamp() - time();
        }

        return (int) $expire;
    }
983231
public function openCache($expire = 3600) {
        $this->allowCache = $expire !== false;
        $this->cacheLife = $expire;
        return $this;
    }
1314341
public function setExpirationYear($expirationYear)
    {
        if ($expirationYear !== null) {
            $expirationYear = $expirationYear < 100 ? 2000 + $expirationYear : $expirationYear;
        }
        $this->expirationYear = $expirationYear;

        return $this;
    }
25207
public function set($key, $val, $expire = 0)
    {
        return $this->mem->set($key, $val, $expire);
    }