Skip to content
master
Go to file
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

README.md

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

Packages

No packages published