Yii 1.1: riiak

Client library for Riak key/value store
4 followers

This is a PHP client for Riak, built as an extension for Yii Framework. Ported from Basho's official PHP client with numerous changes and slight improvements.

To clarify, this is a client library to provide PHP methods for accessing the Riak REST API. This does not have any code or logic to deal with model's specifically (such as Active Record-style functionality). A separate project/extension will be created to fulfill that need.

What is Riak?

Riak is a Dynamo-inspired key/value store with a distributed database network platform that makes storing and retrieving data simple, safe and low-cost. Riak liberates data from vulnerable centralized databases, allowing it to escape catastrophic losses and surges while accelerating the speed of applications. Riak has no single point of failure. Its multiple nodes create a truly fault-tolerant system for storing any type of mission-critical data.

Requirements

Tested/built using Yii 1.1.8-dev (trunk), with PHP 5.3+. Should work in Yii 1.1.x, may work in Yii 1.0.x

Resources

Changelog

  • 6/02/11: Version 0.1.1 uploaded. Bugfix to documentation and map/reduce methods.
  • 5/31/11: Version 0.1.0 uploaded. Initial conversion from Riak PHP client.

Usage

While the example below does not show it, Riiak is set up as a Yii Application Component, so you can add to your protected/config/main.php a new component entry for Riiak, so that it can be accessed via something like Yii::app()->riak, or you can simply implement as show below.

This quick example assumes that you have a local riak cluster running on port 8098, and have installed the Riiak extension into protected/extensions/riiak/

Yii::import('ext.riiak.*');
 
# Connect to Riak
$client = new Riiak('127.0.0.1', 8098);
 
# Choose a bucket name
$bucket = $client->bucket('test');
 
# Supply a key under which to store your data
$person = $bucket->newObject('riak_developer_1', array(
    'name' => 'John Smith',
    'age' => 28,
    'company' => 'Facebook'
));
 
# Save the object to Riak
$person->store();
 
# Fetch the object
$person = $bucket->get('riak_developer_1');
 
# Update the object
$person->data['company'] = 'Google';
$person->store();

Total 1 comment

#4065 report it
intel352 at 2011/06/02 04:49pm
Riiak: Added v0.1.1 - Bugfix

Found/fixed a bug in RiiakMapReduce class, added some missing method documentation, updated readme.

Leave a comment

Please to leave your comment.

Create extension