beansdb的java客户端 beansdb4j

openkk 13年前
     <p>这是beansdb的java客户端, 它使用了和python客户端一模一样的hash算法, 所以它和python客户端是完全兼容 — 这意味着你可以用python客户端存一个东西进beansdb, 然后用java客户端把它取出来。</p>    <p>示例代码:</p>    <pre class="brush:java; toolbar: true; auto-links: false;"> // specify the beansdb nodes.  Map<InetSocketAddress, Range> servers = new HashMap<InetSocketAddress, Range>();  servers.put(new InetSocketAddress("localhost", 7900), new Range(, 16));  servers.put(new InetSocketAddress("localhost", 7901), new Range(, 16));  servers.put(new InetSocketAddress("localhost", 7902), new Range(, 16));     // 3,2,2 is the NRW number in the Dynamo thesis  Beansdb db = new Beansdb(servers, 16, 3, 2, 2);     // set the key: foo to value: bar  db.set("foo", "bar");     // get the value of foo  System.out.println(db.get("foo"));     // get the value for keys: hello, james, foo  List<String> keys = new ArrayList<String>(3);  keys.add("hello");  keys.add("james");  keys.add("foo");  Map<String, Object> ret = db.getMulti(keys);     for (String key : ret.keySet()) {         System.out.println(key + " : " + ret.get(key));  }     // delete the key: foo  db.delete("foo");     // close the db connection  db.close();</pre>    <p><strong>项目主页:</strong><a href="http://www.open-open.com/lib/view/home/1322744402030" target="_blank">http://www.open-open.com/lib/view/home/1322744402030</a></p>    <p></p>