composer update
This commit is contained in:
@@ -1,62 +1,43 @@
|
||||
<?php
|
||||
/*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This software consists of voluntary contributions made by many individuals
|
||||
* and is licensed under the MIT license. For more information, see
|
||||
* <http://www.doctrine-project.org>.
|
||||
*/
|
||||
|
||||
namespace Doctrine\DBAL\Cache;
|
||||
|
||||
use ArrayIterator;
|
||||
use Doctrine\DBAL\Driver\ResultStatement;
|
||||
use Doctrine\DBAL\FetchMode;
|
||||
use InvalidArgumentException;
|
||||
use IteratorAggregate;
|
||||
use PDO;
|
||||
use function array_merge;
|
||||
use function array_values;
|
||||
use function count;
|
||||
use function reset;
|
||||
|
||||
class ArrayStatement implements \IteratorAggregate, ResultStatement
|
||||
class ArrayStatement implements IteratorAggregate, ResultStatement
|
||||
{
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
/** @var mixed[] */
|
||||
private $data;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
/** @var int */
|
||||
private $columnCount = 0;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
/** @var int */
|
||||
private $num = 0;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
/** @var int */
|
||||
private $defaultFetchMode = FetchMode::MIXED;
|
||||
|
||||
/**
|
||||
* @param array $data
|
||||
* @param mixed[] $data
|
||||
*/
|
||||
public function __construct(array $data)
|
||||
{
|
||||
$this->data = $data;
|
||||
if (count($data)) {
|
||||
$this->columnCount = count($data[0]);
|
||||
if (! count($data)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->columnCount = count($data[0]);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -64,7 +45,7 @@ class ArrayStatement implements \IteratorAggregate, ResultStatement
|
||||
*/
|
||||
public function closeCursor()
|
||||
{
|
||||
unset ($this->data);
|
||||
unset($this->data);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -81,7 +62,7 @@ class ArrayStatement implements \IteratorAggregate, ResultStatement
|
||||
public function setFetchMode($fetchMode, $arg2 = null, $arg3 = null)
|
||||
{
|
||||
if ($arg2 !== null || $arg3 !== null) {
|
||||
throw new \InvalidArgumentException("Caching layer does not support 2nd/3rd argument to setFetchMode()");
|
||||
throw new InvalidArgumentException('Caching layer does not support 2nd/3rd argument to setFetchMode()');
|
||||
}
|
||||
|
||||
$this->defaultFetchMode = $fetchMode;
|
||||
@@ -96,13 +77,13 @@ class ArrayStatement implements \IteratorAggregate, ResultStatement
|
||||
{
|
||||
$data = $this->fetchAll();
|
||||
|
||||
return new \ArrayIterator($data);
|
||||
return new ArrayIterator($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function fetch($fetchMode = null, $cursorOrientation = \PDO::FETCH_ORI_NEXT, $cursorOffset = 0)
|
||||
public function fetch($fetchMode = null, $cursorOrientation = PDO::FETCH_ORI_NEXT, $cursorOffset = 0)
|
||||
{
|
||||
if (! isset($this->data[$this->num])) {
|
||||
return false;
|
||||
@@ -127,7 +108,7 @@ class ArrayStatement implements \IteratorAggregate, ResultStatement
|
||||
return reset($row);
|
||||
}
|
||||
|
||||
throw new \InvalidArgumentException('Invalid fetch-style given for fetching result.');
|
||||
throw new InvalidArgumentException('Invalid fetch-style given for fetching result.');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -1,36 +1,17 @@
|
||||
<?php
|
||||
/*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This software consists of voluntary contributions made by many individuals
|
||||
* and is licensed under the MIT license. For more information, see
|
||||
* <http://www.doctrine-project.org>.
|
||||
*/
|
||||
|
||||
namespace Doctrine\DBAL\Cache;
|
||||
|
||||
/**
|
||||
* @author Benjamin Eberlei <kontakt@beberlei.de>
|
||||
* @since 2.2
|
||||
*/
|
||||
class CacheException extends \Doctrine\DBAL\DBALException
|
||||
use Doctrine\DBAL\DBALException;
|
||||
|
||||
class CacheException extends DBALException
|
||||
{
|
||||
/**
|
||||
* @return \Doctrine\DBAL\Cache\CacheException
|
||||
*/
|
||||
public static function noCacheKey()
|
||||
{
|
||||
return new self("No cache key was set.");
|
||||
return new self('No cache key was set.');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -38,6 +19,6 @@ class CacheException extends \Doctrine\DBAL\DBALException
|
||||
*/
|
||||
public static function noResultDriverConfigured()
|
||||
{
|
||||
return new self("Trying to cache a query but no result driver is configured.");
|
||||
return new self('Trying to cache a query but no result driver is configured.');
|
||||
}
|
||||
}
|
||||
|
@@ -1,21 +1,4 @@
|
||||
<?php
|
||||
/*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This software consists of voluntary contributions made by many individuals
|
||||
* and is licensed under the MIT license. For more information, see
|
||||
* <http://www.doctrine-project.org>.
|
||||
*/
|
||||
|
||||
namespace Doctrine\DBAL\Cache;
|
||||
|
||||
@@ -31,19 +14,13 @@ use function sha1;
|
||||
*/
|
||||
class QueryCacheProfile
|
||||
{
|
||||
/**
|
||||
* @var Cache|null
|
||||
*/
|
||||
/** @var Cache|null */
|
||||
private $resultCacheDriver;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
/** @var int */
|
||||
private $lifetime = 0;
|
||||
|
||||
/**
|
||||
* @var string|null
|
||||
*/
|
||||
/** @var string|null */
|
||||
private $cacheKey;
|
||||
|
||||
/**
|
||||
@@ -90,12 +67,12 @@ class QueryCacheProfile
|
||||
/**
|
||||
* Generates the real cache key from query, params, types and connection parameters.
|
||||
*
|
||||
* @param string $query
|
||||
* @param array $params
|
||||
* @param array $types
|
||||
* @param array $connectionParams
|
||||
* @param string $query
|
||||
* @param mixed[] $params
|
||||
* @param int[]|string[] $types
|
||||
* @param mixed[] $connectionParams
|
||||
*
|
||||
* @return array
|
||||
* @return string[]
|
||||
*/
|
||||
public function generateCacheKeys($query, $params, $types, array $connectionParams = [])
|
||||
{
|
||||
@@ -115,7 +92,6 @@ class QueryCacheProfile
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return \Doctrine\DBAL\Cache\QueryCacheProfile
|
||||
*/
|
||||
public function setResultCacheDriver(Cache $cache)
|
||||
|
@@ -1,28 +1,15 @@
|
||||
<?php
|
||||
/*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This software consists of voluntary contributions made by many individuals
|
||||
* and is licensed under the MIT license. For more information, see
|
||||
* <http://www.doctrine-project.org>.
|
||||
*/
|
||||
|
||||
namespace Doctrine\DBAL\Cache;
|
||||
|
||||
use Doctrine\DBAL\Driver\Statement;
|
||||
use Doctrine\DBAL\Driver\ResultStatement;
|
||||
use ArrayIterator;
|
||||
use Doctrine\Common\Cache\Cache;
|
||||
use Doctrine\DBAL\Driver\ResultStatement;
|
||||
use Doctrine\DBAL\Driver\Statement;
|
||||
use Doctrine\DBAL\FetchMode;
|
||||
use InvalidArgumentException;
|
||||
use IteratorAggregate;
|
||||
use PDO;
|
||||
use function array_merge;
|
||||
use function array_values;
|
||||
use function reset;
|
||||
@@ -40,32 +27,21 @@ use function reset;
|
||||
* Also you have to realize that the cache will load the whole result into memory at once to ensure 2.
|
||||
* This means that the memory usage for cached results might increase by using this feature.
|
||||
*/
|
||||
class ResultCacheStatement implements \IteratorAggregate, ResultStatement
|
||||
class ResultCacheStatement implements IteratorAggregate, ResultStatement
|
||||
{
|
||||
/**
|
||||
* @var \Doctrine\Common\Cache\Cache
|
||||
*/
|
||||
/** @var Cache */
|
||||
private $resultCache;
|
||||
|
||||
/**
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
/** @var string */
|
||||
private $cacheKey;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
/** @var string */
|
||||
private $realKey;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
/** @var int */
|
||||
private $lifetime;
|
||||
|
||||
/**
|
||||
* @var \Doctrine\DBAL\Driver\Statement
|
||||
*/
|
||||
/** @var Statement */
|
||||
private $statement;
|
||||
|
||||
/**
|
||||
@@ -75,30 +51,24 @@ class ResultCacheStatement implements \IteratorAggregate, ResultStatement
|
||||
*/
|
||||
private $emptied = false;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
/** @var mixed[] */
|
||||
private $data;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
/** @var int */
|
||||
private $defaultFetchMode = FetchMode::MIXED;
|
||||
|
||||
/**
|
||||
* @param \Doctrine\DBAL\Driver\Statement $stmt
|
||||
* @param \Doctrine\Common\Cache\Cache $resultCache
|
||||
* @param string $cacheKey
|
||||
* @param string $realKey
|
||||
* @param int $lifetime
|
||||
* @param string $cacheKey
|
||||
* @param string $realKey
|
||||
* @param int $lifetime
|
||||
*/
|
||||
public function __construct(Statement $stmt, Cache $resultCache, $cacheKey, $realKey, $lifetime)
|
||||
{
|
||||
$this->statement = $stmt;
|
||||
$this->statement = $stmt;
|
||||
$this->resultCache = $resultCache;
|
||||
$this->cacheKey = $cacheKey;
|
||||
$this->realKey = $realKey;
|
||||
$this->lifetime = $lifetime;
|
||||
$this->cacheKey = $cacheKey;
|
||||
$this->realKey = $realKey;
|
||||
$this->lifetime = $lifetime;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -107,16 +77,20 @@ class ResultCacheStatement implements \IteratorAggregate, ResultStatement
|
||||
public function closeCursor()
|
||||
{
|
||||
$this->statement->closeCursor();
|
||||
if ($this->emptied && $this->data !== null) {
|
||||
$data = $this->resultCache->fetch($this->cacheKey);
|
||||
if ( ! $data) {
|
||||
$data = [];
|
||||
}
|
||||
$data[$this->realKey] = $this->data;
|
||||
|
||||
$this->resultCache->save($this->cacheKey, $data, $this->lifetime);
|
||||
unset($this->data);
|
||||
if (! $this->emptied || $this->data === null) {
|
||||
return true;
|
||||
}
|
||||
|
||||
$data = $this->resultCache->fetch($this->cacheKey);
|
||||
if (! $data) {
|
||||
$data = [];
|
||||
}
|
||||
$data[$this->realKey] = $this->data;
|
||||
|
||||
$this->resultCache->save($this->cacheKey, $data, $this->lifetime);
|
||||
unset($this->data);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -144,13 +118,13 @@ class ResultCacheStatement implements \IteratorAggregate, ResultStatement
|
||||
{
|
||||
$data = $this->fetchAll();
|
||||
|
||||
return new \ArrayIterator($data);
|
||||
return new ArrayIterator($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function fetch($fetchMode = null, $cursorOrientation = \PDO::FETCH_ORI_NEXT, $cursorOffset = 0)
|
||||
public function fetch($fetchMode = null, $cursorOrientation = PDO::FETCH_ORI_NEXT, $cursorOffset = 0)
|
||||
{
|
||||
if ($this->data === null) {
|
||||
$this->data = [];
|
||||
@@ -179,7 +153,7 @@ class ResultCacheStatement implements \IteratorAggregate, ResultStatement
|
||||
return reset($row);
|
||||
}
|
||||
|
||||
throw new \InvalidArgumentException('Invalid fetch-style given for caching result.');
|
||||
throw new InvalidArgumentException('Invalid fetch-style given for caching result.');
|
||||
}
|
||||
|
||||
$this->emptied = true;
|
||||
@@ -192,12 +166,7 @@ class ResultCacheStatement implements \IteratorAggregate, ResultStatement
|
||||
*/
|
||||
public function fetchAll($fetchMode = null, $fetchArgument = null, $ctorArgs = null)
|
||||
{
|
||||
$rows = [];
|
||||
while ($row = $this->fetch($fetchMode)) {
|
||||
$rows[] = $row;
|
||||
}
|
||||
|
||||
return $rows;
|
||||
return $this->statement->fetchAll($fetchMode, $fetchArgument, $ctorArgs);
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user