handlersocket是mysql的一个插件,实现了nosql的特性,可以使用mysql表的索引,
相对于hbase、memcache等nosql方案,具有更大的灵活性,与memcache相比较,具有以下优势:
1、使用nosql的同时可以使用mysql的所有特性;
2、无memcache的持久化的问题;
3、可以使用mysql的索引,查询时不再是简单的的key->value,可以使用"=,>=,<=,>,<"条件,同时可以使用较为复杂的过滤条件。
以下是我用erlang实现的client,基于gen_server,可以支持批量操作。
C++语言的版本需要使用lib库,是对lib库的一个封装。
测试的性能并没有网上说的那么高,按主键查询只有几万。可能是我的表字段数较多的原因(7字段)。
使用时建议使用perconadb,因为源码里已经包括了handlersocket,并且做了一些改进。
C++与erlang版的客户端都可以从这里下载:https://sourceforge.net/projects/erlanghandlerso/
或者从http://download.csdn.net/detail/flyinmind/5064808下载erlang版的客户端。
erlang版当前还没有支持Auth、Filters,C++版没不支持Auth、批量操作。
Java版是基于hs4j做的,没有测试完毕,未开源,支持“批量操作、Filters、Auth”。
转载请注明出处:http://blog.csdn.net/flyinmind/article/details/8581569
Was tested with perconadb 5.x, when I run on 8core-1.6G server, 7columns table, one connection. BATCH-INSERT can reach 50,000/s.SINGLE-SELECT can reach 48,000/s.
It can run in any erlang project, and can have more than one instance, for example:
{ok, Pid1} = hsclient:start_link("192.168.9.3", 9999).
{ok, Pid2} = hsclient:start_link("192.168.9.3", 9999).
And then:
hsclient:open_index(Pid1, <<"1">>, <<"pushdb">>, <<"mc_msg">>, <<"PRIMARY">>, <<"MsgID,RequestID,Message">>).
hsclient:open_index(Pid2, <<"1">>, <<"pushdb">>, <<"mc_msg">>, <<"PRIMARY">>, <<"MsgID,RequestID,Message">>).
It can support batch operations, for example:
hsclient:insert(Pid2, <<"1">>, [
[<<"1">>, <<"11">>, <<"test">>],
[<<"6">>, <<"11">>, <<"test">>],
]).
You can use it to create a handlersocket pool.
Other operations, for example:
hsclient:select(Pid1, <<"1">>, 6, <<"=">>, [<<"1">>]).
hsclient:delete(Pid2, <<"1">>, <<"=">>, [[<<"1">>]]).
hsclient:update(Pid, <<"1">>, <<"=">>, [
{[<<"11">>], [<<"11">>, <<"112">>, <<"test1">>]},
{[<<"12">>], [<<"12">>, <<"112">>, <<"test2">>]}
], 1, 0).
NOT SUPPORT:
1.Auth
2.Filters
There only one erlang code file, you can download it from "files".
At the end of the file, there are examples.
You can add "Auth" and "Filters" yourself, it is very easy.