• 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

  • 相关阅读:
    Python 通过最低位判断数字是偶数还是奇数
    C语言 windows下Ansi和UTF-8编码格式的转换
    C语言 Ubuntu系统 UTF-8 文字处理
    C语言 使用char字符实现汉字处理
    C# GUI应用 实现 2048游戏
    Docker部署Minio
    Ubuntu18.04开启root
    Ubuntu18.04安装Docker
    docker安装mysql
    idea启动项目端口被占用
  • 原文地址:https://www.cnblogs.com/duanxz/p/15876090.html
Copyright © 2020-2023  润新知