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.
- Post bug reports or feature requests to the Github Issues page
% git clone --recursive git@github.com:neatlife/php-ext-sophia.git
% cd php-ext-sophia
% phpize
% ./configure
% make
% make installTo use the system library
% ./configure --with-sophiasophia.ini:
extension=sophia.so
- 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
resource $dblink sp_open ( $dbpath, $dbname )
$link = sp_open('/tmp/storage', 'test');
var_dump($link);bool sp_set ( $key, $value )
var_dump(sp_set('name', 'suxiaolin'));return true represent success or failure
string $value sp_get ( $key )
var_dump(sp_get('name'));value for specific key, if key not exists will got null
bool sp_delete ( $key )
var_dump(sp_delete('name'));return true if delete successfully or false on error
resource sp_begin ( )
var_dump($transaction = sp_begin());start a transaction
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.
// 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());