• 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

  • 相关阅读:
    通用sqlserver分页存储过程
    JSONP解决跨域请求
    laravle框架
    XML作用
    mysql 中的常用查询
    smarty模板技术
    Cookie和Session 会话技术
    正则表达式
    Mongodb常用知识点
    PHP之PDO
  • 原文地址:https://www.cnblogs.com/duanxz/p/15876090.html
Copyright © 2020-2023  润新知