Compute and return the lifetime for the fast backend

@param int $lifetime original lifetime
@param int $priority priority
@param int $maxLifetime maximum lifetime
@return int lifetime for the fast backend
425308
private function _getFastLifetime($lifetime, $priority, $maxLifetime = null)
    {
        if ($lifetime <= 0) {
            // if no lifetime, we have an infinite lifetime
            // we need to use arbitrary lifetimes
            $fastLifetime = (int) (2592000 / (11 - $priority));
        } else {
            // prevent computed infinite lifetime (0) by ceil
            $fastLifetime = (int) ceil($lifetime / (11 - $priority));
        }

        if ($maxLifetime >= 0 && $fastLifetime > $maxLifetime) {
            return $maxLifetime;
        }

        return $fastLifetime;
    }
381337
public function getLifetime($regionName)
    {
        return isset($this->lifetimes[$regionName])
            ? $this->lifetimes[$regionName]
            : $this->defaultLifetime;
    }
1266457
public function gc($maxlifetime)
    {
        if (!$this->shouldGC()) return false;

        $cutOff = new \DateTime();
        $cutOff->modify('-' . $maxlifetime . ' seconds');

        try {
            $sessionSQL = sprintf(
                'delete from `%s`.`%s` where `activity` <= ?',
                $this->database,
                $this->table
            );

            $statement = $this->databaseResource->prepare($sessionSQL);

            if (empty($statement)) {
                throw new \Exception("Could not prepare session gc statement.");
            }

            $cutOffTimestamp = $cutOff->format('Y-m-d H:i:s');
            $statement->bind_param('s', $cutOffTimestamp);

            $statement->execute();

            $statement->close();

            return true;
        } catch (\Exception $exception) {
            // Log and return false
        }

        return false;
    }
1039896
public function withPriority($priority)
    {
        Assertion::float($priority);
        Assertion::greaterOrEqualThan($priority, UrlInterface::PRIORITY_MIN);
        Assertion::lessOrEqualThan($priority, UrlInterface::PRIORITY_MAX);
        Assertion::same($priority, \round($priority, 1));

        $instance = clone $this;

        $instance->priority = $priority;

        return $instance;
    }
704163
public function getCacheLifetime()
    {
        $lifetime = $this->getContainer('config')->get('rinvex.repository.cache.lifetime');

        // Return value even if it's zero "0" (which means cache is disabled)
        return ! is_null($this->cacheLifetime) ? $this->cacheLifetime : $lifetime;
    }
882627
public function priority($priority, $retryTimeout = null, $expireAfter = null)
    {
        $this->noEmergencyWithoutRetryOrExpire($priority, $retryTimeout, $expireAfter);

        $this->priority = $priority;
        $this->retry = $retryTimeout;
        $this->expire = $expireAfter;

        return $this;
    }
1120359
public function gc($lifetime){
        //si la sesión está abierta y tengo lock 
        if($this->opened){
            $fecha= new \DateTime();
            $sql= $this->connection->connection->prepare('DELETE FROM sessions WHERE session_expiration < :fecha');
            $sql->bindValue('fecha', $fecha->format('Y-m-d H:i:s'));
            return $sql->execute() === TRUE;
        }   
        else{
            return FALSE;
        }
    }
456679
public static function init($lifeTime = 0)
    {
        if (self::$sessionStarted == false) {
            session_set_cookie_params($lifeTime);
            session_start();

            return self::$sessionStarted = true;
        }

        return false;
    }
998081
public function clean( $maxlifetime, $next ) {
		global $wpdb;

		// Session is expired if now - item.time > maxlifetime
		// Said another way, if  item.time < now - maxlifetime
		$filter = intval( time() - $maxlifetime );
		$keys   = $wpdb->get_results( "SELECT option_name, option_value FROM $wpdb->options WHERE option_name LIKE '_wp_session_expires_%' AND option_value > $filter ORDER BY option_value LIMIT 0, 1000" );

		foreach ( $keys as $expiration ) {
			$key        = $expiration->option_name;
			$session_id = $this->sanitize( substr( $key, 20 ) );

			$this->_delete( $session_id );
		}

		return $next( $maxlifetime );
	}
1009097
public function gc($maxlifetime = null)
    {
        $result = false;

        if ($this->getTable()->isConnected())
        {
            $query = $this->getObject('lib:database.query.select')
                ->where('time < :time')
                ->bind(array('time' => (int)(time() - $maxlifetime)));

            $result = $this->_table->select($query, KDatabase::FETCH_ROWSET)->delete();
        }

        return $result;
    }
1242219
public function gc($maxLifetime)
    {
        try {
            return (bool) $this->db->from($this->table)
                    ->where($this->columns['expires'])->lt(time())
                    ->delete();
        } catch (PDOException $e) {
            return false;
        }
    }
651777
public function gc($maxlifetime)
    {
        $platform = $this->tableGateway->getAdapter()->getPlatform();

        $where = new Where();
        $where->lessThan(
            $this->options->getModifiedColumn(),
            new Expression('(' . time() . ' - ' . $platform->quoteIdentifier($this->options->getLifetimeColumn()) . ')')
        );

        $rows = $this->tableGateway->select($where);

        $ids = [];

        /* @var \UthandoSessionManager\Model\SessionModel $row */
        foreach ($rows as $row) {
            $ids[] = $row->{$this->options->getIdColumn()};
        }

        if (count($ids) > 0) {
            $where = new Where();
            $result = (bool) $this->tableGateway->delete(
                $where->in($this->options->getIdColumn(), $ids)
            );
        } else {
            $result = false;
        }

        return $result;
    }
1241228
public function clean($maxlifetime, $next)
    {
        $this->cache = array_filter($this->cache, function($item) use ($maxlifetime) {
            /** @var MemoryItem $item */
            return $item->is_valid($maxlifetime);
        });

        return $next($maxlifetime);
    }
720802
public function isValidLocationPriority($priority)
    {
        if ($priority === null) {
            return true;
        }

        return is_int($priority) && $priority >= self::MIN_LOCATION_PRIORITY && $priority <= self::MAX_LOCATION_PRIORITY;
    }
1186261
protected function resolveCacheLifetime($lifetime): DateTime
    {
        if ($lifetime instanceof DateTime) {
            return $lifetime;
        }

        if (is_int($lifetime)) {
            return Carbon::now()->addMinutes($lifetime);
        }
    }
403801
public function gc($lifeTime) {
        // search the entities that need to be deleted.
        $filter = 'PartitionKey eq\'' . $this->_sessionContainerPartition . '\' and expires lt ' . (time() - $lifeTime);
        try {
            $result = $this->_tableRestProxy->queryEntities($this->_sessionContainer, $filter);
            $entities = $result->getEntities();
            foreach ($entities as $entitiy) {
                $this->_tableRestProxy->deleteEntity($this->_sessionContainer, $this->_sessionContainerParition, $entity->getRowKey());
            }
            return TRUE;
        } catch (ServiceException $e) {
            return FALSE;
        }
    }
1008912
public function gc(int $maxLifeTime, string $sessionId = '')
    {
        if ($sessionId) {
            $file = "{$this->savePath}/{$this->sessionName}_{$sessionId}";
            if (file_exists($file) && (filemtime($file) + $maxLifeTime < time())) {
                unlink($file);
            }
            return true;
        }

        foreach (glob("{$this->savePath}/{$this->sessionName}_*") as $file) {
            if (file_exists($file) && (filemtime($file) + $maxLifeTime < time())) {
                unlink($file);
            }
        }

        return true;
    }