diff --git a/VERSION b/VERSION index bee887d..37f3671 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.2307.211801 +0.2307.212010 diff --git a/src/Data/DbStatementCache.php b/src/Data/DbStatementCache.php new file mode 100644 index 0000000..edb82d3 --- /dev/null +++ b/src/Data/DbStatementCache.php @@ -0,0 +1,44 @@ +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 = []; + } +} diff --git a/src/Data/DbTools.php b/src/Data/DbTools.php index 82996ae..a1063d3 100644 --- a/src/Data/DbTools.php +++ b/src/Data/DbTools.php @@ -1,10 +1,11 @@