Use the Index DbStatementCache implementation.
This commit is contained in:
parent
baefea88df
commit
42d893fc18
8 changed files with 7 additions and 47 deletions
|
@ -3,10 +3,10 @@ namespace Misuzu\AuditLog;
|
|||
|
||||
use InvalidArgumentException;
|
||||
use RuntimeException;
|
||||
use Index\Data\DbStatementCache;
|
||||
use Index\Data\IDbConnection;
|
||||
use Index\Data\IDbResult;
|
||||
use Index\Net\IPAddress;
|
||||
use Misuzu\DbStatementCache;
|
||||
use Misuzu\Pagination;
|
||||
use Misuzu\Users\User;
|
||||
|
||||
|
|
|
@ -4,10 +4,10 @@ namespace Misuzu\Changelog;
|
|||
use InvalidArgumentException;
|
||||
use RuntimeException;
|
||||
use Index\DateTime;
|
||||
use Index\Data\DbStatementCache;
|
||||
use Index\Data\DbTools;
|
||||
use Index\Data\IDbConnection;
|
||||
use Index\Data\IDbResult;
|
||||
use Misuzu\DbStatementCache;
|
||||
use Misuzu\Pagination;
|
||||
use Misuzu\Users\User;
|
||||
|
||||
|
|
|
@ -3,9 +3,9 @@ namespace Misuzu\Comments;
|
|||
|
||||
use InvalidArgumentException;
|
||||
use RuntimeException;
|
||||
use Index\Data\DbStatementCache;
|
||||
use Index\Data\IDbConnection;
|
||||
use Index\Data\IDbResult;
|
||||
use Misuzu\DbStatementCache;
|
||||
use Misuzu\Pagination;
|
||||
use Misuzu\Users\User;
|
||||
|
||||
|
|
|
@ -4,11 +4,11 @@ namespace Misuzu\Config;
|
|||
use RuntimeException;
|
||||
use InvalidArgumentException;
|
||||
use Index\Data\DataException;
|
||||
use Index\Data\DbStatementCache;
|
||||
use Index\Data\DbTools;
|
||||
use Index\Data\IDbConnection;
|
||||
use Index\Data\IDbStatement;
|
||||
use Index\Data\IDbResult;
|
||||
use Misuzu\DbStatementCache;
|
||||
use Misuzu\Pagination;
|
||||
|
||||
class DbConfig implements IConfig {
|
||||
|
|
|
@ -1,40 +0,0 @@
|
|||
<?php
|
||||
namespace Misuzu;
|
||||
|
||||
use Index\Data\IDbConnection;
|
||||
use Index\Data\IDbStatement;
|
||||
|
||||
class DbStatementCache {
|
||||
private IDbConnection $dbConn;
|
||||
private array $stmts = [];
|
||||
|
||||
public function __construct(IDbConnection $dbConn) {
|
||||
$this->dbConn = $dbConn;
|
||||
}
|
||||
|
||||
private static function hash(string $query): string {
|
||||
return hash('xxh3', $query, true);
|
||||
}
|
||||
|
||||
public function get(string $query): IDbStatement {
|
||||
$hash = self::hash($query);
|
||||
|
||||
if(array_key_exists($hash, $this->stmts)) {
|
||||
$stmt = $this->stmts[$hash];
|
||||
$stmt->reset();
|
||||
return $stmt;
|
||||
}
|
||||
|
||||
return $this->stmts[$hash] = $this->dbConn->prepare($query);
|
||||
}
|
||||
|
||||
public function remove(string $query): void {
|
||||
unset($this->stmts[self::hash($query)]);
|
||||
}
|
||||
|
||||
public function clear(): void {
|
||||
foreach($this->stmts as $stmt)
|
||||
$stmt->close();
|
||||
$this->stmts = [];
|
||||
}
|
||||
}
|
|
@ -3,8 +3,8 @@ namespace Misuzu\Emoticons;
|
|||
|
||||
use InvalidArgumentException;
|
||||
use RuntimeException;
|
||||
use Index\Data\DbStatementCache;
|
||||
use Index\Data\IDbConnection;
|
||||
use Misuzu\DbStatementCache;
|
||||
|
||||
class Emotes {
|
||||
private const EMOTE_ORDER = [
|
||||
|
|
|
@ -4,9 +4,9 @@ namespace Misuzu\News;
|
|||
use InvalidArgumentException;
|
||||
use RuntimeException;
|
||||
use Index\DateTime;
|
||||
use Index\Data\DbStatementCache;
|
||||
use Index\Data\IDbConnection;
|
||||
use Index\Data\IDbResult;
|
||||
use Misuzu\DbStatementCache;
|
||||
use Misuzu\Pagination;
|
||||
use Misuzu\Comments\CommentsCategoryInfo;
|
||||
use Misuzu\Users\User;
|
||||
|
|
|
@ -3,10 +3,10 @@ namespace Misuzu\Profile;
|
|||
|
||||
use InvalidArgumentException;
|
||||
use RuntimeException;
|
||||
use Index\Data\DbStatementCache;
|
||||
use Index\Data\DbTools;
|
||||
use Index\Data\IDbConnection;
|
||||
use Index\Data\IDbResult;
|
||||
use Misuzu\DbStatementCache;
|
||||
use Misuzu\Users\User;
|
||||
|
||||
class ProfileFields {
|
||||
|
|
Loading…
Reference in a new issue