doctrine / KeyValueStore

Abstraction for Key-Value to Plain Old PHP Object mapping
http://www.doctrine-project.org
MIT License
200 stars 59 forks source link

Added couchbase storage #11

Closed SimonSimCity closed 11 years ago

SimonSimCity commented 11 years ago

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 commented 11 years ago

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.

stof commented 11 years ago

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

SimonSimCity commented 11 years ago

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 commented 11 years ago

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

SimonSimCity commented 11 years ago

@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 commented 11 years ago

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