A PHP extension for Facebook's RocksDB
C++COther
 branch: master 

README.md

RocksDB PHP Extension

RocksDB is a new embedded database for storing key-value pairs developed by Facebook. This project hosts a PHP extension for RocksDB. More information on RocksDB can be found here:

https://github.com/facebook/rocksdb

Simple Example

<?php
$rocksdb = new RocksDB("my_rocksdb_file");
$result = $rocksdb->Open(true);
if($result)
die("Unable to open rocksdb!"); $rocksdb->Put("my_awesome_key", "my_awesome_value");
$value = $rocksdb->Get("my_awesome_key"); echo $value . "\n";
?>

Check test/test.php for more examples.

Platforms

RocksDB is said to compile on Linux and Mac OS X. So far, I haven't seen anyone getting it to build on Windows, but it should work. My build environment is:

  • Ubuntu 13.10 x64
  • GCC 4.8.1

All documentation, instructions and guides assume my configuration. If you were able to get it working on another platform, please let me know.

Notes

I use a custom version of PHP-CPP, because I added basic exception support. Please checkout the fork, until my pull request has been accepted:

git clone https://github.com/Photonios/PHP-CPP

Build

Building RocksDB PHP Extension

Before trying to build the RocksDB PHP extension, make sure you have installed all dependencies listed below. After that, you can simply checkout the code:

git clone https://github.com/Photonios/rocksdb-php.git

Then, run make:

make

The PHP extension, which is a shared/dynamiclly linked library can be found in the bin directory.

Building PHP

The RocksDB PHP extension is being written against PHP 5.5.3. To be able to build the RocksDB PHP extension, you need to install the following packages:

sudo apt-get install php5-dev
sudo apt-get install php5-cli

Building PHP-CPP

PHP-CPP is a C++ library which makes developing PHP extensions from C++ possible. It's also, way easier then using the native PHP C API. PHP-CPP can be found here:

https://github.com/EmielBruijntjes/PHP-CPP

To build, clone the repository:

git clone https://github.com/EmielBruijntjes/PHP-CPP.git php-cpp

Go into the 'php-cpp' directory and run:

make

After that, 'libphpcpp.so' should be present in the 'src' directory. To install the library, do one of the following thins:

  • Add the path where you cloned PHP-CPP to LD_LIBRARY_PATH (export LD_LIBRARY_PATH+=/path/to/php-cpp/src)
  • Create a new file in /etc/ld.so.conf.d with the .conf extension, where the path to the PHP-CPP src directory is on a single line
  • Copy the file libphpcpp.so to /usr/lib

Building RocksDB

To build the RocksDB PHP Extension, you first need to build RocksDB. Clone the RocksDB git repository using:

git clone https://github.com/facebook/rocksdb.git

To be able to build RocksDB, you first need to install all dependencies, this can be done using apt-get:

sudo apt-get install libsnappy-dev
sudo apt-get install zlib1g-dev
sudo apt-get install libbz2-dev
sudo apt-get install libgflags2
sudo apt-get install libgflags-dev

Or run:

sudo apt-get install libsnappy-dev zlib1g-dev libbz2-dev libgflags2 libgflags-dev

After you've install all dependencies, you can simply run:

make clean
make

To build and run all unit tests:

make check

To install the RocksDB library you can do either of these three things:

  • Add the path where you cloned RocksDB to LD_LIBRARY_PATH (export LD_LIBRARY_PATH+=/path/to/rocksdb)
  • Create a new file in /etc/ld.so.conf.d with the .conf extension, where the path to RocksDB is on a single line
  • Copy the files librocksdb.a and libmemenv.a to /usr/lib

Choose whatever you like :)

Installation

After you build the RocksDB PHP extension, you should have a .so file in the bin directory. Execute:

php --ini

To find out where your PHP configuration file is located. It should output something liek this:

Loaded Configuration File: /etc/php5/cli/php.ini

Find the line that starts with extension=, if it's commented out, uncomment it and set the path to your extension, like this:

extension=/iam_awesome/cookies/dance/in/the/rain/rocksdb-php.so

Then, enjoy :D

