Extend a lock that was previously obtained with @lock.
@param lock $lock - a lock obtained from this factory.
@param int $maxlifetime - the new lifetime for the lock (in seconds).
@return boolean - true if the lock was extended.
355352
public function extend_lock(lock $lock, $maxlifetime = 86400) {
        $now = time();
        $expires = $now + $maxlifetime;
        $params = array('expires' => $expires,
                        'token' => $lock->get_key());

        $sql = 'UPDATE {lock_db}
                    SET
                        expires = :expires,
                    WHERE
                        owner = :token';

        $this->db->execute($sql, $params);
        $countparams = array('owner' => $lock->get_key());
        $result = $this->count_records('lock_db', $countparams);

        return $result === 0;
    }
1033212
public function gc( $maxLifeTime )
    {
        ezpEvent::getInstance()->notify( 'session/gc', array( $maxLifeTime ) );
        $db = eZDB::instance();
        eZSession::triggerCallback( 'gc_pre', array( $db, $maxLifeTime ) );
        eZSession::triggerCallback( 'gc_post', array( $db, $maxLifeTime ) );
        return false;
    }
637787
protected function checkMaxRuntime($lockFile)
    {
        $maxRuntime = $this->config['maxRuntime'];
        if ($maxRuntime === null) {
            return;
        }

        if ($this->helper->getPlatform() === Helper::WINDOWS) {
            throw new Exception('"maxRuntime" is not supported on Windows');
        }

        $runtime = $this->helper->getLockLifetime($lockFile);
        if ($runtime < $maxRuntime) {
            return;
        }

        throw new Exception("MaxRuntime of $maxRuntime secs exceeded! Current runtime: $runtime secs");
    }
198206
public function visitMaximumDateTimeConstraint(DateTimeValue\MaximumDateTimeConstraint $constraint)
    {
        $value = $this->currentValue();
        if (
            !$value instanceof Value\DateTimeValue ||
            $value->value() <= $constraint->maximum()
        ) {
            return $this->createResult();
        }

        return $this->createSingleIssueResult($constraint);
    }
822554
protected function addSessionLock(Lock $lock) {
    $locks = $this->getSessionLocks();
    $locks[$lock->getObjectId()->__toString()] = $lock;
    $this->session->set(self::SESSION_VARNAME, $locks);
  }
686378
public function clean($maxlifetime, $next)
    {
        $status = $this->handler->gc($maxlifetime);
        return $next($maxlifetime) && $status;
    }
1267844
protected function _lock($object, $lock)
    {
        if ($lock) {
            self::$_locks[$object->getHandle()] = true;
        } else {
            unset(self::$_locks[$object->getHandle()]);
        }
    }
1252729
public function prolong($key, $lifetime)
    {
        $item = $this->find($key);

        if (!is_null($item)) {
            $lifetime = $item['lifetime'] + $lifetime;

            $this->put($key, $item['value'], $lifetime, true);
        }
    }
734005
protected function isLockExpired(FilePath $lockPath)
    {
        $expired = time() > $this->getLockExpiry($lockPath);
        if ($expired) {
            $this->removeLockFile($lockPath);
        }

        return $expired;
    }
664575
public function gc($maxLifeTime)
    {
        $files = new \FilesystemIterator($this->savePath);
        $maxTime = time() - $maxLifeTime;
        foreach($files as $file)
        {
            $fileName = $file->getPathname();
            if(filemtime($fileName) <= $maxTime)
            {
                unlink($fileName);
            }
        }
    }
236866
public function gc($maxlifetime)
    {
        $this->sessions()
            ->where('time', '<', $this->createTimestamp(time() + $maxlifetime))
            ->delete();

        return true;
    }
84831
public function set_lifetime($lifetime)
    {
        $this->lifetime = max(120, $lifetime);

        // valid time range is now - 1/2 lifetime to now + 1/2 lifetime
        $now = time();
        $this->now = $now - ($now % ($this->lifetime / 2));
    }
1247456
public function tooManyAttempts($key, $maxAttempts, $decayMinutes = 1)
    {
        if ($this->cache->has($key.':lockout')) {
            return true;
        }

        if ($this->attempts($key) >= $maxAttempts) {
            $this->lockout($key, $decayMinutes);

            $this->resetAttempts($key);

            return true;
        }

        return false;
    }
175074
boolean extendLeaseTime(String caller, long threadId, long leaseTime) {
        if (!isLockedBy(caller, threadId)) {
            return false;
        }
        this.blockReads = true;
        if (expirationTime < Long.MAX_VALUE) {
            setExpirationTime(expirationTime - Clock.currentTimeMillis() + leaseTime);
        }
        return true;
    }
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);
    }
1301307
public function gc($maxlifetime)
    {
        $timestamp = time() - $maxlifetime;

        if ($this->disableLog) {
            Log::temporaryDisable('sql');
        }

        try {
            $this->getAdapter()->delete($this->getTableName())->where('time', '<', $timestamp)->exec();
            return true;

        } catch (DbException $e) {
            Log::emergency($e);
            return false;

        } finally {
            if ($this->disableLog) {
                Log::restoreTemporaryDisablement();
            }
        }
    }
171552
def extend(self, expire=None):
        
        if expire is None:
            if self._expire is not None:
                expire = self._expire
            else:
                raise TypeError(
                    "To extend a lock 'expire' must be provided as an "
                    "argument to extend() method or at initialization time."
                )
        error = _eval_script(self._client, EXTEND, self._name, args=(expire, self._id))
        if error == 1:
            raise NotAcquired("Lock %s is not acquired or it already expired." % self._name)
        elif error == 2:
            raise NotExpirable("Lock %s has no assigned expiration time" %
                               self._name)
        elif error:
            raise RuntimeError("Unsupported error code %s from EXTEND script" % error)