-
-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
23 changed files
with
864 additions
and
308 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
25 changes: 25 additions & 0 deletions
25
src/Internal/Doctrine/CachePreparedStatementsConnection.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Loupe\Loupe\Internal\Doctrine; | ||
|
||
use Doctrine\DBAL\Driver\Middleware\AbstractConnectionMiddleware; | ||
use Doctrine\DBAL\Driver\Statement; | ||
|
||
final class CachePreparedStatementsConnection extends AbstractConnectionMiddleware | ||
{ | ||
/** | ||
* @var array<string, Statement> | ||
*/ | ||
private array $cachedStatements = []; | ||
|
||
public function prepare(string $sql): Statement | ||
{ | ||
if (isset($this->cachedStatements[$sql])) { | ||
return $this->cachedStatements[$sql]; | ||
} | ||
|
||
return $this->cachedStatements[$sql] = parent::prepare($sql); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Loupe\Loupe\Internal\Doctrine; | ||
|
||
use Doctrine\DBAL\Driver\Connection as DriverConnection; | ||
use Doctrine\DBAL\Driver\Middleware\AbstractDriverMiddleware; | ||
|
||
final class CachePreparedStatementsDriver extends AbstractDriverMiddleware | ||
{ | ||
public function connect( | ||
#[\SensitiveParameter] | ||
array $params, | ||
): DriverConnection { | ||
return new CachePreparedStatementsConnection( | ||
parent::connect($params), | ||
); | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
src/Internal/Doctrine/CachePreparedStatementsMiddleware.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Loupe\Loupe\Internal\Doctrine; | ||
|
||
use Doctrine\DBAL\Driver as DriverInterface; | ||
use Doctrine\DBAL\Driver\Middleware as MiddlewareInterface; | ||
|
||
class CachePreparedStatementsMiddleware implements MiddlewareInterface | ||
{ | ||
public function wrap(DriverInterface $driver): DriverInterface | ||
{ | ||
return new CachePreparedStatementsDriver($driver); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.