A PHP extension for Facebook's RocksDB More articles about

  1. Yes LevelDB Of “ Upgraded version ” Storage engine RocksDB The research results of

    Google Of leveldb It's a great storage engine . But there are still some unsatisfactory aspects , example leveldb Multithreading merge is not supported . Yes key The support for range lookup is also very easy, No optimization measures have been taken , wait . and Facebook Of Roc ...

  2. The fusion RocksDB, Pregel, Foxx &amp; Satellite Collections How to improve database performance 35%?

    After months of R & D evaluation , Open source multi model database ArangoDB Finally released its 3.2 Official version , This version removes two major hurdles , Added a long-awaited feature , There's also an interesting feature integrated . Besides , The official team says the new version will Arang ...

  3. Install ssdb-rocks on CentOS 6

    Install ssdb-rocks on CentOS 6 C.C.  Published in 2014 year 08 month 10 Japan 20:14 | Hits: 649 In order to optimize the integrity of the selected barrage system , I plan to change to Facebook Of R ...

  4. b2c Project infrastructure analysis ( One )b2c A brief introduction to the large-scale site scheme Has been supplemented with the explanation of

    I've been looking for a company that is suitable for the future bs,b2b b2c Infrastructure for . The reality is to build a bs framework b2b.b2c Website , And of course wap Site . mobile phone app Site . One . The current situation of technical personnel of the existing company : 1. be familiar with asp ...

  5. The guest officer , Your Flask Please put away the bucket

    http://www.factj.com/archives/543.html Flask-AppBuilder          - Simple and rapid Application buil ...

  6. Ethereum blockchain Java(EthereumJ) Learning notes : summary

    This series of articles introduces that Ethereum blockchain is based on Java Language solutions . By introducing EthereumJ Define the main modules and Class, Hope to learn and use EthereumJ Offer some help . The overall architecture Ethereal Java The main solution is ...

  7. [mongodb] MMAP and wiredTiger Comparison

    mongodb Now there are two storage engines  MMAPv1 and WireTiger, Of course, in addition to these two storage engines, there are other storage engines . Such as : Memory engine : current mongodb It's already in the version , The main cache service ...

  8. Rocksdb Compaction principle

    summary compaction There are two main categories : Put... In memory imutable Dump to disk sst The process is called flush perhaps minor compaction: On disk sst The process of dumping files from the lower layer to the higher layer is called compa ...

  9. Rocksdb Engine record format

    Rocksdb It's a kv engine , from facebook The team is based on levelDB modified ,Rocksdb use LSM-tree Store the data , Good read-write and compression characteristics make it very popular . Besides ,Rocksdb Engine as a plug-in ...

Random recommendation

  1. 【Alpha edition 】 Project test

    All I'm talking about is team 031402304 Chen Shen 031402342 Xu Lingling 031402337 Hu Xinying 03140241 Wang Tingting 031402203 Chen Qimin 031402209 Huang Weiwei 031402233 Zheng Yang ...

  2. iOS Of nil,Null,NSNull Use

    When we do the project today , When taking values in an array , It's found that there are NSNull The object of , Then there are various problems when assigning values to the corresponding objects in the array , Always reporting mistakes . Later, through research and data search , Finally solved the problem . nil Used to assign values to objects (Objective ...

  3. [ Answer key ] Mine clearance Mine

    // This blog post is for migration , Written in 2015 year 2 month 6 Japan , It does not represent my current point of view . Original address :http://blog.sina.com.cn/s/blog_6022c4720102vrft.html 1088 ...

  4. StarUml:Exception EOleSysError in module StarUML.ex

    http://sourceforge.net/p/staruml/discussion/510442/thread/9fe12cac/ run as administrator.Works fine.

  5. Busy simulation Vicent Take the lift

    /*n<=5000­ It can't be used O(n) It's moving , But to use. O(1) The transfer of .­ Notice that every shift we make comes from a continuous interval , And we're looking for the sum ­ Sum of intervals ?­ The prefix and !­ Make sum[step][i] Express f[ste ...

  6. Activity Four startup modes and onNewIntent()

    from :http://blog.csdn.net/linghu_java/article/details/17266603 Android in Activity Start mode details   stay Android Every interface in the ...

  7. [Tommas] Test scenarios VS The test case Which is better? ?( turn )

    Share a sentiment of others on the Internet :      6 Years ago , When I worked for a medium-sized multinational company , I suggest instead of wasting time preparing adequate test cases , It's better to write a document describing the test scenario . All of you are very happy with my advice . Cast a troubled look . Their faces clearly ...

  8. Use methodSignatureForSelector And forwardInvocation Realize message forwarding ( turn )

    from :http://blog.sina.com.cn/s/blog_8c87ba3b0102v006.html Before adding the message forwarding function to the program , Two methods have to be covered , namely methodSignatureForS ...

  9. Linux_cloudera-scm-agent: unrecognized service

  10. js, Date.parse firefox compatible

    Date.parse(dateVal); This method is very common ,parse() Method to parse a date time string , And back to 1970/1/1 The number of milliseconds between midnight and that date . You can verify that the input date is in , Returns if it does not exist N ...