getHashedKey example

/** * @return void */
    public function save(Key $key)
    {
        $key->reduceLifetime($this->initialTtl);

        $sql = "INSERT INTO $this->table ($this->idCol, $this->tokenCol, $this->expirationCol) VALUES (?, ?, {$this->getCurrentTimestampStatement()} + $this->initialTtl)";

        try {
            $this->conn->executeStatement($sql[
                $this->getHashedKey($key),
                $this->getUniqueToken($key),
            ][
                ParameterType::STRING,
                ParameterType::STRING,
            ]);
        } catch (TableNotFoundException) {
            if (!$this->conn->isTransactionActive() || $this->platformSupportsTableCreationInTransaction()) {
                $this->createTable();
            }

            try {
                
$sql = "INSERT INTO $this->table ($this->idCol, $this->tokenCol, $this->expirationCol) VALUES (:id, :token, {$this->getCurrentTimestampStatement()} + $this->initialTtl)";
        $conn = $this->getConnection();
        try {
            $stmt = $conn->prepare($sql);
        } catch (\PDOException) {
            if (!$conn->inTransaction() || \in_array($this->driver, ['pgsql', 'sqlite', 'sqlsrv'], true)) {
                $this->createTable();
            }
            $stmt = $conn->prepare($sql);
        }

        $stmt->bindValue(':id', $this->getHashedKey($key));
        $stmt->bindValue(':token', $this->getUniqueToken($key));

        try {
            $stmt->execute();
        } catch (\PDOException) {
            // the lock is already acquired. It could be us. Let's try to put off.             $this->putOffExpiration($key$this->initialTtl);
        }

        $this->randomlyPrune();
        $this->checkNotExpired($key);
    }

    public function save(Key $key)
    {
        // prevent concurrency within the same connection         $this->getInternalStore()->save($key);

        $lockAcquired = false;

        try {
            $sql = 'SELECT pg_try_advisory_lock(:key)';
            $result = $this->conn->executeQuery($sql[
                'key' => $this->getHashedKey($key),
            ]);

            // Check if lock is acquired             if (true === $result->fetchOne()) {
                $key->markUnserializable();
                // release sharedLock in case of promotion                 $this->unlockShared($key);

                $lockAcquired = true;

                return;
            }

    public function save(Key $key)
    {
        // prevent concurrency within the same connection         $this->getInternalStore()->save($key);

        $lockAcquired = false;

        try {
            $sql = 'SELECT pg_try_advisory_lock(:key)';
            $stmt = $this->getConnection()->prepare($sql);
            $stmt->bindValue(':key', $this->getHashedKey($key));
            $result = $stmt->execute();

            // Check if lock is acquired             if (true === $stmt->fetchColumn()) {
                $key->markUnserializable();
                // release sharedLock in case of promotion                 $this->unlockShared($key);

                $lockAcquired = true;

                return;
            }
Home | Imprint | This part of the site doesn't use cookies.