Permalink
Browse files

Merge pull request #79 from larowlan/dynamodb

Enhances existing dynamodb implementation and adds docs
  • Loading branch information...
2 parents b2906e2 + bb1ba64 commit 8ba3db4ce7727f19cdb91519968ba4259b588277 @EmanueleMinotto EmanueleMinotto committed on GitHub Jul 5, 2016
View
@@ -23,7 +23,7 @@ Following vendors are targeted:
* Doctrine\Common\Cache provider (Implemented)
* RDBMS (Implemented)
* Couchbase (Implemented)
-* Amazon DynamoDB
+* Amazon DynamoDB (Implemented)
* CouchDB (Implemented)
* Cassandra
* MongoDB (Implemented)
View
@@ -8,6 +8,7 @@
"datastax/php-driver": "^1.0",
"doctrine/couchdb": "^1.0.0-beta4",
"phpunit/phpunit": "^4.8|^5.0",
+ "aws/aws-sdk-php": "^3.8",
"riak/riak-client": "dev-master"
},
"suggest": {
@@ -198,6 +198,29 @@ CouchDB storage setup based on `doctrine/couchdb-client <https://github.com/doct
$storage = new CouchDbStorage($client);
+DynamoDb
+---------
+
+DynamoDb is supported through the `AWS SDK for PHP <https://aws.amazon.com/sdk-for-php/>`_
+Create your tables via the AWS DynamoDb console or using the `PHP based API <http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/LowLevelPHPTableOperationsExample.html>`_
+See the `AWS docs <http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/UsingPHP.html#PHPSDKCredentialsSet>`_ for more information on configuring credentials for the client.
+
+.. code-block:: php
+
+ <?php
+
+ $sdk = new \Aws\Sdk([...]);
+ $client = $sdk->createDynamoDb();
+
+ $storage = new DynamoDbStorage(
+ $client,
+ // Optional key name, defaults to Id.
+ null,
+ // Optional table name/ key name pairs.
+ // This example uses a table called Awesome keyed by MyKey.
+ ['storage_keys' => ['Awesome' => 'MyKey']]
+ );
+
MongoDB
-------
@@ -0,0 +1,48 @@
+<?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\KeyValueStore;
+
+class InvalidArgumentException extends KeyValueStoreException
+{
+ public static function invalidType($name, $expectedType, &$actual)
+ {
+ return new static(
+ sprintf('The %s must be a %s, got "%s" instead.', $name, $expectedType, gettype($actual)),
+ 0
+ );
+ }
+
+ public static function invalidLength($name, $min, $max)
+ {
+ return new static(
+ sprintf('The %s must be at least %d but no more than %d chars.', $name, $min, $max),
+ 0
+ );
+ }
+
+ public static function invalidTableName($name)
+ {
+ return new static(
+ sprintf('Invalid table name: %s', $name),
+ 0
+ );
+ }
+}
@@ -22,4 +22,8 @@
class NotFoundException extends KeyValueStoreException
{
+ public static function notFoundByKey($key)
+ {
+ return new static(sprintf('Could not find an item with key: %s', $key), 0);
+ }
}
Oops, something went wrong.

0 comments on commit 8ba3db4

Please sign in to comment.