#RocksServer is server for RocksDB
Supports the following operations:
operations | description |
---|---|
Get | Get value by key |
Multi get | Get values by keys |
Set | Set value by key |
Multi set | Set values by keys |
Delete key | Delete key from DB |
Multi delete keys | Delete keys from DB |
Check key exist | Check key existing |
Imcrement | Imcrement value by key |
Prefit | Prefix iterator |
For more details see: protocol description
##Dependency RocksDB, LibEvent
The compiler should support C++11
First install RocksDB dependences:
sudo apt install libgflags-dev libsnappy-dev zlib1g-dev libbz2-dev liblz4-dev libzstd-dev
Then clone the repository:
git clone --recursive https://github.com/valmat/RocksServer
cd RocksServer
or
git clone https://github.com/valmat/RocksServer
cd RocksServer
git submodule update
After then compile dependencies:
./deps/make.sh
Compile:
cd src
make
After: edit config.ini and run
./RocksServer.bin config.ini
Or you can install it:
switch to root and run
make install
Exemple of usage: driver for php Or any your own implementation by protocol description.
First you need implement your own request listener. To do this, you should to implement the interface
template<typename ProtIn, typename ProtOut>
struct RequestBase: public RequestSuperBase
{
virtual void run(const ProtIn &, const ProtOut &) = 0;
};
For example:
RequestPing.h
struct RequestPing : public RequestBase<ProtocolInTrivial, ProtocolOut>
{
virtual void run(const ProtocolInTrivial &in, const ProtocolOut &out) override
{
out.setStr("pong");
}
};
After that, you need to implement a plugin:
smpl_plug.cpp
#include <rocksserver/api.h>
#include "RequestPing.h"
PLUGIN(Extension &extension)
{
extension.bind("/ping", new RequestPing());
}
Compile your plugin:
g++ -I. -I"/usr/include/rocksserver/include" -Wall -O3 -std=c++11 -fPIC -c smpl_plug.cpp -o smpl_plug.o
g++ -Wall -std=c++11 -O3 -shared smpl_plug.o -o smpl_plug.so
and copy to /usr/lib/rocksserver/plugins
cp -f smpl_plug.so /usr/lib/rocksserver/plugins/smpl_plug.so
Restart RocksServer. See example how to extend RocksServer.
Just edit config.ini