mirror of
https://github.com/doctrine/KeyValueStore.git
synced 2026-03-24 08:42:12 +01:00
Compare commits
9 Commits
force-cs
...
missing-ra
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2117eef3e3 | ||
|
|
ff58187a3b | ||
|
|
e878a42d81 | ||
|
|
55f0840706 | ||
|
|
ac4c317a7e | ||
|
|
705d5fc1d1 | ||
|
|
465bd365f7 | ||
|
|
9fb5e498ed | ||
|
|
573723ab3c |
15
.travis.yml
15
.travis.yml
@@ -1,17 +1,26 @@
|
||||
language: php
|
||||
|
||||
services:
|
||||
- cassandra
|
||||
- couchdb
|
||||
- mongodb
|
||||
- redis-server
|
||||
|
||||
matrix:
|
||||
include:
|
||||
-
|
||||
dist: precise
|
||||
php: 5.5
|
||||
|
||||
php:
|
||||
- 5.5
|
||||
- 5.6
|
||||
- 7.0
|
||||
- hhvm
|
||||
- 7.1
|
||||
- 7.2
|
||||
- 7.3
|
||||
|
||||
before_install:
|
||||
- if [[ $TRAVIS_PHP_VERSION != "hhvm" && $TRAVIS_PHP_VERSION != "7.0" ]]; then sh ./tests/travis.sh; fi
|
||||
- if [[ ${TRAVIS_PHP_VERSION:0:1} != "7" ]]; then sh ./tests/travis.sh; fi
|
||||
- composer self-update
|
||||
|
||||
install:
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
},
|
||||
"require-dev": {
|
||||
"datastax/php-driver": "^1.0",
|
||||
"doctrine/couchdb": "^1.0.0-beta4",
|
||||
"doctrine/couchdb": "^2.0@alpha",
|
||||
"phpunit/phpunit": "^4.8|^5.0",
|
||||
"aws/aws-sdk-php": "^3.8",
|
||||
"riak/riak-client": "dev-master"
|
||||
|
||||
@@ -202,7 +202,7 @@ class RangeQuery
|
||||
/**
|
||||
* Execute query and return a result iterator.
|
||||
*
|
||||
* @return ResultIterator
|
||||
* @return array
|
||||
*/
|
||||
public function execute()
|
||||
{
|
||||
|
||||
@@ -29,14 +29,14 @@ namespace Doctrine\KeyValueStore\Query;
|
||||
interface RangeQueryStorage
|
||||
{
|
||||
/**
|
||||
* Execute the range query and return a ResultIterator
|
||||
* Execute the range query and return an array
|
||||
*
|
||||
* @param RangeQuery $query
|
||||
* @param string $storageName
|
||||
* @param array $key
|
||||
* @param Closure $hydrateRow
|
||||
*
|
||||
* @return ResultIterator
|
||||
* @return array
|
||||
*/
|
||||
public function executeRangeQuery(RangeQuery $query, $storageName, $key, \Closure $hydrateRow = null);
|
||||
}
|
||||
|
||||
@@ -23,6 +23,8 @@ namespace Doctrine\KeyValueStore\Storage;
|
||||
use Cassandra\ExecutionOptions;
|
||||
use Cassandra\Session;
|
||||
use Doctrine\KeyValueStore\NotFoundException;
|
||||
use Doctrine\KeyValueStore\Query\RangeQuery;
|
||||
use Doctrine\KeyValueStore\Query\RangeQueryStorage;
|
||||
|
||||
/**
|
||||
* Cassandra Storage Engine for KeyValueStore.
|
||||
@@ -31,7 +33,7 @@ use Doctrine\KeyValueStore\NotFoundException;
|
||||
*
|
||||
* @uses https://github.com/datastax/php-driver
|
||||
*/
|
||||
class CassandraStorage implements Storage
|
||||
class CassandraStorage implements Storage, RangeQueryStorage
|
||||
{
|
||||
/**
|
||||
* @var \Cassandra\Session
|
||||
@@ -176,6 +178,13 @@ class CassandraStorage implements Storage
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function executeRangeQuery(RangeQuery $query, $storageName, $key, \Closure $hydrateRow = null)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
|
||||
@@ -21,6 +21,9 @@
|
||||
namespace Doctrine\KeyValueStore\Storage;
|
||||
|
||||
use Doctrine\CouchDB\CouchDBClient;
|
||||
use Doctrine\CouchDB\Mango\MangoQuery;
|
||||
use Doctrine\KeyValueStore\Query\RangeQuery;
|
||||
use Doctrine\KeyValueStore\Query\RangeQueryStorage;
|
||||
|
||||
/**
|
||||
* Key-Value-Storage using a Doctrine CouchDB Client library as backend.
|
||||
@@ -30,7 +33,7 @@ use Doctrine\CouchDB\CouchDBClient;
|
||||
*
|
||||
* @author Emanuele Minotto <minottoemanuele@gmail.com>
|
||||
*/
|
||||
final class CouchDbStorage implements Storage
|
||||
final class CouchDbStorage implements Storage, RangeQueryStorage
|
||||
{
|
||||
/**
|
||||
* @var CouchDBClient
|
||||
@@ -116,7 +119,7 @@ final class CouchDbStorage implements Storage
|
||||
/**
|
||||
* @param string $storageName
|
||||
* @param array|string $key
|
||||
*
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private function flattenKey($storageName, $key)
|
||||
@@ -137,4 +140,72 @@ final class CouchDbStorage implements Storage
|
||||
|
||||
return $finalKey;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function executeRangeQuery(RangeQuery $query, $storageName, $key, \Closure $hydrateRow = null)
|
||||
{
|
||||
$mangoQuery = new MangoQuery();
|
||||
$partitionKey = $query->getPartitionKey();
|
||||
|
||||
$conditions = [];
|
||||
foreach ($query->getConditions() as $condition) {
|
||||
switch ($condition[0]) {
|
||||
case RangeQuery::CONDITION_LE:
|
||||
$conditions[] = [
|
||||
$partitionKey => [
|
||||
'$lte' => $condition[1],
|
||||
],
|
||||
];
|
||||
break;
|
||||
|
||||
case RangeQuery::CONDITION_GE:
|
||||
$conditions[] = [
|
||||
$partitionKey => [
|
||||
'$gte' => $condition[1],
|
||||
],
|
||||
];
|
||||
break;
|
||||
|
||||
case RangeQuery::CONDITION_NEQ:
|
||||
$conditions[] = [
|
||||
$partitionKey => [
|
||||
'$ne' => $condition[1],
|
||||
],
|
||||
];
|
||||
break;
|
||||
|
||||
case RangeQuery::CONDITION_STARTSWITH:
|
||||
$conditions[] = [
|
||||
$partitionKey => [
|
||||
'$regex' => '^'.$condition[1],
|
||||
],
|
||||
];
|
||||
break;
|
||||
|
||||
default:
|
||||
$conditions[] = [
|
||||
$partitionKey => [
|
||||
'$'.$condition[0] => $condition[1],
|
||||
],
|
||||
];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$mangoQuery
|
||||
->select(['_id', $key])
|
||||
->where(['$and' => $conditions])
|
||||
->limit($query->getLimit());
|
||||
|
||||
$results = [];
|
||||
$mangoResults = $this->client->find($query);
|
||||
|
||||
foreach ($mangoResults as $mangoResult) {
|
||||
$results[] = $hydrateRow($mangoResult);
|
||||
}
|
||||
|
||||
return $results;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,7 +33,10 @@ class MongoDbStorageTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
protected function setUp()
|
||||
{
|
||||
$this->mongo = $this->getMock('\Mongo');
|
||||
$this->mongo = $this
|
||||
->getMockBuilder('\Mongo')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
|
||||
$this->mongodb = $this->getMockBuilder('\MongoDB')->disableOriginalConstructor()->getMock();
|
||||
|
||||
|
||||
@@ -39,6 +39,10 @@ class RiakStorageTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
protected function setup()
|
||||
{
|
||||
if (PHP_MAJOR_VERSION >= 7) {
|
||||
$this->markTestSkipped('Riak extension is not available for PHP versions >= 7');
|
||||
}
|
||||
|
||||
$this->riak = $this->getMockBuilder('Riak\\Client')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
|
||||
@@ -20,7 +20,9 @@
|
||||
|
||||
namespace Doctrine\Tests\KeyValueStore\Storage;
|
||||
|
||||
use Doctrine\KeyValueStore\Http\Client;
|
||||
use Doctrine\KeyValueStore\Http\Response;
|
||||
use Doctrine\KeyValueStore\Storage\WindowsAzureTable\AuthorizationSchema;
|
||||
use Doctrine\KeyValueStore\Storage\WindowsAzureTableStorage;
|
||||
|
||||
class WindowsAzureTableStorageTest extends AbstractStorageTestCase
|
||||
@@ -29,8 +31,14 @@ class WindowsAzureTableStorageTest extends AbstractStorageTestCase
|
||||
|
||||
protected function createStorage()
|
||||
{
|
||||
$this->client = $this->getMock('Doctrine\KeyValueStore\Http\Client');
|
||||
$auth = $this->getMock('Doctrine\KeyValueStore\Storage\WindowsAzureTable\AuthorizationSchema');
|
||||
$this->client = $this
|
||||
->getMockBuilder(Client::class)
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
$auth = $this
|
||||
->getMockBuilder(AuthorizationSchema::class)
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
$auth->expects($this->any())->method('signRequest')->will($this->returnValue('Authorization: SharedKeyLite testaccount1:uay+rilMVayH/SVI8X+a3fL8k/NxCnIePdyZSkqvydM='));
|
||||
|
||||
$storage = new WindowsAzureTableStorage(
|
||||
|
||||
Reference in New Issue
Block a user