Skip to content

Modern transactional key-value/row storage library binding write by c extension for php7. http://sophia.systems/

Notifications You must be signed in to change notification settings

neatlife/php-ext-sophia

Repository files navigation

sophia Extension for PHP

Build Status

Modern transactional key-value/row storage library binding write by c extension for php.

For more information on sophia and for the full API documentation, please see the sophia Documentation.

Build from sources

% git clone --recursive git@github.com:neatlife/php-ext-sophia.git
% cd php-ext-sophia
% phpize
% ./configure
% make
% make install

To use the system library

% ./configure --with-sophia

Configration

sophia.ini:

extension=sophia.so

Function

  • sp_open — open an database for later use
  • sp_set — add a key value pair to previous opened database
  • sp_get — get value for specific key
  • sp_delete — delete specific key with it's value
  • sp_begin — begin a transaction
  • sp_commit — commit a transaction

sp_open

resource $dblink sp_open ( $dbpath, $dbname )

$link = sp_open('/tmp/storage', 'test');
var_dump($link);

sp_set

bool sp_set ( $key, $value )

var_dump(sp_set('name', 'suxiaolin'));

return true represent success or failure

sp_get

string $value sp_get ( $key )

var_dump(sp_get('name'));

value for specific key, if key not exists will got null

sp_delete

bool sp_delete ( $key )

var_dump(sp_delete('name'));

return true if delete successfully or false on error

sp_begin

resource sp_begin ( )

var_dump($transaction = sp_begin());

start a transaction

sp_commit

resource sp_commit ( resource $transaction )

var_dump(sp_commit());

commit a transaction

On success, sp_commit() returns 0. On error, it returns -1. On rollback 1 is returned, 2 on lock.

Examples

// set
var_dump(sp_open('/tmp/storage', 'test'));

var_dump(sp_set('name', 'suxiaolin'));

var_dump(sp_get('name'));
// delete
var_dump(sp_open('/tmp/storage', 'test'));

var_dump(sp_set('name', 'suxiaolin'));

var_dump(sp_delete('name'));

var_dump(sp_get('name'));
// transaction
var_dump(sp_open('/tmp/storage', 'test'));

var_dump(sp_begin());

var_dump(sp_set('name', 'xiaolin'));
var_dump(sp_get('name'));
var_dump(sp_delete('name'));

var_dump(sp_commit());

About

Modern transactional key-value/row storage library binding write by c extension for php7. http://sophia.systems/

Resources

Stars

Watchers

Forks

Packages

No packages published