随笔 - 2228  文章 - 4  评论 - 372  阅读 - 1109万

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   duanxz  阅读(194)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义
· 地球OL攻略 —— 某应届生求职总结
· 提示词工程——AI应用必不可少的技术
· Open-Sora 2.0 重磅开源!
· 周边上新:园子的第一款马克杯温暖上架
历史上的今天:
2017-02-09 chkconfig命令详解
2015-02-09 谈谈分布式事务之三: System.Transactions事务详解[下篇]
2015-02-09 谈谈分布式事务之三: System.Transactions事务详解[上篇]
2015-02-09 谈谈分布式事务之二:基于DTC的分布式事务管理模型[下篇]
2015-02-09 谈谈分布式事务之二:基于DTC的分布式事务管理模型[上篇]
2015-02-09 选择合适的innodb_log_file_size
2015-02-09 灰度上线
< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

点击右上角即可分享
微信分享提示