Aerospike java client

1、要求

java client 要求jdk8及以上版本

2、依赖包

maven

 <dependencies>
      <dependency>
        <groupId>com.aerospike</groupId>
        <artifactId>aerospike-client</artifactId>
        <version>5.0.0</version>
      </dependency>
    </dependencies>

gradle

repositories {
      mavenCentral()
    }
            
    dependencies {
      compile "com.aerospike:aerospike-client:5.0.0"
    }

如果要用到AerospikeClient 的异步方法时,需要引入netty的包。例如:

<dependencies>
      <dependency>
        <groupId>com.aerospike</groupId>
        <artifactId>aerospike-client</artifactId>
        <version>5.0.0</version>
      </dependency>

      <dependency>
        <groupId>io.netty</groupId>
        <artifactId>netty-handler</artifactId>
        <version>4.1.50.Final</version>
      </dependency>

      <dependency>
        <groupId>io.netty</groupId>
        <artifactId>netty-transport</artifactId>
        <version>4.1.50.Final</version>
      </dependency>

      <!-- Only needed when using epoll event loops on linux -->
      <dependency>
        <groupId>io.netty</groupId>
        <artifactId>netty-transport-native-epoll</artifactId>
        <classifier>linux-x86_64</classifier>
        <version>4.1.50.Final</version>
      </dependency>
    </dependencies>

 

 

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

posted on 2022-02-09 17:48  duanxz  阅读(188)  评论(0编辑  收藏  举报