Yet another NoSql database based on leveldb.
- Simple, small code base, easy to learn API
- Very fast, high performance
####1. Start MyTable server
com.lubin.myTable.server.MyTableServer####2. Create a client and try basic operation...
IMyTableclient = MyTableClient.getInstance();
Stringkey = "hello";
client.put(key, bytes("myTable"));
byte[] value = client.get(key);
System.out.println("key="+key+" value=" + asString(value)+"\n");
client.delete(key);
client.put("a", bytes("myTable:"+ "a"));
client.put("b", bytes("myTable:"+ "b"));
client.put("c", bytes("myTable:"+ "c"));
client.put("d", bytes("myTable:"+ "d"));
client.put("e", bytes("myTable:"+ "e"));
Map<String, byte[]> res = client.range("a", "d");
for(Map.Entry<String, byte[]> entry :res.entrySet()){
System.out.println("key="+entry.getKey() + " value="+asString(entry.getValue()));
}output:
key=hello value=myTable
key=a value=myTable:a
key=b value=myTable:b
key=c value=myTable:c
####3. Config file for myTable server
server{port=9090backlog=1000async=false//handling request in business logic thread poolasyncThreadPoolSize=4ioThreadNum=1objects=[com.lubin.myTable.obj.MyTableObj]}leveldb{dataDir="default"createIfMissing=truecacheSize=500//500MwriteBufferSize=16//16MWriteOptions{sync=false}ReadOptions{fillCache=trueverifyChecksums=true}}####4. Config file for myTable client
client{reconnInterval=1000//time interval(million second) for reconnecting to serverasyncThreadPoolSize=1//thread pool for excuting Async callbackioThreadNum=2serializer=0//0 kryo 1 jsonobjects=[{ name =com.lubin.myTable.obj.IMyTableservers="127.0.0.1:9090"}]}To build the JAR file of myTable, you need to install Maven (http://maven.apache.org), then type the following command:
$ mvn package
To generate project files (.project, .classpath) for Eclipse, do
$ mvn eclipse:eclipse
then import the folder from your Eclipse.
======== Oh, that's all! Easy to understand, right? Please feel free to contact me(2005dawnbreaks@gmail.com) if you have any questions.