A PHP extension for Facebook's RocksDB
Merge pull request #1 from miclen/patch-1 …
| src | Update database.cpp | a year ago | |
| test | Revert 4c59e30 | a year ago | |
| .gitignore | Updated gitignore to ignore eclipse project files and other junk | 2 years ago | |
| Makefile | Revert 4c59e30 | a year ago | |
| README.md | Revert 4c59e30 | a year ago | |
| test.sh | Revert 4c59e30 | a year ago | |
| test_valgrind.sh | Revert 4c59e30 | a year ago |
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.dwith the.confextension, where the path to the PHP-CPP src directory is on a single line - Copy the file
libphpcpp.soto/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.dwith the.confextension, where the path to RocksDB is on a single line - Copy the files
librocksdb.aandlibmemenv.ato/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的更多相关文章
- 对LevelDB的“升级版”存储引擎RocksDB的调研成果
Google的leveldb是个非常优秀的存储引擎.但还是有一些不尽人意的地方,比方leveldb不支持多线程合并.对key范围查找的支持还非常easy,未做优化措施,等等.而Facebook的Roc ...
- 融合RocksDB, Pregel, Foxx & Satellite Collections 怎样使数据库性能提升35%?
经过数月的研发测评,开源多模型数据库ArangoDB 终于发布了其 3.2 正式版,该版本消除了两个重大的障碍,添加了一个期待已久的功能,还集成了一个有趣的功能.此外,官方团队表示新版本将 Arang ...
- Install ssdb-rocks on CentOS 6
Install ssdb-rocks on CentOS 6 C.C. 发表于 2014年08月10日 20:14 | Hits: 649 为了优化节操精选的弹幕系统,打算更换到Facebook的R ...
- b2c项目基础架构分析(一)b2c 大型站点方案简述 已补充名词解释
我最近一直在找适合将来用于公司大型bs,b2b b2c的基础架构. 实际情况是要建立一个bs架构b2b.b2c的网站,当然还包括wap站点.手机app站点. 一.现有公司技术人员现状: 1.熟悉asp ...
- 客官,您的 Flask 全家桶请收好
http://www.factj.com/archives/543.html Flask-AppBuilder - Simple and rapid Application buil ...
- 以太坊区块链Java(EthereumJ)学习笔记:概述
本系列文章介绍以太坊区块链基于Java语言的解决方案.通过介绍EthereumJ定义的主要模块和Class,希望为大家学习和使用EthereumJ提供一些帮助. 整体架构 以太坊的Java解决方案主要 ...
- [mongodb] MMAP 和wiredTiger 的比较
mongodb 现在有两款存储引擎 MMAPv1 和 WireTiger,当然了除了这两款存储引擎还有其他的存储引擎了. 如: 内存引擎:现在的mongodb 版本中已经有了,主要的cache 服务 ...
- 如何基于LSM-tree架构实现一写多读
一 前言 PolarDB是阿里巴巴自研的新一代云原生关系型数据库,在存储计算分离架构下,利用了软硬件结合的优势,为用户提供具备极致弹性.海量存储.高性能.低成本的数据库服务.X-Engine是阿里巴 ...
- Rocksdb Compaction原理
概述 compaction主要包括两类:将内存中imutable 转储到磁盘上sst的过程称之为flush或者minor compaction:磁盘上的sst文件从低层向高层转储的过程称之为compa ...
随机推荐
- js对象中的回调函数
假设一个页面new多个同类型的对象,且该对象内部含异步请求的回调,很有可能回调函数中的this指向最后一次new的对象. 解决该问题的办法是,异步请求使用$.ajax并制定其context为this, ...
- Chrome的Crash Report服务
<本文转自:http://www.cppblog.com/woaidongmao/archive/2009/10/22/99211.aspx> 本文翻译自debugInfo网站上一篇文章g ...
- 【The final】软件工程实践总结
软件工程就这么告一段落了,竟然有那么一丢丢的舍不得-- 一.为拖延找的种种借口 [首先声明]以下纯粹是个人吐槽,仅作记录以便日后自己可以回顾一下往昔罢了,可以直接忽略,跳到第二大点:我的拖延之 ...
- at org.apache.catalina.loader.WebappClassLoader.loadClass问题处理
在连接oracle数据库时,正常的java application可以连接,但是到javabean web中就出错,说是Class.forName(dirver)找不到驱 动,问题是,我将oracle ...
- AMD&CMD
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- Html-Css-a标签的使用
a标签去掉下划线 a{ text-decoration:none; } 或者把这个属性分别加到a标签下, a:link{ text-decoration:none; } a:visited{ text ...
- 【HTTP劫持和DNS劫持】腾讯的实际业务分析
简单介绍一下HTTP劫持和DNS劫持的概念,也就是运营商通过某些方式篡改了用户正常访问的网页,插入广告或者其他一些杂七杂八的东西. 首先对运营商的劫持行为做一些分析,他们的目的无非 ...
- 【HDU 5007】Post Robot
Description DT is a big fan of digital products. He writes posts about technological products almost ...
- Visio绘制时序图
用visio建立时序图 1.选择模版 2.常见符号 时序图创建步骤 1.确定交互过程的上下文: 2.识别参与过程的交互对象: 3.为每个对象设置生命线: 4.从初始消息开始,依次画出随后消息: 5.考 ...
- 转-Android中自动连接到指定SSID的Wi-Fi
最近在做一个项目,其中涉及到一块“自动连接已存在的wifi热点”的功能,在网上查阅了大量资料,五花八门,但其中一些说的很简单,即不能实现傻瓜式的拿来就用,有些说的很详细,但其中不乏些许错误造成功能无法 ...