Skip to content
This repository has been archived by the owner on Feb 5, 2024. It is now read-only.

Added couchbase storage #11

Merged
merged 5 commits into from Jan 27, 2013
Merged

Added couchbase storage #11

merged 5 commits into from Jan 27, 2013

Conversation

SimonSimCity
Copy link
Contributor

Added a storage implementation for couchbase.

Or do you think that memcache would be enough, as it's a drop-in replacement?
http://www.couchbase.com/memcached

@SimonSimCity
Copy link
Contributor Author

Just one question left ...

The interface defines the methods "insert" and "update". In Couchbase you have "add" which will return an error if the data-set exists, "replace" which will only save the data if the data-set exists and "set" which will save the data whether the key already exists or not.

I used "add" for "insert". Please write it down if that's wrong implemented.

/**
* @var \PHPUnit_Framework_MockObject_MockObject
*/
private $couchbase;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use spaces for the indentation, not tabs

@stof
Copy link
Member

stof commented Dec 3, 2012

The DBALStorage uses a SQL Insert so it will also fail on existing keys: https://github.com/doctrine/KeyValueStore/blob/master/lib/Doctrine/KeyValueStore/Storage/DBALStorage.php#L78
However, you should catch the exception to be consistent, and either discard it (behavior of the DBALStorage but probably bad for debugging) or wrap it in a StorageException (behavior of the WindowsAzureTableStorage). @beberlei what should be the storage behavior ?

and you should add a suggestion for ext-couchbase in the composer.json


protected function setUp()
{
$this->couchbase = $this->getMockBuilder('\Couchbase')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you need to skip the test when the Couchbase class is not available instead of making it fail with an exception

@SimonSimCity
Copy link
Contributor Author

The current implementation will just do nothing as you don't get a return-value ... The php-extension returns FALSE if insert or update fails - but I don't know how to handle it ..

The current implementation for DBAL f.e. is quite loosy as well .. they all don't care if the functions fail.
Like it looks for me, this KeyValueStore's are just thought for caching ... It's not sure if your data really got saved.

@stof
Copy link
Member

stof commented Dec 3, 2012

@SimonSimCity they are the storage, not a cache (except if you use the whole KeyValueStore as a cache)

@SimonSimCity
Copy link
Contributor Author

@stof: I know that ... but every implementation in here is build this way, that if an error occurs, f.e. during adding (key already exists ..), it's just ignored.
But that's another discussion ;)

beberlei added a commit that referenced this pull request Jan 27, 2013
@beberlei beberlei merged commit 0d7c5f0 into doctrine:master Jan 27, 2013
@beberlei
Copy link
Member

@SimonSimCity thank you for the pull request, very much appreciated!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants