function PostgreSqlStore::exists
Overrides PersistingStoreInterface::exists
2 calls to PostgreSqlStore::exists()
- PostgreSqlStore::delete in vendor/
symfony/ lock/ Store/ PostgreSqlStore.php - Removes a resource from the storage.
- PostgreSqlStore::putOffExpiration in vendor/
symfony/ lock/ Store/ PostgreSqlStore.php - Extends the TTL of a resource.
File
-
vendor/
symfony/ lock/ Store/ PostgreSqlStore.php, line 166
Class
- PostgreSqlStore
- PostgreSqlStore is a PersistingStoreInterface implementation using PostgreSql advisory locks.
Namespace
Symfony\Component\Lock\StoreCode
public function exists(Key $key) : bool {
$sql = "SELECT count(*) FROM pg_locks WHERE locktype='advisory' AND objid=:key AND pid=pg_backend_pid()";
$stmt = $this->getConnection()
->prepare($sql);
$stmt->bindValue(':key', $this->getHashedKey($key));
$stmt->execute();
if ($stmt->fetchColumn() > 0) {
// connection is locked, check for lock in internal store
return $this->getInternalStore()
->exists($key);
}
return false;
}