Skip to content

Commit

Permalink
Update README with details on configuration.
Browse files Browse the repository at this point in the history
  • Loading branch information
beberlei committed Apr 2, 2012
1 parent 17f6059 commit e788122
Showing 1 changed file with 42 additions and 2 deletions.
44 changes: 42 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ The Persistence interfaces are rather overkill for many implementations in the N

Following vendors are targeted:

* Microsoft Azure Table
* Microsoft Azure Table (Implemented)
* Amazon DynamoDB
* CouchDB
* MongoDB
Expand All @@ -36,7 +36,7 @@ Suppose we track e-mail campaigns based on campaign id and recipients.
use Doctrine\KeyValueStore\Mapping\Annotations as KeyValue;

/**
* @KeyValue\Entity
* @KeyValue\Entity(storageName="responses")
*/
class Response
{
Expand Down Expand Up @@ -67,3 +67,43 @@ Suppose we track e-mail campaigns based on campaign id and recipients.

$entityManager->flush();

## Configuration

There is no factory yet that simplifies the creation process, here is the
full code necessary to instantiate a KeyValue EntityManager with a Doctrine
Cache backend:

use Doctrine\KeyValueStore\EntityManager;
use Doctrine\KeyValueStore\Mapping\AnnotationDriver;
use Doctrine\KeyValueStore\Storage\DoctrineCacheStorage;
use Doctrine\Common\Cache\ArrayCache;
use Doctrine\Common\Annotations\AnnotationReader;

$storage = new DoctrineCacheStorage($cache);
$cache = new ArrayCache;
$metadata = new AnnotationDriver(new AnnotationReader);
$entityManager = new EntityManager($storage, $cache, $metadata);

If you want to use WindowsAzure Table you can use the following configuration
to instantiate the storage:

use Doctrine\KeyValueStore\Storage\WindowsAzureTableStorage;
use Doctrine\KeyValueStore\Storage\WindowsAzureTable\SharedKeyLiteAuthorization;
use Doctrine\KeyValueStore\Http\SocketClient;

$name = ""; // Windows Azure Storage Account Name
$key = ""; // Windows Azure Storage Account Key

$auth = new SharedKeyLiteAuthorization($name, $key);
$storage = new WindowsAzureTableStorage(new SocketClient(), $name, $auth);

If you want to use Doctrine DBAL as backend:

$params = array();
$tableName = "storage";
$idColumnName = "id";
$dataColumnName = "serialized_data";

$conn = DriverManager::getConnection($params);
$storage = new DBALStorage($conn, $tableName, $idColumnName, $dataColumnName);

0 comments on commit e788122

Please sign in to comment.