RocksServer supports the following operations:
- Get a value or multiple values by key or keys
- Set a value or multiple values by key or keys
- Delete key or keys from the database
- Check if a key exists
- Increment a value by key
- Iterate over key-value pairs by key prefix
- Iterate over key-value pairs by seek key or key prefix
For more details, see: protocol description
RocksServer depends on RocksDB and LibEvent.
The compiler should support C++11
.
First, install RocksDB dependencies:
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 --init
After that, compile the dependencies:
./deps/make.sh
Compile the server:
cd src
make
Then, edit config.ini
and run:
./RocksServer.bin config.ini
Alternatively, you can install it:
Switch to root and run:
make install
Examples of usage:
You can also implement your own client based on the protocol description.
To extend RocksServer, you should first implement your own request listener by implementing the following interface:
template<typename ProtIn, typename ProtOut>
struct RequestBase: public RequestSuperBase
{
virtual void run(const ProtIn &, const ProtOut &) = 0;
};
Example:
RequestPing.h
struct RequestPing : public RequestBase<ProtocolInTrivial, ProtocolOut>
{
virtual void run(const ProtocolInTrivial &in, const ProtocolOut &out) override
{
out.setStr("pong");
}
};
Then, 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
Copy it to /usr/lib/rocksserver/plugins
:
cp -f smpl_plug.so /usr/lib/rocksserver/plugins/smpl_plug.so
Restart RocksServer. See this example for how to extend RocksServer.
To customize RocksServer, edit config.ini.
RocksServer is licensed under the BSD License.