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.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
andlibmemenv.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的更多相关文章
-
对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 ...
随机推荐
-
css去掉iPhone、iPad默认按钮样式
原文链接:http://blog.sina.com.cn/s/blog_7d796c0d0102uyd2.html 只要在样式里面加一句去掉css去掉iPhone.iPad的默认按钮样式就可以了!~ ...
-
C++实现数字媒体三维图像变换
C++实现数字媒体三维图像变换 必备环境 glut.h 头文件 glut32.lib 对象文件库 glut32.dll 动态连接库 程序说明 C++实现了用glut画物体对象的功能.并附带放大缩小,旋 ...
-
利用jQuery实现的Ajax 验证用户名是否存在
异步刷新实现方式有多种,也可以借助JS的多种框架,下面是使用jQuery框架实现的AJAX 验证用户名是否存在 jQuery.ajax概述 HTTP 请求加载远程数据. 通过jQuery 底层 AJA ...
-
.Net程序员学用Oracle系列(8):触发器、作业、序列、连接
1.触发器 2.作业 2.1.作业调度功能和应用 2.2.通过 DBMS_JOB 来调度作业 3.序列 3.1.创建序列 3.2.使用序列 & 删除序列 4.连接 4.1.创建连接 4.2.使 ...
-
Java中的的画正三角方法
在循环的语句的练习中,画正三角是一个很经典的例子,但是如果方法找的不对的话,即使最终画出来了,那么得到的代码也是非常的复杂,应用性不高. 下面有两种方法来画正三角,第一种是一种比较麻烦的办法,是通过归 ...
-
第三十三篇-TabLayout的使用
效果图: 最上方是一个TabLayout,有三个部分,新闻.财经.娱乐,下方是一个ViewPaper,里面包含三个fragment,分别对应三个xml和java class. 第一个Fragment里 ...
-
Iris分类以及数组reshape想到的
最近在研究Iris花的逻辑回归分类中看到了如下的代码: from sklearn.linear_model import LogisticRegression X = iris["data& ...
-
jquery关于attr和prop的差异
转自:http://www.jb51.net/article/88068.htm 处理像checkbox,radio和select这样的元素时,经常会发现明明使用了attr设置了selected或ch ...
-
Fluent 18.0新功能之:其他
ANSYS 18.0在2017年1月底发布,来看看Fluent18.0更新了哪些内容. 1 用户界面 关于用户界面方面的更新包括: (1)可以在树形菜单中同时选择多个子节点,如同时选择多个边界,点击右 ...
-
IIS------项目配置到IIS后报500错误
转载: http://blog.csdn.net/yinjingjing198808/article/details/7185453 错误一: HTTP Error 500.19 - Internal ...