NIF based Erlang bindings for aerospike based on libaerospike. CBERL is at early stage of development, it only supports very basic functionality. Please submit bugs and patches if you find any. Tested on mac, debian squeeze and amazon linux.
First you must have lua5.1 installed.
curl -R -O http://www.lua.org/ftp/lua-5.1.tar.gz
Then:
git clone git@github.com:chitika/aerospike.git
Then, get git submodules:
cd aerospike
git submodule update --init --remote --recursive
Then:
### assuming you have rebar in your path
./rebar get-deps compile
Or just include it as a dependency in your rebar config.
echo -n '#include "aserl_error.h"
char* aserl_error_status_string(as_status as_res) {
switch (as_res) {
' > c_src/aserl_error.c
cat c/src/include/aerospike/as_status.h | grep "AEROSPIKE_[A-Z_]*\>.*=" | sed 's/^.*AEROSPIKE_/AEROSPIKE_/g' | sed 's/[ ]*//g' | sed "s/`echo -e \\\t`*//g" | sed "s/,*//g" | awk -F"=" '!($2 in a){a[$2];print "\t\tcase "$1":\n\t\t\treturn \""tolower($1)"\";"}' >> c_src/aserl_error.c
echo -n '
}
return "aerospike_err_unkown";
}' >> c_src/aserl_error.c
Make sure you have aerospike running on localhost or use aerospike:new(Host) instead.
%% create a connection pool of 5 connections named aerospike_default
%% you can provide more argument like host, username, password,
%% bucket and transcoder - look at [aerospike.erl](https://github.com/wcummings/aerospike/blob/master/src/aerospike.erl) for more detail
aerospike:start_link(aerospike_default, 5).
{ok, <0.33.0>}
%% Poolname, Key, Expire - 0 for infinity, Value
aerospike:set(aerospike_default, <<"fkey">>, 0, <<"aerospike">>).
ok
aerospike:get(aerospike_default, <<"fkey">>).
{<<"fkey">>, ReturnedCasValue, <<"aerospike">>}
For more information on all the functions -> ./rebar doc (most of documentation is out of date right now)
I included results of basho_bench which I ran on my mac. It is the results of 100 processes using a pool of 5 connections. I included basha_bench driver and config file under bench. Please tweak the config file for your requirement and run your own benchmarks.
-
Update documentation
-
Write more tests