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的更多相关文章

  1. 对LevelDB的“升级版”存储引擎RocksDB的调研成果

    Google的leveldb是个非常优秀的存储引擎.但还是有一些不尽人意的地方,比方leveldb不支持多线程合并.对key范围查找的支持还非常easy,未做优化措施,等等.而Facebook的Roc ...

  2. 融合RocksDB, Pregel, Foxx & Satellite Collections 怎样使数据库性能提升35%?

    经过数月的研发测评,开源多模型数据库ArangoDB 终于发布了其 3.2 正式版,该版本消除了两个重大的障碍,添加了一个期待已久的功能,还集成了一个有趣的功能.此外,官方团队表示新版本将 Arang ...

  3. Install ssdb-rocks on CentOS 6

    Install ssdb-rocks on CentOS 6 C.C.  发表于 2014年08月10日 20:14 | Hits: 649 为了优化节操精选的弹幕系统,打算更换到Facebook的R ...

  4. b2c项目基础架构分析(一)b2c 大型站点方案简述 已补充名词解释

    我最近一直在找适合将来用于公司大型bs,b2b b2c的基础架构. 实际情况是要建立一个bs架构b2b.b2c的网站,当然还包括wap站点.手机app站点. 一.现有公司技术人员现状: 1.熟悉asp ...

  5. 客官,您的 Flask 全家桶请收好

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

  6. 以太坊区块链Java(EthereumJ)学习笔记:概述

    本系列文章介绍以太坊区块链基于Java语言的解决方案.通过介绍EthereumJ定义的主要模块和Class,希望为大家学习和使用EthereumJ提供一些帮助. 整体架构 以太坊的Java解决方案主要 ...

  7. [mongodb] MMAP 和wiredTiger 的比较

    mongodb 现在有两款存储引擎  MMAPv1 和 WireTiger,当然了除了这两款存储引擎还有其他的存储引擎了. 如: 内存引擎:现在的mongodb 版本中已经有了,主要的cache 服务 ...

  8. 如何基于LSM-tree架构实现一写多读

    一  前言 PolarDB是阿里巴巴自研的新一代云原生关系型数据库,在存储计算分离架构下,利用了软硬件结合的优势,为用户提供具备极致弹性.海量存储.高性能.低成本的数据库服务.X-Engine是阿里巴 ...

  9. Rocksdb Compaction原理

    概述 compaction主要包括两类:将内存中imutable 转储到磁盘上sst的过程称之为flush或者minor compaction:磁盘上的sst文件从低层向高层转储的过程称之为compa ...

随机推荐

  1. PHP时间日期比较

    若要使用PHP来比较日期,最好用DateTime::diff 但是这个是5.3才支持的,如果没有这样的环境,可以使用<.>来比较 如下例子,会输出right $date1=strtotim ...

  2. 每天一个linux命令(22):chgrp命令

    在 lunix系统里,文件或目录的权限的掌控以拥有者及所诉群组来管理.可以使用chgrp指令取变更文件与目录所属群组,这种方式采用群组名称或群组识别 码都可以.Chgrp命令就是change grou ...

  3. 每天一个linux命令(13):tail 命令

    tail 命令从指定点开始将文件写到标准输出.使用tail命令的-f选项可以方便的查阅正在改变的日志文件,tail -f filename会把filename里最尾部的内容显示在屏幕上,并且不但刷新, ...

  4. QQ面向对象设计

          通讯项目--仿QQ聊天程序   详细设计说明书                                                         一.引言 此项目为验证Jav ...

  5. js获取服务器时间戳

    <!DOCTYPE html> <html> <head> <title>ajax</title> </head> <bo ...

  6. shiro 与 web 的结合

    本次使用的jar包为 shiro-core-.jar shiro-web-.jar 从Shiro 1.2开始引入了Environment/WebEnvironment的概念,即由它们的实现提供相应的S ...

  7. myeclipse6.0 序列号生成器源码

    import java.io.*; public class Test{ private static final String LL = "Decompiling this copyrig ...

  8. github 建立博客

    Last login: Wed Jan 27 20:33:21 on console liukun-MBP:~ kamil$ cd ~/.ssh/ liukun-MBP:.ssh kamil$ ls ...

  9. getHibernateTemplate()的用法

    getHibernateTemplate() spring 中获得由spring所配置的hibernate的操作对象,然后利用此对象进行,保存,修改和删除等操作,此方法是在配置了spring以后,hi ...

  10. [Angularjs]视图和路由(二)

    写在前面 上篇文章主要介绍了视图和路由的基本概念,并在文章最后举了一个简单的使用案例.这篇文章将继续学习路由的配置,及相关参数的说明. 系列文章 [Angularjs]ng-select和ng-opt ...