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 ...
随机推荐
- WampServer集成环境安装与配置
实习到了第三个礼拜了,原来我们小组是以开发php为主的,我们项目的服务器也是用php做的,因此我觉得很有必要学一下php的相关知识,首先当然是搭建环境了,写篇博客分享下经验. 目录: 一.软件下载 二 ...
- NumberFormat类的用法
NumberFormat.getInstance()方法返回NumberFormat的一个实例(实际上是NumberFormat具体的一个子类,例如DecimalFormat), 这适合根据本地设置格 ...
- [转载]ODAC (odp.net) 开发到部署
1. 确定你开发机和服务器的操作系统是32位还是64位, 而且要确定要部署的服务器是什么操作系统; 2. 下载开发机和服务器所需的dll, 地址:http://download.csdn.net/de ...
- zabbix_监控_邮件预警
一.解决的问题:当触发器满足条件被触发时,发邮件进行通知 二.软件及方案 使用外部邮箱发送邮件 使用mailx发送邮件,版本为12.4 zabbix版本为2.2.2 zabbix中使用执行脚本 ...
- poj2485&&poj2395 kruskal
题意:最小生成树的最大边最小,sort从小到大即可 poj2485 #include<stdio.h> #include<string.h> #include<algor ...
- [NOIP2010] 提高组 洛谷P1525 关押罪犯
刚才做并查集想到了这道以前做的题,干脆一并放上来 题目描述 S 城现有两座监狱,一共关押着N 名罪犯,编号分别为1~N.他们之间的关系自然也极不和谐.很多罪犯之间甚至积怨已久,如果客观条件具备则随时可 ...
- C# WPF 显示图片和视频显示 EmuguCv、AForge.Net测试
WPF 没有用到 PictureBox, 而是用Image代替. 下面我试着加载显示一个图片 . XAML <Image x:Name="srcImg"Width=" ...
- App接口中json方式封装通信接口
封装json通信接口的类 <?php class Response{ /** * 按json方式输出通信数据 * @param integer $code状态码 * @param string ...
- Lua函数之二
Lua函数之二 Lua中函数的两个重要特性: 1.函数和其他类型(如number.string)一样,可以存放在变量中,也可以存放在table中,可以作为函数的参数,还可以作为函数的返回值. 2.嵌套 ...
- 如何使用Unix/Linux grep命令——磨刀不误砍柴工系列
http://man.linuxde.net/grep ---------------------------------------------------- 如何使用Unix/Linux gre ...