Inital commit for unit test configuration
This commit is contained in:

committed by
Manish Verma

parent
2f0796e954
commit
e0436b7757
9
vendor/doctrine/cache/README.md
vendored
9
vendor/doctrine/cache/README.md
vendored
@@ -1,9 +1,10 @@
|
||||
# Doctrine Cache
|
||||
|
||||
[](http://travis-ci.org/doctrine/cache)
|
||||
[](https://scrutinizer-ci.com/g/doctrine/cache/?branch=master)
|
||||
[](https://scrutinizer-ci.com/g/doctrine/cache/?branch=master)
|
||||
[](http://travis-ci.org/doctrine/cache)
|
||||
[](https://scrutinizer-ci.com/g/doctrine/cache/?branch=master)
|
||||
[](https://scrutinizer-ci.com/g/doctrine/cache/?branch=master)
|
||||
|
||||
[](https://packagist.org/packages/doctrine/cache) [](https://packagist.org/packages/doctrine/cache)
|
||||
[](https://packagist.org/packages/doctrine/cache)
|
||||
[](https://packagist.org/packages/doctrine/cache)
|
||||
|
||||
Cache component extracted from the Doctrine Common project. [Documentation](http://doctrine-orm.readthedocs.io/projects/doctrine-orm/en/latest/reference/caching.html)
|
||||
|
9
vendor/doctrine/cache/composer.json
vendored
9
vendor/doctrine/cache/composer.json
vendored
@@ -3,7 +3,7 @@
|
||||
"type": "library",
|
||||
"description": "Caching library offering an object-oriented API for many cache backends",
|
||||
"keywords": ["cache", "caching"],
|
||||
"homepage": "http://www.doctrine-project.org",
|
||||
"homepage": "https://www.doctrine-project.org",
|
||||
"license": "MIT",
|
||||
"authors": [
|
||||
{"name": "Guilherme Blanco", "email": "guilhermeblanco@gmail.com"},
|
||||
@@ -18,8 +18,9 @@
|
||||
"require-dev": {
|
||||
"alcaeus/mongo-php-adapter": "^1.1",
|
||||
"mongodb/mongodb": "^1.1",
|
||||
"phpunit/phpunit": "^5.7",
|
||||
"predis/predis": "~1.0"
|
||||
"phpunit/phpunit": "^7.0",
|
||||
"predis/predis": "~1.0",
|
||||
"doctrine/coding-standard": "^4.0"
|
||||
},
|
||||
"suggest": {
|
||||
"alcaeus/mongo-php-adapter": "Required to use legacy MongoDB driver"
|
||||
@@ -35,7 +36,7 @@
|
||||
},
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "1.7.x-dev"
|
||||
"dev-master": "1.8.x-dev"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
274
vendor/doctrine/cache/docs/en/index.rst
vendored
Normal file
274
vendor/doctrine/cache/docs/en/index.rst
vendored
Normal file
@@ -0,0 +1,274 @@
|
||||
Introduction
|
||||
============
|
||||
|
||||
Doctrine Cache is a library that provides an interface for caching data.
|
||||
It comes with implementations for some of the most popular caching data
|
||||
stores. Here is what the ``Cache`` interface looks like.
|
||||
|
||||
.. code-block:: php
|
||||
namespace Doctrine\Common\Cache;
|
||||
|
||||
interface Cache
|
||||
{
|
||||
public function fetch($id);
|
||||
public function contains($id);
|
||||
public function save($id, $data, $lifeTime = 0);
|
||||
public function delete($id);
|
||||
public function getStats();
|
||||
}
|
||||
|
||||
Here is an example that uses Memcache.
|
||||
|
||||
.. code-block:: php
|
||||
use Doctrine\Common\Cache\MemcacheCache;
|
||||
|
||||
$memcache = new Memcache();
|
||||
$cache = new MemcacheCache();
|
||||
$cache->setMemcache($memcache);
|
||||
|
||||
$cache->set('key', 'value');
|
||||
|
||||
echo $cache->get('key') // prints "value"
|
||||
|
||||
Drivers
|
||||
=======
|
||||
|
||||
Doctrine ships with several common drivers that you can easily use.
|
||||
Below you can find information about all the available drivers.
|
||||
|
||||
ApcCache
|
||||
--------
|
||||
|
||||
The ``ApcCache`` driver uses the ``apc_fetch``, ``apc_exists``, etc. functions that come
|
||||
with PHP so no additional setup is required in order to use it.
|
||||
|
||||
.. code-block:: php
|
||||
$cache = new ApcCache();
|
||||
|
||||
ApcuCache
|
||||
---------
|
||||
|
||||
The ``ApcuCache`` driver uses the ``apcu_fetch``, ``apcu_exists``, etc. functions that come
|
||||
with PHP so no additional setup is required in order to use it.
|
||||
|
||||
.. code-block:: php
|
||||
$cache = new ApcuCache();
|
||||
|
||||
ArrayCache
|
||||
----------
|
||||
|
||||
The ``ArrayCache`` driver stores the cache data in PHPs memory and is not persisted anywhere.
|
||||
This can be useful for caching things in memory for a single process when you don't need
|
||||
the cache to be persistent across processes.
|
||||
|
||||
.. code-block:: php
|
||||
$cache = new ArrayCache();
|
||||
|
||||
ChainCache
|
||||
----------
|
||||
|
||||
The ``ChainCache`` driver lets you chain multiple other drivers together easily.
|
||||
|
||||
.. code-block:: php
|
||||
$arrayCache = new ArrayCache();
|
||||
$apcuCache = new ApcuCache();
|
||||
|
||||
$cache = new ChainCache([$arrayCache, $apcuCache]);
|
||||
|
||||
CouchbaseBucketCache
|
||||
--------------------
|
||||
|
||||
The ``CouchbaseBucketCache`` driver uses Couchbase to store the cache data.
|
||||
|
||||
.. code-block:: php
|
||||
$bucketName = 'bucket-name';
|
||||
|
||||
$authenticator = new Couchbase\PasswordAuthenticator();
|
||||
$authenticator->username('username')->password('password');
|
||||
|
||||
$cluster = new CouchbaseCluster('couchbase://127.0.0.1');
|
||||
|
||||
$cluster->authenticate($authenticator);
|
||||
$bucket = $cluster->openBucket($bucketName);
|
||||
|
||||
$cache = new CouchbaseBucketCache($bucket);
|
||||
|
||||
FilesystemCache
|
||||
---------------
|
||||
|
||||
The ``FilesystemCache`` driver stores the cache data on the local filesystem.
|
||||
|
||||
.. code-block:: php
|
||||
$cache = new FilesystemCache('/path/to/cache/directory');
|
||||
|
||||
MemecacheCache
|
||||
--------------
|
||||
|
||||
The ``MemcacheCache`` drivers stores the cache data in Memcache.
|
||||
|
||||
.. code-block:: php
|
||||
$memcache = new Memcache();
|
||||
$memcache->connect('localhost', 11211);
|
||||
|
||||
$cache = new MemcacheCache();
|
||||
$cache->setMemcache($memcache);
|
||||
|
||||
MemcachedCache
|
||||
--------------
|
||||
|
||||
The ``MemcachedCache`` drivers stores the cache data in Memcached.
|
||||
|
||||
.. code-block:: php
|
||||
$memcached = new Memcached();
|
||||
|
||||
$cache = new MemcachedCache();
|
||||
$cache->setMemcached($memcached);
|
||||
|
||||
MongoDBCache
|
||||
------------
|
||||
|
||||
The ``MongoDBCache`` drivers stores the cache data in a MongoDB collection.
|
||||
|
||||
.. code-block:: php
|
||||
$manager = new MongoDB\Driver\Manager("mongodb://localhost:27017");
|
||||
|
||||
$collection = new MongoDB\Collection($manager, 'database_name', 'collection_name');
|
||||
|
||||
$cache = new MongoDBCache($collection);
|
||||
|
||||
PhpFileCache
|
||||
------------
|
||||
|
||||
The ``PhpFileCache`` driver stores the cache data on the local filesystem like the
|
||||
``FilesystemCache`` driver except the data is serialized using the ``serialize()``
|
||||
and ``unserialize()`` functions available in PHP. The files are included so this means
|
||||
that the data can be cached in PHPs opcache.
|
||||
|
||||
.. code-block:: php
|
||||
$cache = new PhpFileCache('/path/to/cache/directory');
|
||||
|
||||
PredisCache
|
||||
-----------
|
||||
|
||||
The ``PredisCache`` driver stores the cache data in Redis
|
||||
and depends on the ``predis/predis`` package which can be installed with composer.
|
||||
|
||||
.. code-block:: bash
|
||||
$ composer require predis/predis
|
||||
|
||||
Then you can use the ``Predis\Client`` class to pass to the ``PredisCache`` class.
|
||||
|
||||
.. code-block:: php
|
||||
$client = new Predis\Client();
|
||||
|
||||
$cache = new PredisCache($client);
|
||||
|
||||
RedisCache
|
||||
----------
|
||||
|
||||
The ``RedisCache`` driver stores the cache data in Redis and depends on the
|
||||
``phpredis`` extension which can be found `here <https://github.com/phpredis/phpredis>`_.
|
||||
|
||||
.. code-block:: php
|
||||
$redis = new Redis();
|
||||
|
||||
$cache = new RedisCache($redis);
|
||||
|
||||
RiakCache
|
||||
---------
|
||||
|
||||
The ``RiakCache`` driver stores the cache data in Riak and depends on the
|
||||
``riak`` extension which can be found `here <https://github.com/php-riak/php_riak>`_.
|
||||
|
||||
.. code-block:: php
|
||||
$connection = new Riak\Connection('localhost', 8087);
|
||||
|
||||
$bucket = new Riak\Bucket($connection, 'bucket_name');
|
||||
|
||||
$cache = new RiakCache($bucket);
|
||||
|
||||
SQLite3Cache
|
||||
------------
|
||||
|
||||
The ``SQLite3Cache`` driver stores the cache data in a SQLite database and depends on the
|
||||
``sqlite3`` extension which can be found `here <http://php.net/manual/en/book.sqlite3.php>`_.
|
||||
|
||||
.. code-block:: php
|
||||
$db = new SQLite3('mydatabase.db');
|
||||
|
||||
$cache = new SQLite3Cache($db, 'table_name');
|
||||
|
||||
VoidCache
|
||||
---------
|
||||
|
||||
The ``VoidCache`` driver does not store the cache data anywhere. This can
|
||||
be useful for test environments where you don't want to cache the data
|
||||
anywhere but need to satisfy the dependency for the ``Doctrine\Common\Cache\Cache``
|
||||
interface.
|
||||
|
||||
.. code-block:: php
|
||||
$cache = new VoidCache();
|
||||
|
||||
WinCacheCache
|
||||
-------------
|
||||
|
||||
The ``WinCacheCache`` driver uses the ``wincache_ucache_get``, ``wincache_ucache_exists``, etc. functions that come
|
||||
with the ``wincache`` extension which can be found `here <http://php.net/manual/en/book.wincache.php>`_.
|
||||
|
||||
.. code-block:: php
|
||||
$cache = new WinCacheCache();
|
||||
|
||||
XcacheCache
|
||||
-----------
|
||||
|
||||
The ``XcacheCache`` driver uses functions that come with the ``xcache``
|
||||
extension which can be found `here <https://xcache.lighttpd.net/>`_.
|
||||
|
||||
.. code-block:: php
|
||||
$cache = new XcacheCache();
|
||||
|
||||
ZendDataCache
|
||||
-------------
|
||||
|
||||
The ``ZendDataCache`` driver uses the Zend Data Cache API available in the Zend Platform.
|
||||
|
||||
.. code-block:: php
|
||||
$cache = new ZendDataCache();
|
||||
|
||||
Custom Drivers
|
||||
==============
|
||||
|
||||
If you want to implement your own cache driver, you just need to implement
|
||||
the ``Doctrine\Common\Cache\Cache`` interface. Here is an example implementation
|
||||
skeleton.
|
||||
|
||||
.. code-block:: php
|
||||
use Doctrine\Common\Cache\Cache;
|
||||
|
||||
class MyCacheDriver implements Cache
|
||||
{
|
||||
public function fetch($id)
|
||||
{
|
||||
// fetch $id from the cache
|
||||
}
|
||||
|
||||
public function contains($id)
|
||||
{
|
||||
// check if $id exists in the cache
|
||||
}
|
||||
|
||||
public function save($id, $data, $lifeTime = 0)
|
||||
{
|
||||
// save $data under $id in the cache for $lifetime
|
||||
}
|
||||
|
||||
public function delete($id)
|
||||
{
|
||||
// delete $id from the cache
|
||||
}
|
||||
|
||||
public function getStats()
|
||||
{
|
||||
// get cache stats
|
||||
}
|
||||
}
|
@@ -1,35 +1,21 @@
|
||||
<?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\Common\Cache;
|
||||
|
||||
use const PHP_VERSION_ID;
|
||||
use function apc_cache_info;
|
||||
use function apc_clear_cache;
|
||||
use function apc_delete;
|
||||
use function apc_exists;
|
||||
use function apc_fetch;
|
||||
use function apc_sma_info;
|
||||
use function apc_store;
|
||||
|
||||
/**
|
||||
* APC cache provider.
|
||||
*
|
||||
* @link www.doctrine-project.org
|
||||
* @deprecated since version 1.6, use ApcuCache instead
|
||||
* @since 2.0
|
||||
* @author Benjamin Eberlei <kontakt@beberlei.de>
|
||||
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
|
||||
* @author Jonathan Wage <jonwage@gmail.com>
|
||||
* @author Roman Borschel <roman@code-factory.org>
|
||||
* @author David Abdemoulaie <dave@hobodave.com>
|
||||
*/
|
||||
class ApcCache extends CacheProvider
|
||||
{
|
||||
@@ -102,9 +88,9 @@ class ApcCache extends CacheProvider
|
||||
|
||||
// @TODO - Temporary fix @see https://github.com/krakjoe/apcu/pull/42
|
||||
if (PHP_VERSION_ID >= 50500) {
|
||||
$info['num_hits'] = isset($info['num_hits']) ? $info['num_hits'] : $info['nhits'];
|
||||
$info['num_misses'] = isset($info['num_misses']) ? $info['num_misses'] : $info['nmisses'];
|
||||
$info['start_time'] = isset($info['start_time']) ? $info['start_time'] : $info['stime'];
|
||||
$info['num_hits'] = $info['num_hits'] ?? $info['nhits'];
|
||||
$info['num_misses'] = $info['num_misses'] ?? $info['nmisses'];
|
||||
$info['start_time'] = $info['start_time'] ?? $info['stime'];
|
||||
}
|
||||
|
||||
return [
|
||||
|
@@ -1,30 +1,20 @@
|
||||
<?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\Common\Cache;
|
||||
|
||||
use function apcu_cache_info;
|
||||
use function apcu_clear_cache;
|
||||
use function apcu_delete;
|
||||
use function apcu_exists;
|
||||
use function apcu_fetch;
|
||||
use function apcu_sma_info;
|
||||
use function apcu_store;
|
||||
use function count;
|
||||
|
||||
/**
|
||||
* APCu cache provider.
|
||||
*
|
||||
* @link www.doctrine-project.org
|
||||
* @since 1.6
|
||||
* @author Kévin Dunglas <dunglas@gmail.com>
|
||||
*/
|
||||
class ApcuCache extends CacheProvider
|
||||
{
|
||||
@@ -68,7 +58,7 @@ class ApcuCache extends CacheProvider
|
||||
{
|
||||
$result = apcu_delete($keys);
|
||||
|
||||
return false !== $result && count($result) !== count($keys);
|
||||
return $result !== false && count($result) !== count($keys);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -1,55 +1,26 @@
|
||||
<?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\Common\Cache;
|
||||
|
||||
use function time;
|
||||
|
||||
/**
|
||||
* Array cache driver.
|
||||
*
|
||||
* @link www.doctrine-project.org
|
||||
* @since 2.0
|
||||
* @author Benjamin Eberlei <kontakt@beberlei.de>
|
||||
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
|
||||
* @author Jonathan Wage <jonwage@gmail.com>
|
||||
* @author Roman Borschel <roman@code-factory.org>
|
||||
* @author David Abdemoulaie <dave@hobodave.com>
|
||||
*/
|
||||
class ArrayCache extends CacheProvider
|
||||
{
|
||||
/**
|
||||
* @var array[] $data each element being a tuple of [$data, $expiration], where the expiration is int|bool
|
||||
*/
|
||||
/** @var array[] $data each element being a tuple of [$data, $expiration], where the expiration is int|bool */
|
||||
private $data = [];
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
/** @var int */
|
||||
private $hitsCount = 0;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
/** @var int */
|
||||
private $missesCount = 0;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
/** @var int */
|
||||
private $upTime;
|
||||
|
||||
/**
|
||||
|
@@ -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\Common\Cache;
|
||||
|
||||
@@ -23,27 +6,20 @@ namespace Doctrine\Common\Cache;
|
||||
* Interface for cache drivers.
|
||||
*
|
||||
* @link www.doctrine-project.org
|
||||
* @since 2.0
|
||||
* @author Benjamin Eberlei <kontakt@beberlei.de>
|
||||
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
|
||||
* @author Jonathan Wage <jonwage@gmail.com>
|
||||
* @author Roman Borschel <roman@code-factory.org>
|
||||
* @author Fabio B. Silva <fabio.bat.silva@gmail.com>
|
||||
* @author Kévin Dunglas <dunglas@gmail.com>
|
||||
*/
|
||||
interface Cache
|
||||
{
|
||||
const STATS_HITS = 'hits';
|
||||
const STATS_MISSES = 'misses';
|
||||
const STATS_UPTIME = 'uptime';
|
||||
const STATS_MEMORY_USAGE = 'memory_usage';
|
||||
const STATS_MEMORY_AVAILABLE = 'memory_available';
|
||||
public const STATS_HITS = 'hits';
|
||||
public const STATS_MISSES = 'misses';
|
||||
public const STATS_UPTIME = 'uptime';
|
||||
public const STATS_MEMORY_USAGE = 'memory_usage';
|
||||
public const STATS_MEMORY_AVAILABLE = 'memory_available';
|
||||
/**
|
||||
* Only for backward compatibility (may be removed in next major release)
|
||||
*
|
||||
* @deprecated
|
||||
*/
|
||||
const STATS_MEMORY_AVAILIABLE = 'memory_available';
|
||||
public const STATS_MEMORY_AVAILIABLE = 'memory_available';
|
||||
|
||||
/**
|
||||
* Fetches an entry from the cache.
|
||||
@@ -108,8 +84,6 @@ interface Cache
|
||||
* - <b>memory_available</b>
|
||||
* Memory allowed to use for storage.
|
||||
*
|
||||
* @since 2.2
|
||||
*
|
||||
* @return array|null An associative array with server's statistics if available, NULL otherwise.
|
||||
*/
|
||||
public function getStats();
|
||||
|
@@ -1,38 +1,19 @@
|
||||
<?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\Common\Cache;
|
||||
|
||||
use function array_combine;
|
||||
use function array_key_exists;
|
||||
use function array_map;
|
||||
use function sprintf;
|
||||
|
||||
/**
|
||||
* Base class for cache provider implementations.
|
||||
*
|
||||
* @since 2.2
|
||||
* @author Benjamin Eberlei <kontakt@beberlei.de>
|
||||
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
|
||||
* @author Jonathan Wage <jonwage@gmail.com>
|
||||
* @author Roman Borschel <roman@code-factory.org>
|
||||
* @author Fabio B. Silva <fabio.bat.silva@gmail.com>
|
||||
* @author Benoit Burnichon <bburnichon@gmail.com>
|
||||
*/
|
||||
abstract class CacheProvider implements Cache, FlushableCache, ClearableCache, MultiOperationCache
|
||||
{
|
||||
const DOCTRINE_NAMESPACE_CACHEKEY = 'DoctrineNamespaceCacheKey[%s]';
|
||||
public const DOCTRINE_NAMESPACE_CACHEKEY = 'DoctrineNamespaceCacheKey[%s]';
|
||||
|
||||
/**
|
||||
* The namespace to prefix all cache ids with.
|
||||
@@ -44,7 +25,7 @@ abstract class CacheProvider implements Cache, FlushableCache, ClearableCache, M
|
||||
/**
|
||||
* The namespace version.
|
||||
*
|
||||
* @var integer|null
|
||||
* @var int|null
|
||||
*/
|
||||
private $namespaceVersion;
|
||||
|
||||
@@ -96,9 +77,11 @@ abstract class CacheProvider implements Cache, FlushableCache, ClearableCache, M
|
||||
// no internal array function supports this sort of mapping: needs to be iterative
|
||||
// this filters and combines keys in one pass
|
||||
foreach ($namespacedKeys as $requestedKey => $namespacedKey) {
|
||||
if (isset($items[$namespacedKey]) || array_key_exists($namespacedKey, $items)) {
|
||||
$foundItems[$requestedKey] = $items[$namespacedKey];
|
||||
if (! isset($items[$namespacedKey]) && ! array_key_exists($namespacedKey, $items)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$foundItems[$requestedKey] = $items[$namespacedKey];
|
||||
}
|
||||
|
||||
return $foundItems;
|
||||
@@ -138,7 +121,7 @@ abstract class CacheProvider implements Cache, FlushableCache, ClearableCache, M
|
||||
*/
|
||||
public function deleteMultiple(array $keys)
|
||||
{
|
||||
return $this->doDeleteMultiple(array_map(array($this, 'getNamespacedId'), $keys));
|
||||
return $this->doDeleteMultiple(array_map([$this, 'getNamespacedId'], $keys));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -191,15 +174,13 @@ abstract class CacheProvider implements Cache, FlushableCache, ClearableCache, M
|
||||
*/
|
||||
private function getNamespacedId(string $id) : string
|
||||
{
|
||||
$namespaceVersion = $this->getNamespaceVersion();
|
||||
$namespaceVersion = $this->getNamespaceVersion();
|
||||
|
||||
return sprintf('%s[%s][%s]', $this->namespace, $id, $namespaceVersion);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the namespace cache key.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private function getNamespaceCacheKey() : string
|
||||
{
|
||||
@@ -208,12 +189,10 @@ abstract class CacheProvider implements Cache, FlushableCache, ClearableCache, M
|
||||
|
||||
/**
|
||||
* Returns the namespace version.
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
private function getNamespaceVersion() : int
|
||||
{
|
||||
if (null !== $this->namespaceVersion) {
|
||||
if ($this->namespaceVersion !== null) {
|
||||
return $this->namespaceVersion;
|
||||
}
|
||||
|
||||
@@ -234,9 +213,12 @@ abstract class CacheProvider implements Cache, FlushableCache, ClearableCache, M
|
||||
$returnValues = [];
|
||||
|
||||
foreach ($keys as $key) {
|
||||
if (false !== ($item = $this->doFetch($key)) || $this->doContains($key)) {
|
||||
$returnValues[$key] = $item;
|
||||
$item = $this->doFetch($key);
|
||||
if ($item === false && ! $this->doContains($key)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$returnValues[$key] = $item;
|
||||
}
|
||||
|
||||
return $returnValues;
|
||||
@@ -263,9 +245,9 @@ abstract class CacheProvider implements Cache, FlushableCache, ClearableCache, M
|
||||
/**
|
||||
* Default implementation of doSaveMultiple. Each driver that supports multi-put should override it.
|
||||
*
|
||||
* @param array $keysAndValues Array of keys and values to save in cache
|
||||
* @param int $lifetime The lifetime. If != 0, sets a specific lifetime for these
|
||||
* cache entries (0 => infinite lifeTime).
|
||||
* @param array $keysAndValues Array of keys and values to save in cache
|
||||
* @param int $lifetime The lifetime. If != 0, sets a specific lifetime for these
|
||||
* cache entries (0 => infinite lifeTime).
|
||||
*
|
||||
* @return bool TRUE if the operation was successful, FALSE if it wasn't.
|
||||
*/
|
||||
@@ -274,9 +256,11 @@ abstract class CacheProvider implements Cache, FlushableCache, ClearableCache, M
|
||||
$success = true;
|
||||
|
||||
foreach ($keysAndValues as $key => $value) {
|
||||
if (!$this->doSave($key, $value, $lifetime)) {
|
||||
$success = false;
|
||||
if ($this->doSave($key, $value, $lifetime)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$success = false;
|
||||
}
|
||||
|
||||
return $success;
|
||||
@@ -306,9 +290,11 @@ abstract class CacheProvider implements Cache, FlushableCache, ClearableCache, M
|
||||
$success = true;
|
||||
|
||||
foreach ($keys as $key) {
|
||||
if (! $this->doDelete($key)) {
|
||||
$success = false;
|
||||
if ($this->doDelete($key)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$success = false;
|
||||
}
|
||||
|
||||
return $success;
|
||||
@@ -333,8 +319,6 @@ abstract class CacheProvider implements Cache, FlushableCache, ClearableCache, M
|
||||
/**
|
||||
* Retrieves cached information from the data store.
|
||||
*
|
||||
* @since 2.2
|
||||
*
|
||||
* @return array|null An associative array with server's statistics if available, NULL otherwise.
|
||||
*/
|
||||
abstract protected function doGetStats();
|
||||
|
@@ -1,39 +1,20 @@
|
||||
<?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\Common\Cache;
|
||||
|
||||
use function array_values;
|
||||
use function count;
|
||||
use function iterator_to_array;
|
||||
|
||||
/**
|
||||
* Cache provider that allows to easily chain multiple cache providers
|
||||
*
|
||||
* @author Michaël Gallego <mic.gallego@gmail.com>
|
||||
*/
|
||||
class ChainCache extends CacheProvider
|
||||
{
|
||||
/**
|
||||
* @var CacheProvider[]
|
||||
*/
|
||||
/** @var CacheProvider[] */
|
||||
private $cacheProviders = [];
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param CacheProvider[] $cacheProviders
|
||||
*/
|
||||
public function __construct($cacheProviders = [])
|
||||
@@ -65,7 +46,7 @@ class ChainCache extends CacheProvider
|
||||
$value = $cacheProvider->doFetch($id);
|
||||
|
||||
// We populate all the previous cache layers (that are assumed to be faster)
|
||||
for ($subKey = $key - 1 ; $subKey >= 0 ; $subKey--) {
|
||||
for ($subKey = $key - 1; $subKey >= 0; $subKey--) {
|
||||
$this->cacheProviders[$subKey]->doSave($id, $value);
|
||||
}
|
||||
|
||||
@@ -81,7 +62,7 @@ class ChainCache extends CacheProvider
|
||||
*/
|
||||
protected function doFetchMultiple(array $keys)
|
||||
{
|
||||
/* @var $traversedProviders CacheProvider[] */
|
||||
/** @var CacheProvider[] $traversedProviders */
|
||||
$traversedProviders = [];
|
||||
$keysCount = count($keys);
|
||||
$fetchedValues = [];
|
||||
|
@@ -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\Common\Cache;
|
||||
|
||||
@@ -26,8 +9,6 @@ namespace Doctrine\Common\Cache;
|
||||
* global "flushing", see {@see FlushableCache}.
|
||||
*
|
||||
* @link www.doctrine-project.org
|
||||
* @since 1.4
|
||||
* @author Adirelle <adirelle@gmail.com>
|
||||
*/
|
||||
interface ClearableCache
|
||||
{
|
||||
|
195
vendor/doctrine/cache/lib/Doctrine/Common/Cache/CouchbaseBucketCache.php
vendored
Normal file
195
vendor/doctrine/cache/lib/Doctrine/Common/Cache/CouchbaseBucketCache.php
vendored
Normal file
@@ -0,0 +1,195 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Doctrine\Common\Cache;
|
||||
|
||||
use Couchbase\Bucket;
|
||||
use Couchbase\Document;
|
||||
use Couchbase\Exception;
|
||||
use function phpversion;
|
||||
use function serialize;
|
||||
use function sprintf;
|
||||
use function substr;
|
||||
use function time;
|
||||
use function unserialize;
|
||||
use function version_compare;
|
||||
|
||||
/**
|
||||
* Couchbase ^2.3.0 cache provider.
|
||||
*/
|
||||
final class CouchbaseBucketCache extends CacheProvider
|
||||
{
|
||||
private const MINIMUM_VERSION = '2.3.0';
|
||||
|
||||
private const KEY_NOT_FOUND = 13;
|
||||
|
||||
private const MAX_KEY_LENGTH = 250;
|
||||
|
||||
private const THIRTY_DAYS_IN_SECONDS = 2592000;
|
||||
|
||||
/** @var Bucket */
|
||||
private $bucket;
|
||||
|
||||
public function __construct(Bucket $bucket)
|
||||
{
|
||||
if (version_compare(phpversion('couchbase'), self::MINIMUM_VERSION) < 0) {
|
||||
// Manager is required to flush cache and pull stats.
|
||||
throw new \RuntimeException(sprintf('ext-couchbase:^%s is required.', self::MINIMUM_VERSION));
|
||||
}
|
||||
|
||||
$this->bucket = $bucket;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doFetch($id)
|
||||
{
|
||||
$id = $this->normalizeKey($id);
|
||||
|
||||
try {
|
||||
$document = $this->bucket->get($id);
|
||||
} catch (Exception $e) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($document instanceof Document && $document->value !== false) {
|
||||
return unserialize($document->value);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doContains($id)
|
||||
{
|
||||
$id = $this->normalizeKey($id);
|
||||
|
||||
try {
|
||||
$document = $this->bucket->get($id);
|
||||
} catch (Exception $e) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($document instanceof Document) {
|
||||
return ! $document->error;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doSave($id, $data, $lifeTime = 0)
|
||||
{
|
||||
$id = $this->normalizeKey($id);
|
||||
|
||||
$lifeTime = $this->normalizeExpiry($lifeTime);
|
||||
|
||||
try {
|
||||
$encoded = serialize($data);
|
||||
|
||||
$document = $this->bucket->upsert($id, $encoded, [
|
||||
'expiry' => (int) $lifeTime,
|
||||
]);
|
||||
} catch (Exception $e) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($document instanceof Document) {
|
||||
return ! $document->error;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doDelete($id)
|
||||
{
|
||||
$id = $this->normalizeKey($id);
|
||||
|
||||
try {
|
||||
$document = $this->bucket->remove($id);
|
||||
} catch (Exception $e) {
|
||||
return $e->getCode() === self::KEY_NOT_FOUND;
|
||||
}
|
||||
|
||||
if ($document instanceof Document) {
|
||||
return ! $document->error;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doFlush()
|
||||
{
|
||||
$manager = $this->bucket->manager();
|
||||
|
||||
// Flush does not return with success or failure, and must be enabled per bucket on the server.
|
||||
// Store a marker item so that we will know if it was successful.
|
||||
$this->doSave(__METHOD__, true, 60);
|
||||
|
||||
$manager->flush();
|
||||
|
||||
if ($this->doContains(__METHOD__)) {
|
||||
$this->doDelete(__METHOD__);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doGetStats()
|
||||
{
|
||||
$manager = $this->bucket->manager();
|
||||
$stats = $manager->info();
|
||||
$nodes = $stats['nodes'];
|
||||
$node = $nodes[0];
|
||||
$interestingStats = $node['interestingStats'];
|
||||
|
||||
return [
|
||||
Cache::STATS_HITS => $interestingStats['get_hits'],
|
||||
Cache::STATS_MISSES => $interestingStats['cmd_get'] - $interestingStats['get_hits'],
|
||||
Cache::STATS_UPTIME => $node['uptime'],
|
||||
Cache::STATS_MEMORY_USAGE => $interestingStats['mem_used'],
|
||||
Cache::STATS_MEMORY_AVAILABLE => $node['memoryFree'],
|
||||
];
|
||||
}
|
||||
|
||||
private function normalizeKey(string $id) : string
|
||||
{
|
||||
$normalized = substr($id, 0, self::MAX_KEY_LENGTH);
|
||||
|
||||
if ($normalized === false) {
|
||||
return $id;
|
||||
}
|
||||
|
||||
return $normalized;
|
||||
}
|
||||
|
||||
/**
|
||||
* Expiry treated as a unix timestamp instead of an offset if expiry is greater than 30 days.
|
||||
* @src https://developer.couchbase.com/documentation/server/4.1/developer-guide/expiry.html
|
||||
*/
|
||||
private function normalizeExpiry(int $expiry) : int
|
||||
{
|
||||
if ($expiry > self::THIRTY_DAYS_IN_SECONDS) {
|
||||
return time() + $expiry;
|
||||
}
|
||||
|
||||
return $expiry;
|
||||
}
|
||||
}
|
@@ -1,45 +1,26 @@
|
||||
<?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\Common\Cache;
|
||||
|
||||
use \Couchbase;
|
||||
use Couchbase;
|
||||
use function explode;
|
||||
use function time;
|
||||
|
||||
/**
|
||||
* Couchbase cache provider.
|
||||
*
|
||||
* @link www.doctrine-project.org
|
||||
* @since 2.4
|
||||
* @author Michael Nitschinger <michael@nitschinger.at>
|
||||
* @deprecated Couchbase SDK 1.x is now deprecated. Use \Doctrine\Common\Cache\CouchbaseBucketCache instead.
|
||||
* https://developer.couchbase.com/documentation/server/current/sdk/php/compatibility-versions-features.html
|
||||
*/
|
||||
class CouchbaseCache extends CacheProvider
|
||||
{
|
||||
/**
|
||||
* @var Couchbase|null
|
||||
*/
|
||||
/** @var Couchbase|null */
|
||||
private $couchbase;
|
||||
|
||||
/**
|
||||
* Sets the Couchbase instance to use.
|
||||
*
|
||||
* @param Couchbase $couchbase
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setCouchbase(Couchbase $couchbase)
|
||||
@@ -70,7 +51,7 @@ class CouchbaseCache extends CacheProvider
|
||||
*/
|
||||
protected function doContains($id)
|
||||
{
|
||||
return (null !== $this->couchbase->get($id));
|
||||
return $this->couchbase->get($id) !== null;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -107,8 +88,8 @@ class CouchbaseCache extends CacheProvider
|
||||
{
|
||||
$stats = $this->couchbase->getStats();
|
||||
$servers = $this->couchbase->getServers();
|
||||
$server = explode(":", $servers[0]);
|
||||
$key = $server[0] . ":" . "11210";
|
||||
$server = explode(':', $servers[0]);
|
||||
$key = $server[0] . ':11210';
|
||||
$stats = $stats[$key];
|
||||
return [
|
||||
Cache::STATS_HITS => $stats['get_hits'],
|
||||
|
@@ -2,23 +2,6 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/*
|
||||
* 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\Common\Cache;
|
||||
|
||||
@@ -28,6 +11,9 @@ use MongoDB\Collection;
|
||||
use MongoDB\Database;
|
||||
use MongoDB\Driver\Exception\Exception;
|
||||
use MongoDB\Model\BSONDocument;
|
||||
use function serialize;
|
||||
use function time;
|
||||
use function unserialize;
|
||||
|
||||
/**
|
||||
* MongoDB cache provider for ext-mongodb
|
||||
@@ -36,24 +22,16 @@ use MongoDB\Model\BSONDocument;
|
||||
*/
|
||||
class ExtMongoDBCache extends CacheProvider
|
||||
{
|
||||
/**
|
||||
* @var Database
|
||||
*/
|
||||
/** @var Database */
|
||||
private $database;
|
||||
|
||||
/**
|
||||
* @var Collection
|
||||
*/
|
||||
/** @var Collection */
|
||||
private $collection;
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
/** @var bool */
|
||||
private $expirationIndexCreated = false;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* This provider will default to the write concern and read preference
|
||||
* options set on the Database instance (or inherited from MongoDB or
|
||||
* Client). Using an unacknowledged write concern (< 1) may make the return
|
||||
@@ -62,13 +40,12 @@ class ExtMongoDBCache extends CacheProvider
|
||||
*
|
||||
* @see http://www.php.net/manual/en/mongo.readpreferences.php
|
||||
* @see http://www.php.net/manual/en/mongo.writeconcerns.php
|
||||
* @param Collection $collection
|
||||
*/
|
||||
public function __construct(Collection $collection)
|
||||
{
|
||||
// Ensure there is no typemap set - we want to use our own
|
||||
$this->collection = $collection->withOptions(['typeMap' => null]);
|
||||
$this->database = new Database($collection->getManager(), $collection->getDatabaseName());
|
||||
$this->database = new Database($collection->getManager(), $collection->getDatabaseName());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -119,10 +96,12 @@ class ExtMongoDBCache extends CacheProvider
|
||||
try {
|
||||
$this->collection->updateOne(
|
||||
['_id' => $id],
|
||||
['$set' => [
|
||||
MongoDBCache::EXPIRATION_FIELD => ($lifeTime > 0 ? new UTCDateTime((time() + $lifeTime) * 1000): null),
|
||||
MongoDBCache::DATA_FIELD => new Binary(serialize($data), Binary::TYPE_GENERIC),
|
||||
]],
|
||||
[
|
||||
'$set' => [
|
||||
MongoDBCache::EXPIRATION_FIELD => ($lifeTime > 0 ? new UTCDateTime((time() + $lifeTime) * 1000): null),
|
||||
MongoDBCache::DATA_FIELD => new Binary(serialize($data), Binary::TYPE_GENERIC),
|
||||
],
|
||||
],
|
||||
['upsert' => true]
|
||||
);
|
||||
} catch (Exception $e) {
|
||||
@@ -166,7 +145,7 @@ class ExtMongoDBCache extends CacheProvider
|
||||
*/
|
||||
protected function doGetStats()
|
||||
{
|
||||
$uptime = null;
|
||||
$uptime = null;
|
||||
$memoryUsage = null;
|
||||
|
||||
try {
|
||||
@@ -177,12 +156,12 @@ class ExtMongoDBCache extends CacheProvider
|
||||
'recordStats' => 0,
|
||||
'repl' => 0,
|
||||
])->toArray()[0];
|
||||
$uptime = $serverStatus['uptime'] ?? null;
|
||||
$uptime = $serverStatus['uptime'] ?? null;
|
||||
} catch (Exception $e) {
|
||||
}
|
||||
|
||||
try {
|
||||
$collStats = $this->database->command(['collStats' => $this->collection->getCollectionName()])->toArray()[0];
|
||||
$collStats = $this->database->command(['collStats' => $this->collection->getCollectionName()])->toArray()[0];
|
||||
$memoryUsage = $collStats['size'] ?? null;
|
||||
} catch (Exception $e) {
|
||||
}
|
||||
@@ -198,19 +177,15 @@ class ExtMongoDBCache extends CacheProvider
|
||||
|
||||
/**
|
||||
* Check if the document is expired.
|
||||
*
|
||||
* @param BSONDocument $document
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
private function isExpired(BSONDocument $document): bool
|
||||
private function isExpired(BSONDocument $document) : bool
|
||||
{
|
||||
return isset($document[MongoDBCache::EXPIRATION_FIELD]) &&
|
||||
$document[MongoDBCache::EXPIRATION_FIELD] instanceof UTCDateTime &&
|
||||
$document[MongoDBCache::EXPIRATION_FIELD]->toDateTime() < new \DateTime();
|
||||
}
|
||||
|
||||
private function createExpirationIndex(): void
|
||||
private function createExpirationIndex() : void
|
||||
{
|
||||
if ($this->expirationIndexCreated) {
|
||||
return;
|
||||
|
@@ -1,30 +1,34 @@
|
||||
<?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\Common\Cache;
|
||||
|
||||
use const DIRECTORY_SEPARATOR;
|
||||
use const PATHINFO_DIRNAME;
|
||||
use function bin2hex;
|
||||
use function chmod;
|
||||
use function defined;
|
||||
use function disk_free_space;
|
||||
use function file_exists;
|
||||
use function file_put_contents;
|
||||
use function gettype;
|
||||
use function hash;
|
||||
use function is_dir;
|
||||
use function is_int;
|
||||
use function is_writable;
|
||||
use function mkdir;
|
||||
use function pathinfo;
|
||||
use function realpath;
|
||||
use function rename;
|
||||
use function rmdir;
|
||||
use function sprintf;
|
||||
use function strlen;
|
||||
use function strrpos;
|
||||
use function substr;
|
||||
use function tempnam;
|
||||
use function unlink;
|
||||
|
||||
/**
|
||||
* Base file cache driver.
|
||||
*
|
||||
* @since 2.3
|
||||
* @author Fabio B. Silva <fabio.bat.silva@gmail.com>
|
||||
* @author Tobias Schultze <http://tobion.de>
|
||||
*/
|
||||
abstract class FileCache extends CacheProvider
|
||||
{
|
||||
@@ -42,29 +46,19 @@ abstract class FileCache extends CacheProvider
|
||||
*/
|
||||
private $extension;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
/** @var int */
|
||||
private $umask;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
/** @var int */
|
||||
private $directoryStringLength;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
/** @var int */
|
||||
private $extensionStringLength;
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
/** @var bool */
|
||||
private $isRunningOnWindows;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param string $directory The cache directory.
|
||||
* @param string $extension The cache file extension.
|
||||
*
|
||||
@@ -73,7 +67,7 @@ abstract class FileCache extends CacheProvider
|
||||
public function __construct($directory, $extension = '', $umask = 0002)
|
||||
{
|
||||
// YES, this needs to be *before* createPathIfNeeded()
|
||||
if ( ! is_int($umask)) {
|
||||
if (! is_int($umask)) {
|
||||
throw new \InvalidArgumentException(sprintf(
|
||||
'The umask parameter is required to be integer, was: %s',
|
||||
gettype($umask)
|
||||
@@ -81,14 +75,14 @@ abstract class FileCache extends CacheProvider
|
||||
}
|
||||
$this->umask = $umask;
|
||||
|
||||
if ( ! $this->createPathIfNeeded($directory)) {
|
||||
if (! $this->createPathIfNeeded($directory)) {
|
||||
throw new \InvalidArgumentException(sprintf(
|
||||
'The directory "%s" does not exist and could not be created.',
|
||||
$directory
|
||||
));
|
||||
}
|
||||
|
||||
if ( ! is_writable($directory)) {
|
||||
if (! is_writable($directory)) {
|
||||
throw new \InvalidArgumentException(sprintf(
|
||||
'The directory "%s" is not writable.',
|
||||
$directory
|
||||
@@ -134,8 +128,7 @@ abstract class FileCache extends CacheProvider
|
||||
$hash = hash('sha256', $id);
|
||||
|
||||
// This ensures that the filename is unique and that there are no invalid chars in it.
|
||||
if (
|
||||
'' === $id
|
||||
if ($id === ''
|
||||
|| ((strlen($id) * 2 + $this->extensionStringLength) > 255)
|
||||
|| ($this->isRunningOnWindows && ($this->directoryStringLength + 4 + strlen($id) * 2 + $this->extensionStringLength) > 258)
|
||||
) {
|
||||
@@ -195,9 +188,11 @@ abstract class FileCache extends CacheProvider
|
||||
{
|
||||
$usage = 0;
|
||||
foreach ($this->getIterator() as $name => $file) {
|
||||
if (! $file->isDir() && $this->isFilenameEndingWithExtension($name)) {
|
||||
$usage += $file->getSize();
|
||||
if ($file->isDir() || ! $this->isFilenameEndingWithExtension($name)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$usage += $file->getSize();
|
||||
}
|
||||
|
||||
$free = disk_free_space($this->directory);
|
||||
@@ -214,13 +209,12 @@ abstract class FileCache extends CacheProvider
|
||||
/**
|
||||
* Create path if needed.
|
||||
*
|
||||
* @param string $path
|
||||
* @return bool TRUE on success or if path already exists, FALSE if path cannot be created.
|
||||
*/
|
||||
private function createPathIfNeeded(string $path) : bool
|
||||
{
|
||||
if ( ! is_dir($path)) {
|
||||
if (false === @mkdir($path, 0777 & (~$this->umask), true) && !is_dir($path)) {
|
||||
if (! is_dir($path)) {
|
||||
if (@mkdir($path, 0777 & (~$this->umask), true) === false && ! is_dir($path)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -240,11 +234,11 @@ abstract class FileCache extends CacheProvider
|
||||
{
|
||||
$filepath = pathinfo($filename, PATHINFO_DIRNAME);
|
||||
|
||||
if ( ! $this->createPathIfNeeded($filepath)) {
|
||||
if (! $this->createPathIfNeeded($filepath)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( ! is_writable($filepath)) {
|
||||
if (! is_writable($filepath)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -263,9 +257,6 @@ abstract class FileCache extends CacheProvider
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Iterator
|
||||
*/
|
||||
private function getIterator() : \Iterator
|
||||
{
|
||||
return new \RecursiveIteratorIterator(
|
||||
@@ -276,12 +267,10 @@ abstract class FileCache extends CacheProvider
|
||||
|
||||
/**
|
||||
* @param string $name The filename
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
private function isFilenameEndingWithExtension(string $name) : bool
|
||||
{
|
||||
return '' === $this->extension
|
||||
return $this->extension === ''
|
||||
|| strrpos($name, $this->extension) === (strlen($name) - $this->extensionStringLength);
|
||||
}
|
||||
}
|
||||
|
@@ -1,33 +1,22 @@
|
||||
<?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\Common\Cache;
|
||||
|
||||
use const PHP_EOL;
|
||||
use function fclose;
|
||||
use function fgets;
|
||||
use function fopen;
|
||||
use function is_file;
|
||||
use function serialize;
|
||||
use function time;
|
||||
use function unserialize;
|
||||
|
||||
/**
|
||||
* Filesystem cache driver.
|
||||
*
|
||||
* @since 2.3
|
||||
* @author Fabio B. Silva <fabio.bat.silva@gmail.com>
|
||||
*/
|
||||
class FilesystemCache extends FileCache
|
||||
{
|
||||
const EXTENSION = '.doctrinecache.data';
|
||||
public const EXTENSION = '.doctrinecache.data';
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
@@ -46,13 +35,14 @@ class FilesystemCache extends FileCache
|
||||
$lifetime = -1;
|
||||
$filename = $this->getFilename($id);
|
||||
|
||||
if ( ! is_file($filename)) {
|
||||
if (! is_file($filename)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$resource = fopen($filename, "r");
|
||||
$resource = fopen($filename, 'r');
|
||||
$line = fgets($resource);
|
||||
|
||||
if (false !== ($line = fgets($resource))) {
|
||||
if ($line !== false) {
|
||||
$lifetime = (int) $line;
|
||||
}
|
||||
|
||||
@@ -62,7 +52,7 @@ class FilesystemCache extends FileCache
|
||||
return false;
|
||||
}
|
||||
|
||||
while (false !== ($line = fgets($resource))) {
|
||||
while (($line = fgets($resource)) !== false) {
|
||||
$data .= $line;
|
||||
}
|
||||
|
||||
@@ -79,13 +69,14 @@ class FilesystemCache extends FileCache
|
||||
$lifetime = -1;
|
||||
$filename = $this->getFilename($id);
|
||||
|
||||
if ( ! is_file($filename)) {
|
||||
if (! is_file($filename)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$resource = fopen($filename, "r");
|
||||
$resource = fopen($filename, 'r');
|
||||
$line = fgets($resource);
|
||||
|
||||
if (false !== ($line = fgets($resource))) {
|
||||
if ($line !== false) {
|
||||
$lifetime = (int) $line;
|
||||
}
|
||||
|
||||
@@ -103,8 +94,8 @@ class FilesystemCache extends FileCache
|
||||
$lifeTime = time() + $lifeTime;
|
||||
}
|
||||
|
||||
$data = serialize($data);
|
||||
$filename = $this->getFilename($id);
|
||||
$data = serialize($data);
|
||||
$filename = $this->getFilename($id);
|
||||
|
||||
return $this->writeFile($filename, $lifeTime . PHP_EOL . $data);
|
||||
}
|
||||
|
@@ -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\Common\Cache;
|
||||
|
||||
@@ -23,8 +6,6 @@ namespace Doctrine\Common\Cache;
|
||||
* Interface for cache that can be flushed.
|
||||
*
|
||||
* @link www.doctrine-project.org
|
||||
* @since 1.4
|
||||
* @author Adirelle <adirelle@gmail.com>
|
||||
*/
|
||||
interface FlushableCache
|
||||
{
|
||||
|
@@ -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\Common\Cache;
|
||||
|
||||
@@ -23,28 +6,26 @@ use MongoBinData;
|
||||
use MongoCollection;
|
||||
use MongoCursorException;
|
||||
use MongoDate;
|
||||
use const E_USER_DEPRECATED;
|
||||
use function serialize;
|
||||
use function time;
|
||||
use function trigger_error;
|
||||
use function unserialize;
|
||||
|
||||
/**
|
||||
* MongoDB cache provider.
|
||||
*
|
||||
* @author Jeremy Mikola <jmikola@gmail.com>
|
||||
* @internal Do not use - will be removed in 2.0. Use MongoDBCache instead
|
||||
*/
|
||||
class LegacyMongoDBCache extends CacheProvider
|
||||
{
|
||||
/**
|
||||
* @var MongoCollection
|
||||
*/
|
||||
/** @var MongoCollection */
|
||||
private $collection;
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
/** @var bool */
|
||||
private $expirationIndexCreated = false;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* This provider will default to the write concern and read preference
|
||||
* options set on the MongoCollection instance (or inherited from MongoDB or
|
||||
* MongoClient). Using an unacknowledged write concern (< 1) may make the
|
||||
@@ -53,7 +34,6 @@ class LegacyMongoDBCache extends CacheProvider
|
||||
*
|
||||
* @see http://www.php.net/manual/en/mongo.readpreferences.php
|
||||
* @see http://www.php.net/manual/en/mongo.writeconcerns.php
|
||||
* @param MongoCollection $collection
|
||||
*/
|
||||
public function __construct(MongoCollection $collection)
|
||||
{
|
||||
@@ -109,10 +89,12 @@ class LegacyMongoDBCache extends CacheProvider
|
||||
try {
|
||||
$result = $this->collection->update(
|
||||
['_id' => $id],
|
||||
['$set' => [
|
||||
MongoDBCache::EXPIRATION_FIELD => ($lifeTime > 0 ? new MongoDate(time() + $lifeTime) : null),
|
||||
MongoDBCache::DATA_FIELD => new MongoBinData(serialize($data), MongoBinData::BYTE_ARRAY),
|
||||
]],
|
||||
[
|
||||
'$set' => [
|
||||
MongoDBCache::EXPIRATION_FIELD => ($lifeTime > 0 ? new MongoDate(time() + $lifeTime) : null),
|
||||
MongoDBCache::DATA_FIELD => new MongoBinData(serialize($data), MongoBinData::BYTE_ARRAY),
|
||||
],
|
||||
],
|
||||
['upsert' => true, 'multiple' => false]
|
||||
);
|
||||
} catch (MongoCursorException $e) {
|
||||
@@ -171,8 +153,6 @@ class LegacyMongoDBCache extends CacheProvider
|
||||
* Check if the document is expired.
|
||||
*
|
||||
* @param array $document
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
private function isExpired(array $document) : bool
|
||||
{
|
||||
@@ -182,7 +162,7 @@ class LegacyMongoDBCache extends CacheProvider
|
||||
}
|
||||
|
||||
|
||||
private function createExpirationIndex(): void
|
||||
private function createExpirationIndex() : void
|
||||
{
|
||||
if ($this->expirationIndexCreated) {
|
||||
return;
|
||||
|
@@ -1,49 +1,25 @@
|
||||
<?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\Common\Cache;
|
||||
|
||||
use \Memcache;
|
||||
use Memcache;
|
||||
use function time;
|
||||
|
||||
/**
|
||||
* Memcache cache provider.
|
||||
*
|
||||
* @link www.doctrine-project.org
|
||||
* @since 2.0
|
||||
* @author Benjamin Eberlei <kontakt@beberlei.de>
|
||||
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
|
||||
* @author Jonathan Wage <jonwage@gmail.com>
|
||||
* @author Roman Borschel <roman@code-factory.org>
|
||||
* @author David Abdemoulaie <dave@hobodave.com>
|
||||
*
|
||||
* @deprecated
|
||||
*/
|
||||
class MemcacheCache extends CacheProvider
|
||||
{
|
||||
/**
|
||||
* @var Memcache|null
|
||||
*/
|
||||
/** @var Memcache|null */
|
||||
private $memcache;
|
||||
|
||||
/**
|
||||
* Sets the memcache instance to use.
|
||||
*
|
||||
* @param Memcache $memcache
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setMemcache(Memcache $memcache)
|
||||
@@ -76,9 +52,9 @@ class MemcacheCache extends CacheProvider
|
||||
{
|
||||
$flags = null;
|
||||
$this->memcache->get($id, $flags);
|
||||
|
||||
|
||||
//if memcache has changed the value of "flags", it means the value exists
|
||||
return ($flags !== null);
|
||||
return $flags !== null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -1,49 +1,23 @@
|
||||
<?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\Common\Cache;
|
||||
|
||||
use \Memcached;
|
||||
use Memcached;
|
||||
use function time;
|
||||
|
||||
/**
|
||||
* Memcached cache provider.
|
||||
*
|
||||
* @link www.doctrine-project.org
|
||||
* @since 2.2
|
||||
* @author Benjamin Eberlei <kontakt@beberlei.de>
|
||||
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
|
||||
* @author Jonathan Wage <jonwage@gmail.com>
|
||||
* @author Roman Borschel <roman@code-factory.org>
|
||||
* @author David Abdemoulaie <dave@hobodave.com>
|
||||
*/
|
||||
class MemcachedCache extends CacheProvider
|
||||
{
|
||||
/**
|
||||
* @var Memcached|null
|
||||
*/
|
||||
/** @var Memcached|null */
|
||||
private $memcached;
|
||||
|
||||
/**
|
||||
* Sets the memcache instance to use.
|
||||
*
|
||||
* @param Memcached $memcached
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setMemcached(Memcached $memcached)
|
||||
|
@@ -1,39 +1,21 @@
|
||||
<?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\Common\Cache;
|
||||
|
||||
use MongoCollection;
|
||||
use MongoDB\Collection;
|
||||
use const E_USER_DEPRECATED;
|
||||
use function trigger_error;
|
||||
|
||||
/**
|
||||
* MongoDB cache provider.
|
||||
*
|
||||
* @since 1.1
|
||||
* @author Jeremy Mikola <jmikola@gmail.com>
|
||||
*/
|
||||
class MongoDBCache extends CacheProvider
|
||||
{
|
||||
/**
|
||||
* The data field will store the serialized PHP value.
|
||||
*/
|
||||
const DATA_FIELD = 'd';
|
||||
public const DATA_FIELD = 'd';
|
||||
|
||||
/**
|
||||
* The expiration field will store a MongoDate value indicating when the
|
||||
@@ -50,16 +32,12 @@ class MongoDBCache extends CacheProvider
|
||||
*
|
||||
* @see http://docs.mongodb.org/manual/tutorial/expire-data/
|
||||
*/
|
||||
const EXPIRATION_FIELD = 'e';
|
||||
public const EXPIRATION_FIELD = 'e';
|
||||
|
||||
/**
|
||||
* @var CacheProvider
|
||||
*/
|
||||
/** @var CacheProvider */
|
||||
private $provider;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* This provider will default to the write concern and read preference
|
||||
* options set on the collection instance (or inherited from MongoDB or
|
||||
* MongoClient). Using an unacknowledged write concern (< 1) may make the
|
||||
|
@@ -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\Common\Cache;
|
||||
|
||||
@@ -23,9 +6,6 @@ namespace Doctrine\Common\Cache;
|
||||
* Interface for cache drivers that allows to put many items at once.
|
||||
*
|
||||
* @link www.doctrine-project.org
|
||||
* @since 1.7
|
||||
* @author Benoit Burnichon <bburnichon@gmail.com>
|
||||
*
|
||||
* @deprecated
|
||||
*/
|
||||
interface MultiDeleteCache
|
||||
@@ -37,5 +17,5 @@ interface MultiDeleteCache
|
||||
*
|
||||
* @return bool TRUE if the operation was successful, FALSE if it wasn't.
|
||||
*/
|
||||
function deleteMultiple(array $keys);
|
||||
public function deleteMultiple(array $keys);
|
||||
}
|
||||
|
@@ -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\Common\Cache;
|
||||
|
||||
@@ -23,9 +6,6 @@ namespace Doctrine\Common\Cache;
|
||||
* Interface for cache drivers that allows to get many items at once.
|
||||
*
|
||||
* @link www.doctrine-project.org
|
||||
* @since 1.4
|
||||
* @author Asmir Mustafic <goetas@gmail.com>
|
||||
*
|
||||
* @deprecated
|
||||
*/
|
||||
interface MultiGetCache
|
||||
@@ -37,5 +17,5 @@ interface MultiGetCache
|
||||
* @return mixed[] Array of retrieved values, indexed by the specified keys.
|
||||
* Values that couldn't be retrieved are not contained in this array.
|
||||
*/
|
||||
function fetchMultiple(array $keys);
|
||||
public function fetchMultiple(array $keys);
|
||||
}
|
||||
|
@@ -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\Common\Cache;
|
||||
|
||||
@@ -23,8 +6,6 @@ namespace Doctrine\Common\Cache;
|
||||
* Interface for cache drivers that supports multiple items manipulation.
|
||||
*
|
||||
* @link www.doctrine-project.org
|
||||
* @since 1.7
|
||||
* @author Luís Cobucci <lcobucci@gmail.com>
|
||||
*/
|
||||
interface MultiOperationCache extends MultiGetCache, MultiDeleteCache, MultiPutCache
|
||||
{
|
||||
|
@@ -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\Common\Cache;
|
||||
|
||||
@@ -23,9 +6,6 @@ namespace Doctrine\Common\Cache;
|
||||
* Interface for cache drivers that allows to put many items at once.
|
||||
*
|
||||
* @link www.doctrine-project.org
|
||||
* @since 1.6
|
||||
* @author Daniel Gorgan <danut007ro@gmail.com>
|
||||
*
|
||||
* @deprecated
|
||||
*/
|
||||
interface MultiPutCache
|
||||
@@ -33,11 +13,11 @@ interface MultiPutCache
|
||||
/**
|
||||
* Returns a boolean value indicating if the operation succeeded.
|
||||
*
|
||||
* @param array $keysAndValues Array of keys and values to save in cache
|
||||
* @param int $lifetime The lifetime. If != 0, sets a specific lifetime for these
|
||||
* cache entries (0 => infinite lifeTime).
|
||||
* @param array $keysAndValues Array of keys and values to save in cache
|
||||
* @param int $lifetime The lifetime. If != 0, sets a specific lifetime for these
|
||||
* cache entries (0 => infinite lifeTime).
|
||||
*
|
||||
* @return bool TRUE if the operation was successful, FALSE if it wasn't.
|
||||
*/
|
||||
function saveMultiple(array $keysAndValues, $lifetime = 0);
|
||||
public function saveMultiple(array $keysAndValues, $lifetime = 0);
|
||||
}
|
||||
|
@@ -1,33 +1,22 @@
|
||||
<?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\Common\Cache;
|
||||
|
||||
use function is_object;
|
||||
use function method_exists;
|
||||
use function restore_error_handler;
|
||||
use function serialize;
|
||||
use function set_error_handler;
|
||||
use function sprintf;
|
||||
use function time;
|
||||
use function var_export;
|
||||
|
||||
/**
|
||||
* Php file cache driver.
|
||||
*
|
||||
* @since 2.3
|
||||
* @author Fabio B. Silva <fabio.bat.silva@gmail.com>
|
||||
*/
|
||||
class PhpFileCache extends FileCache
|
||||
{
|
||||
const EXTENSION = '.doctrinecache.php';
|
||||
public const EXTENSION = '.doctrinecache.php';
|
||||
|
||||
/**
|
||||
* @var callable
|
||||
@@ -88,27 +77,25 @@ class PhpFileCache extends FileCache
|
||||
$lifeTime = time() + $lifeTime;
|
||||
}
|
||||
|
||||
$filename = $this->getFilename($id);
|
||||
$filename = $this->getFilename($id);
|
||||
|
||||
$value = [
|
||||
'lifetime' => $lifeTime,
|
||||
'data' => $data
|
||||
'data' => $data,
|
||||
];
|
||||
|
||||
if (is_object($data) && method_exists($data, '__set_state')) {
|
||||
$value = var_export($value, true);
|
||||
$code = sprintf('<?php return %s;', $value);
|
||||
$value = var_export($value, true);
|
||||
$code = sprintf('<?php return %s;', $value);
|
||||
} else {
|
||||
$value = var_export(serialize($value), true);
|
||||
$code = sprintf('<?php return unserialize(%s);', $value);
|
||||
$value = var_export(serialize($value), true);
|
||||
$code = sprintf('<?php return unserialize(%s);', $value);
|
||||
}
|
||||
|
||||
return $this->writeFile($filename, $code);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $id
|
||||
*
|
||||
* @return array|null
|
||||
*/
|
||||
private function includeFileForId(string $id) : ?array
|
||||
|
@@ -1,43 +1,23 @@
|
||||
<?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\Common\Cache;
|
||||
|
||||
use Predis\ClientInterface;
|
||||
use function array_combine;
|
||||
use function array_filter;
|
||||
use function array_map;
|
||||
use function call_user_func_array;
|
||||
use function serialize;
|
||||
use function unserialize;
|
||||
|
||||
/**
|
||||
* Predis cache provider.
|
||||
*
|
||||
* @author othillo <othillo@othillo.nl>
|
||||
*/
|
||||
class PredisCache extends CacheProvider
|
||||
{
|
||||
/**
|
||||
* @var ClientInterface
|
||||
*/
|
||||
/** @var ClientInterface */
|
||||
private $client;
|
||||
|
||||
/**
|
||||
* @param ClientInterface $client
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(ClientInterface $client)
|
||||
{
|
||||
$this->client = $client;
|
||||
@@ -49,7 +29,7 @@ class PredisCache extends CacheProvider
|
||||
protected function doFetch($id)
|
||||
{
|
||||
$result = $this->client->get($id);
|
||||
if (null === $result) {
|
||||
if ($result === null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -76,11 +56,13 @@ class PredisCache extends CacheProvider
|
||||
|
||||
// Keys have lifetime, use SETEX for each of them
|
||||
foreach ($keysAndValues as $key => $value) {
|
||||
$response = $this->client->setex($key, $lifetime, serialize($value));
|
||||
$response = (string) $this->client->setex($key, $lifetime, serialize($value));
|
||||
|
||||
if ((string) $response != 'OK') {
|
||||
$success = false;
|
||||
if ($response == 'OK') {
|
||||
continue;
|
||||
}
|
||||
|
||||
$success = false;
|
||||
}
|
||||
|
||||
return $success;
|
||||
@@ -155,7 +137,7 @@ class PredisCache extends CacheProvider
|
||||
Cache::STATS_MISSES => $info['Stats']['keyspace_misses'],
|
||||
Cache::STATS_UPTIME => $info['Server']['uptime_in_seconds'],
|
||||
Cache::STATS_MEMORY_USAGE => $info['Memory']['used_memory'],
|
||||
Cache::STATS_MEMORY_AVAILABLE => false
|
||||
Cache::STATS_MEMORY_AVAILABLE => false,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
@@ -1,45 +1,26 @@
|
||||
<?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\Common\Cache;
|
||||
|
||||
use Redis;
|
||||
use function array_combine;
|
||||
use function defined;
|
||||
use function extension_loaded;
|
||||
use function is_bool;
|
||||
|
||||
/**
|
||||
* Redis cache provider.
|
||||
*
|
||||
* @link www.doctrine-project.org
|
||||
* @since 2.2
|
||||
* @author Osman Ungur <osmanungur@gmail.com>
|
||||
*/
|
||||
class RedisCache extends CacheProvider
|
||||
{
|
||||
/**
|
||||
* @var Redis|null
|
||||
*/
|
||||
/** @var Redis|null */
|
||||
private $redis;
|
||||
|
||||
/**
|
||||
* Sets the redis instance to use.
|
||||
*
|
||||
* @param Redis $redis
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setRedis(Redis $redis)
|
||||
@@ -74,12 +55,14 @@ class RedisCache extends CacheProvider
|
||||
$fetchedItems = array_combine($keys, $this->redis->mget($keys));
|
||||
|
||||
// Redis mget returns false for keys that do not exist. So we need to filter those out unless it's the real data.
|
||||
$foundItems = [];
|
||||
$foundItems = [];
|
||||
|
||||
foreach ($fetchedItems as $key => $value) {
|
||||
if (false !== $value || $this->redis->exists($key)) {
|
||||
$foundItems[$key] = $value;
|
||||
if ($value === false && ! $this->redis->exists($key)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$foundItems[$key] = $value;
|
||||
}
|
||||
|
||||
return $foundItems;
|
||||
@@ -95,9 +78,11 @@ class RedisCache extends CacheProvider
|
||||
|
||||
// Keys have lifetime, use SETEX for each of them
|
||||
foreach ($keysAndValues as $key => $value) {
|
||||
if (!$this->redis->setex($key, $lifetime, $value)) {
|
||||
$success = false;
|
||||
if ($this->redis->setex($key, $lifetime, $value)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$success = false;
|
||||
}
|
||||
|
||||
return $success;
|
||||
@@ -112,7 +97,13 @@ class RedisCache extends CacheProvider
|
||||
*/
|
||||
protected function doContains($id)
|
||||
{
|
||||
return $this->redis->exists($id);
|
||||
$exists = $this->redis->exists($id);
|
||||
|
||||
if (is_bool($exists)) {
|
||||
return $exists;
|
||||
}
|
||||
|
||||
return $exists > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -162,7 +153,7 @@ class RedisCache extends CacheProvider
|
||||
Cache::STATS_MISSES => $info['keyspace_misses'],
|
||||
Cache::STATS_UPTIME => $info['uptime_in_seconds'],
|
||||
Cache::STATS_MEMORY_USAGE => $info['used_memory'],
|
||||
Cache::STATS_MEMORY_AVAILABLE => false
|
||||
Cache::STATS_MEMORY_AVAILABLE => false,
|
||||
];
|
||||
}
|
||||
|
||||
@@ -171,7 +162,7 @@ class RedisCache extends CacheProvider
|
||||
* igbinary support, that is used. Otherwise the default PHP serializer is
|
||||
* used.
|
||||
*
|
||||
* @return integer One of the Redis::SERIALIZER_* constants
|
||||
* @return int One of the Redis::SERIALIZER_* constants
|
||||
*/
|
||||
protected function getSerializerValue()
|
||||
{
|
||||
|
@@ -1,49 +1,32 @@
|
||||
<?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\Common\Cache;
|
||||
|
||||
use Riak\Bucket;
|
||||
use Riak\Input;
|
||||
use Riak\Exception;
|
||||
use Riak\Input;
|
||||
use Riak\Object;
|
||||
use function count;
|
||||
use function serialize;
|
||||
use function time;
|
||||
use function unserialize;
|
||||
|
||||
/**
|
||||
* Riak cache provider.
|
||||
*
|
||||
* @link www.doctrine-project.org
|
||||
* @since 1.1
|
||||
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
|
||||
*
|
||||
* @deprecated
|
||||
*/
|
||||
class RiakCache extends CacheProvider
|
||||
{
|
||||
const EXPIRES_HEADER = 'X-Riak-Meta-Expires';
|
||||
public const EXPIRES_HEADER = 'X-Riak-Meta-Expires';
|
||||
|
||||
/**
|
||||
* @var \Riak\Bucket
|
||||
*/
|
||||
/** @var Bucket */
|
||||
private $bucket;
|
||||
|
||||
/**
|
||||
* Sets the riak bucket instance to use.
|
||||
*
|
||||
* @param \Riak\Bucket $bucket
|
||||
*/
|
||||
public function __construct(Bucket $bucket)
|
||||
{
|
||||
@@ -59,7 +42,7 @@ class RiakCache extends CacheProvider
|
||||
$response = $this->bucket->get($id);
|
||||
|
||||
// No objects found
|
||||
if ( ! $response->hasObject()) {
|
||||
if (! $response->hasObject()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -101,7 +84,7 @@ class RiakCache extends CacheProvider
|
||||
$response = $this->bucket->get($id, $input);
|
||||
|
||||
// No objects found
|
||||
if ( ! $response->hasObject()) {
|
||||
if (! $response->hasObject()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -198,10 +181,6 @@ class RiakCache extends CacheProvider
|
||||
|
||||
/**
|
||||
* Check if a given Riak Object have expired.
|
||||
*
|
||||
* @param \Riak\Object $object
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
private function isExpired(Object $object) : bool
|
||||
{
|
||||
@@ -229,12 +208,12 @@ class RiakCache extends CacheProvider
|
||||
* @param string $vClock
|
||||
* @param array $objectList
|
||||
*
|
||||
* @return \Riak\Object
|
||||
* @return Object
|
||||
*/
|
||||
protected function resolveConflict($id, $vClock, array $objectList)
|
||||
{
|
||||
// Our approach here is last-write wins
|
||||
$winner = $objectList[count($objectList)];
|
||||
$winner = $objectList[count($objectList) - 1];
|
||||
|
||||
$putInput = new Input\PutInput();
|
||||
$putInput->setVClock($vClock);
|
||||
|
@@ -1,68 +1,50 @@
|
||||
<?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\Common\Cache;
|
||||
|
||||
use SQLite3;
|
||||
use SQLite3Result;
|
||||
use const SQLITE3_ASSOC;
|
||||
use const SQLITE3_BLOB;
|
||||
use const SQLITE3_TEXT;
|
||||
use function array_search;
|
||||
use function implode;
|
||||
use function serialize;
|
||||
use function sprintf;
|
||||
use function time;
|
||||
use function unserialize;
|
||||
|
||||
/**
|
||||
* SQLite3 cache provider.
|
||||
*
|
||||
* @since 1.4
|
||||
* @author Jake Bell <jake@theunraveler.com>
|
||||
*/
|
||||
class SQLite3Cache extends CacheProvider
|
||||
{
|
||||
/**
|
||||
* The ID field will store the cache key.
|
||||
*/
|
||||
const ID_FIELD = 'k';
|
||||
public const ID_FIELD = 'k';
|
||||
|
||||
/**
|
||||
* The data field will store the serialized PHP value.
|
||||
*/
|
||||
const DATA_FIELD = 'd';
|
||||
public const DATA_FIELD = 'd';
|
||||
|
||||
/**
|
||||
* The expiration field will store a date value indicating when the
|
||||
* cache entry should expire.
|
||||
*/
|
||||
const EXPIRATION_FIELD = 'e';
|
||||
public const EXPIRATION_FIELD = 'e';
|
||||
|
||||
/**
|
||||
* @var SQLite3
|
||||
*/
|
||||
/** @var SQLite3 */
|
||||
private $sqlite;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
/** @var string */
|
||||
private $table;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* Calling the constructor will ensure that the database file and table
|
||||
* exist and will create both if they don't.
|
||||
*
|
||||
* @param SQLite3 $sqlite
|
||||
* @param string $table
|
||||
*/
|
||||
public function __construct(SQLite3 $sqlite, $table)
|
||||
@@ -70,15 +52,20 @@ class SQLite3Cache extends CacheProvider
|
||||
$this->sqlite = $sqlite;
|
||||
$this->table = (string) $table;
|
||||
|
||||
list($id, $data, $exp) = $this->getFields();
|
||||
$this->ensureTableExists();
|
||||
}
|
||||
|
||||
return $this->sqlite->exec(sprintf(
|
||||
'CREATE TABLE IF NOT EXISTS %s(%s TEXT PRIMARY KEY NOT NULL, %s BLOB, %s INTEGER)',
|
||||
$table,
|
||||
$id,
|
||||
$data,
|
||||
$exp
|
||||
));
|
||||
private function ensureTableExists() : void
|
||||
{
|
||||
$this->sqlite->exec(
|
||||
sprintf(
|
||||
'CREATE TABLE IF NOT EXISTS %s(%s TEXT PRIMARY KEY NOT NULL, %s BLOB, %s INTEGER)',
|
||||
$this->table,
|
||||
static::ID_FIELD,
|
||||
static::DATA_FIELD,
|
||||
static::EXPIRATION_FIELD
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -88,7 +75,7 @@ class SQLite3Cache extends CacheProvider
|
||||
{
|
||||
$item = $this->findById($id);
|
||||
|
||||
if (!$item) {
|
||||
if (! $item) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -100,7 +87,7 @@ class SQLite3Cache extends CacheProvider
|
||||
*/
|
||||
protected function doContains($id)
|
||||
{
|
||||
return null !== $this->findById($id, false);
|
||||
return $this->findById($id, false) !== null;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -159,7 +146,6 @@ class SQLite3Cache extends CacheProvider
|
||||
* Find a single row by ID.
|
||||
*
|
||||
* @param mixed $id
|
||||
* @param bool $includeData
|
||||
*
|
||||
* @return array|null
|
||||
*/
|
||||
@@ -167,7 +153,7 @@ class SQLite3Cache extends CacheProvider
|
||||
{
|
||||
list($idField) = $fields = $this->getFields();
|
||||
|
||||
if (!$includeData) {
|
||||
if (! $includeData) {
|
||||
$key = array_search(static::DATA_FIELD, $fields);
|
||||
unset($fields[$key]);
|
||||
}
|
||||
@@ -210,8 +196,6 @@ class SQLite3Cache extends CacheProvider
|
||||
* Check if the item is expired.
|
||||
*
|
||||
* @param array $item
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
private function isExpired(array $item) : bool
|
||||
{
|
||||
|
@@ -1,25 +1,8 @@
|
||||
<?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\Common\Cache;
|
||||
|
||||
class Version
|
||||
{
|
||||
const VERSION = '1.7.1';
|
||||
public const VERSION = '1.8.0';
|
||||
}
|
||||
|
@@ -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\Common\Cache;
|
||||
|
||||
@@ -23,8 +6,6 @@ namespace Doctrine\Common\Cache;
|
||||
* Void cache driver. The cache could be of use in tests where you don`t need to cache anything.
|
||||
*
|
||||
* @link www.doctrine-project.org
|
||||
* @since 1.5
|
||||
* @author Kotlyar Maksim <kotlyar.maksim@gmail.com>
|
||||
*/
|
||||
class VoidCache extends CacheProvider
|
||||
{
|
||||
|
@@ -1,34 +1,21 @@
|
||||
<?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\Common\Cache;
|
||||
|
||||
use function count;
|
||||
use function is_array;
|
||||
use function wincache_ucache_clear;
|
||||
use function wincache_ucache_delete;
|
||||
use function wincache_ucache_exists;
|
||||
use function wincache_ucache_get;
|
||||
use function wincache_ucache_info;
|
||||
use function wincache_ucache_meminfo;
|
||||
use function wincache_ucache_set;
|
||||
|
||||
/**
|
||||
* WinCache cache provider.
|
||||
*
|
||||
* @link www.doctrine-project.org
|
||||
* @since 2.2
|
||||
* @author Benjamin Eberlei <kontakt@beberlei.de>
|
||||
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
|
||||
* @author Jonathan Wage <jonwage@gmail.com>
|
||||
* @author Roman Borschel <roman@code-factory.org>
|
||||
* @author David Abdemoulaie <dave@hobodave.com>
|
||||
*/
|
||||
class WinCacheCache extends CacheProvider
|
||||
{
|
||||
|
@@ -1,34 +1,24 @@
|
||||
<?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\Common\Cache;
|
||||
|
||||
use const XC_TYPE_VAR;
|
||||
use function ini_get;
|
||||
use function serialize;
|
||||
use function unserialize;
|
||||
use function xcache_clear_cache;
|
||||
use function xcache_get;
|
||||
use function xcache_info;
|
||||
use function xcache_isset;
|
||||
use function xcache_set;
|
||||
use function xcache_unset;
|
||||
|
||||
/**
|
||||
* Xcache cache driver.
|
||||
*
|
||||
* @link www.doctrine-project.org
|
||||
* @since 2.0
|
||||
* @author Benjamin Eberlei <kontakt@beberlei.de>
|
||||
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
|
||||
* @author Jonathan Wage <jonwage@gmail.com>
|
||||
* @author Roman Borschel <roman@code-factory.org>
|
||||
* @author David Abdemoulaie <dave@hobodave.com>
|
||||
*
|
||||
* @deprecated
|
||||
*/
|
||||
class XcacheCache extends CacheProvider
|
||||
{
|
||||
|
@@ -1,31 +1,16 @@
|
||||
<?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\Common\Cache;
|
||||
|
||||
use function zend_shm_cache_clear;
|
||||
use function zend_shm_cache_delete;
|
||||
use function zend_shm_cache_fetch;
|
||||
use function zend_shm_cache_store;
|
||||
|
||||
/**
|
||||
* Zend Data Cache cache driver.
|
||||
*
|
||||
* @link www.doctrine-project.org
|
||||
* @since 2.0
|
||||
* @author Ralph Schindler <ralph.schindler@zend.com>
|
||||
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
|
||||
*/
|
||||
class ZendDataCache extends CacheProvider
|
||||
{
|
||||
@@ -42,7 +27,7 @@ class ZendDataCache extends CacheProvider
|
||||
*/
|
||||
protected function doContains($id)
|
||||
{
|
||||
return (false !== zend_shm_cache_fetch($id));
|
||||
return zend_shm_cache_fetch($id) !== false;
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user