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. AngularJS开发指南16:AngularJS构建大型Web应用详解

    AngularJS是由Google创建的一种JS框架,使用它可以扩展应用程序中的HTML功能,从而在web应用程序中使用HTML声明动态内容.在该团队工作的软件工程师Brian Ford近日撰写了一篇 ...

  2. LINQ构建交叉表

    最近碰到客户的一个需求.使用交叉表来显示客户数据.也就是以同时以行头和列头交叉形式显示数据内容.同时要求即使有些列没有数据,也需要显示该列内容,并设置默认值. 说明: “交叉表”对象是一个网格,用来根 ...

  3. jQuery1.4源码解读

    来吧, 慢慢折腾吧 总结一下: jq1.4挺简单的, 正则写的不多, 看的都懂, 多写一些 三目写法到底要不要 特殊的地方的注释一定要有 /*! * jQuery JavaScript Library ...

  4. Oracle查看锁表

     查看锁表进程SQL语句1: select sess.sid,     sess.serial#,     lo.oracle_username,     lo.os_user_name,     a ...

  5. BIEE 维表

    (1)       在物理层给表创建别名(表——>新建对象——>别名) (1)       在业务层创建维度(表——>创建逻辑维——>基于级别层次的维) 钻取是维本身的功能 一 ...

  6. 1.Android入门学习

    现在移动开发Android.iOS都很普遍,本人也是第一次学习Android,所以记录自己学习Android点滴,刚学不久肯定有很多不足地方望大家批评指正. 一.Android工具环境搭配 网上已经有 ...

  7. BZOJ-1433 假期的宿舍 最大流+基础建图

    网络流练习ing.. 1433: [ZJOI2009]假期的宿舍 Time Limit: 10 Sec Memory Limit: 162 MB Submit: 1748 Solved: 765 [S ...

  8. SQL localdb 连接字符串

    http://blog.csdn.net/greystar/article/details/47699797 原来SQL 2012 下连接LOCALDB,字符串为: Data Source=(Loca ...

  9. apt-get常用命令

    apt-get常用命令 一,什么的是apt-get 高级包装工具(英语:Advanced Packaging Tools,简称:APT)是Debian及其衍生发行版(如:ubuntu)的软件包管理器. ...

  10. 禁止掉非法IP登陆服务器

    今天查看线上服务器日志/var/log/secure发现有很多国外的ip尝试登陆服务器,以前一直没太注意这方面,作为系统管理员真是失职啊,虽然服务器已经设置了强密码,但是看到有人想搞你还是很不爽的.一 ...