This repository has been archived by the owner on Feb 5, 2024. It is now read-only.
Riak #6
Merged
Merged
Riak #6
Changes from 5 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
2c1a79a
Add Riak storage
Baachi 692e0ca
CS
Baachi 76530e8
Replace docblocks with {@inheritDoc}
Baachi f4ba01a
Use the right indention
Baachi f8c3d9d
Update composer file and add riak/riak-client to the "suggest" section
Baachi c7050dd
Replace version constraint in suggest section
Baachi File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,12 @@ | |
"require": { | ||
"doctrine/common": "*" | ||
}, | ||
"suggest": { | ||
"riak/riak-client": "dev-master" | ||
}, | ||
"require-dev": { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You should add riak to the "suggest" key aswell, what do you think? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, it makes sense. I will add riak to the suggest section. |
||
"riak/riak-client": "dev-master" | ||
}, | ||
"description": "Simple Key-Value Store Abstraction Layer that maps to PHP objects, allowing for many backends.", | ||
"license": "MIT", | ||
"autoload": { | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,137 @@ | ||
<?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\Storage; | ||
|
||
use Doctrine\KeyValueStore\NotFoundException; | ||
|
||
use Riak\Client; | ||
|
||
/** | ||
* @author Markus Bachmann <markus.bachmann@bachi.biz> | ||
*/ | ||
class RiakStorage implements Storage | ||
{ | ||
/** | ||
* @var \Riak\Client | ||
*/ | ||
protected $client; | ||
|
||
/** | ||
* Constructor | ||
* | ||
* @param \Riak\Client $riak | ||
* @param string $bucketName | ||
*/ | ||
public function __construct(Client $riak) | ||
{ | ||
$this->client = $riak; | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
public function supportsPartialUpdates() | ||
{ | ||
return false; | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
public function supportsCompositePrimaryKeys() | ||
{ | ||
return false; | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
public function requiresCompositePrimaryKeys() | ||
{ | ||
return false; | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
public function insert($storageName, $key, array $data) | ||
{ | ||
$bucket = $this->client->bucket($storageName); | ||
$object = $bucket->newObject($key, $data); | ||
$object->store(); | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
public function update($storageName, $key, array $data) | ||
{ | ||
$bucket = $this->client->bucket($storageName); | ||
/** @var $object \Riak\Object */ | ||
$object = $bucket->get($key); | ||
|
||
$object->setData($data); | ||
$object->store(); | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
public function delete($storageName, $key) | ||
{ | ||
$bucket = $this->client->bucket($storageName); | ||
|
||
/** @var $object \Riak\Object */ | ||
$object = $bucket->get($key); | ||
|
||
if (!$object->exists()) { | ||
// object does not exist, do nothing | ||
return; | ||
} | ||
|
||
$object->delete(); | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
public function find($storageName, $key) | ||
{ | ||
$bucket = $this->client->bucket($storageName); | ||
|
||
/** @var $object \Riak\Object */ | ||
$object = $bucket->get($key); | ||
|
||
if (!$object->exists()) { | ||
throw new NotFoundException; | ||
} | ||
|
||
return $object->getData(); | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
public function getName() | ||
{ | ||
return 'riak'; | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggest does not expect a version constraint but a string displayed to the user. so you could make it better by using
"riak/riak-client": "to use the Riak storage"
. This will output"doctrine/key-value-store" suggest installing "riak/riak-client" (to use the Riak storage)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah awesome!
Thank you ;)