diff --git a/.ci/mongodb.ini b/.ci/mongodb.ini new file mode 100644 index 000000000..45969d065 --- /dev/null +++ b/.ci/mongodb.ini @@ -0,0 +1 @@ +extension=mongodb.so diff --git a/.travis.yml b/.travis.yml index 846f6cedb..47cebbe5d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -15,6 +15,7 @@ env: global: - COMPOSER_ARGS="--no-interaction" - COVERAGE_DEPS="php-coveralls/php-coveralls" + - EXTMONGODB_DEPS="mongodb/mongodb" - TESTS_ZEND_CACHE_APC_ENABLED=true - TESTS_ZEND_CACHE_APCU_ENABLED=true - TESTS_ZEND_CACHE_FILESYSTEM_DIR=/dev/shm @@ -25,6 +26,7 @@ env: - TESTS_ZEND_CACHE_MEMCACHE_HOST=$TESTS_ZEND_CACHE_MEMCACHED_HOST - TESTS_ZEND_CACHE_MEMCACHE_PORT=$TESTS_ZEND_CACHE_MEMCACHED_PORT - TESTS_ZEND_CACHE_MONGODB_ENABLED=true + - TESTS_ZEND_CACHE_EXTMONGODB_ENABLED=true - TESTS_ZEND_CACHE_REDIS_ENABLED=true - TESTS_ZEND_CACHE_REDIS_HOST="127.0.0.1" - TESTS_ZEND_CACHE_REDIS_PORT=6379 @@ -42,6 +44,7 @@ matrix: env: - DEPS=lowest - APCU_PECL_VERSION="apcu-4.0.8" + - TESTS_ZEND_CACHE_EXTMONGODB_ENABLED=false - TESTS_ZEND_CACHE_MEMCACHE_ENABLED=true - TESTS_ZEND_CACHE_XCACHE_ENABLED=true - php: 5.6 @@ -49,12 +52,14 @@ matrix: - DEPS=locked - LEGACY_DEPS="phpbench/phpbench phpunit/phpunit" - APCU_PECL_VERSION="apcu-4.0.10" + - TESTS_ZEND_CACHE_EXTMONGODB_ENABLED=false - TESTS_ZEND_CACHE_MEMCACHE_ENABLED=true - TESTS_ZEND_CACHE_XCACHE_ENABLED=true - php: 5.6 env: - DEPS=latest - APCU_PECL_VERSION="apcu-4.0.11" + - TESTS_ZEND_CACHE_EXTMONGODB_ENABLED=false - TESTS_ZEND_CACHE_MEMCACHE_ENABLED=true - TESTS_ZEND_CACHE_XCACHE_ENABLED=true - php: 7 @@ -63,6 +68,7 @@ matrix: - APCU_PECL_VERSION="apcu-5.1.2" - APCU_BC_PECL_VERSION="apcu_bc-1.0.0" - TESTS_ZEND_CACHE_MONGODB_USE_POLYFILL=true + - TESTS_ZEND_CACHE_EXTMONGODB_ENABLED=false - php: 7 env: - DEPS=locked @@ -70,12 +76,14 @@ matrix: - APCU_PECL_VERSION="apcu-5.1.8" - APCU_BC_PECL_VERSION="apcu_bc-1.0.2" - TESTS_ZEND_CACHE_MONGODB_USE_POLYFILL=true + - TESTS_ZEND_CACHE_EXTMONGODB_ENABLED=false - php: 7 env: - DEPS=latest - APCU_PECL_VERSION="apcu" - APCU_BC_PECL_VERSION="apcu_bc-1.0.3" - TESTS_ZEND_CACHE_MONGODB_USE_POLYFILL=true + - TESTS_ZEND_CACHE_EXTMONGODB_ENABLED=false - php: 7.1 env: - DEPS=lowest @@ -158,10 +166,14 @@ install: phpenv config-add .ci/memcached.ini ; fi ; - if [[ $TESTS_ZEND_CACHE_MONGODB_ENABLED == 'true' && $TESTS_ZEND_CACHE_MONGODB_USE_POLYFILL != 'true' ]]; then + - if [[ $TESTS_ZEND_CACHE_MONGODB_ENABLED == 'true' && $TESTS_ZEND_CACHE_MONGODB_USE_POLYFILL != 'true' ]]; then phpenv config-add .ci/mongo.ini ; fi ; + - if [[ $TESTS_ZEND_CACHE_EXTMONGODB_ENABLED == 'true' ]]; then + phpenv config-add .ci/mongodb.ini ; + fi ; + - if [[ $TESTS_ZEND_CACHE_XCACHE_ENABLED == 'true' ]]; then phpenv config-add .ci/xcache.ini ; fi ; @@ -171,7 +183,8 @@ install: - if [[ $DEPS == 'latest' ]]; then travis_retry composer update $COMPOSER_ARGS ; fi - if [[ $DEPS == 'lowest' ]]; then travis_retry composer update --prefer-lowest --prefer-stable $COMPOSER_ARGS ; fi - if [[ $TEST_COVERAGE == 'true' ]]; then travis_retry composer require --dev $COMPOSER_ARGS $COVERAGE_DEPS ; fi - - if [[ $TESTS_ZEND_CACHE_MONGODB_USE_POLYFILL == 'true' ]]; then travis_retry composer require --dev --no-update mongofill/mongofill:dev-master ; fi + - if [[ $TESTS_ZEND_CACHE_MONGODB_USE_POLYFILL == 'true' ]]; then travis_retry composer require --dev --no-update $COMPOSER_ARGS mongofill/mongofill:dev-master ; fi + - if [[ $TESTS_ZEND_CACHE_EXTMONGODB_ENABLED == 'true' ]]; then travis_retry composer require --dev --no-update $COMPOSER_ARGS $EXTMONGODB_DEPS ; fi - stty cols 120 && composer show - pecl list - php -m diff --git a/composer.json b/composer.json index 5e1bda47e..cce7cde48 100644 --- a/composer.json +++ b/composer.json @@ -39,9 +39,11 @@ "ext-memcache": "Memcache >= 2.0.0 to use the Memcache storage adapter", "ext-memcached": "Memcached >= 1.0.0 to use the Memcached storage adapter", "ext-mongo": "Mongo, to use MongoDb storage adapter", + "ext-mongodb": "MongoDB, to use the ExtMongoDb storage adapter", "ext-redis": "Redis, to use Redis storage adapter", "ext-wincache": "WinCache, to use the WinCache storage adapter", "ext-xcache": "XCache, to use the XCache storage adapter", + "mongodb/mongodb": "Required for use with the ext-mongodb adapter", "mongofill/mongofill": "Alternative to ext-mongo - a pure PHP implementation designed as a drop in replacement" }, "autoload": { diff --git a/docs/book/storage/adapter.md b/docs/book/storage/adapter.md index 48ab64fe0..c2834eb89 100644 --- a/docs/book/storage/adapter.md +++ b/docs/book/storage/adapter.md @@ -795,6 +795,11 @@ Name | Data Type | Default Value | Description PHP extension [mongo](http://php.net/mongo), or a MongoDB polyfill library, such as [Mongofill](https://github.com/mongofill/mongofill). +> #### ext-mongodb +> +> If you are using the mongodb extension (vs the mongo extension), you will need +> to use the [ExtMongoDb adapter](#the-extmongodb-adapter) instead. + This adapter implements the following interfaces: - `Zend\Cache\Storage\FlushableInterface` @@ -832,6 +837,60 @@ Key | Default | Description `connectionOptions` | `['fsync' => false, 'journal' => true]` | Associative array of options to pass to `MongoClient` (see the [MongoClient docs](http://php.net/MongoClient)). `driverOptions` | `[]` | Associative array of driver options to pass to `MongoClient` (see the [MongoClient docs](http://php.net/MongoClient)). +## The ExtMongoDB Adapter + +- Since 2.8.0 + +`Zend\Cache\Storage\Adapter\ExtMongoDB` stores cache items using the mongodb extension, and +requires that the MongoDB PHP Client library is also installed. You can install the client +library using the following: + +```bash +$ composer require mongodb/mongodb +``` + +> #### ext-mongo +> +> If you are using the mongo extension (vs the mongodb extension), you will need +> to use the [MongoDb adapter](#the-mongodb-adapter) instead. + +This adapter implements the following interfaces: + +- `Zend\Cache\Storage\FlushableInterface` + +### Capabilities + +Capability | Value +---------- | ----- +`supportedDatatypes` | `string`, `null`, `boolean`, `integer`, `double`, `array` +`supportedMetadata` | _id +`minTtl` | 0 +`maxTtl` | 0 +`staticTtl` | `true` +`ttlPrecision` | 1 +`useRequestTime` | `false` +`lockOnExpire` | 0 +`maxKeyLength` | 255 +`namespaceIsPrefix` | `true` +`namespaceSeparator` |