Aerospike java client
1、要求
java client 要求jdk8及以上版本
2、依赖包
maven
com.aerospike aerospike-client 5.0.0
gradle
repositories { mavenCentral() } dependencies { compile "com.aerospike:aerospike-client:5.0.0" }
如果要用到AerospikeClient 的异步方法时,需要引入netty的包。例如:
com.aerospike aerospike-client 5.0.0 io.netty netty-handler 4.1.50.Final io.netty netty-transport 4.1.50.Final io.netty netty-transport-native-epoll linux-x86_64 4.1.50.Final
java示例:
AerospikeClient client = new AerospikeClient("192.168.1.150", 3000); Key key = new Key("ns1", "demo", "putgetkey"); Bin bin1 = new Bin("bin1", "value1"); Bin bin2 = new Bin("bin2", "value2"); // Write a record client.put(null, key, bin1, bin2); // Read a record Record record = client.get(null, key); client.close();
服务端用aql查看插入结果:
参考:https://developer.aerospike.com/client/java/install