首页  

aerospike 乐观锁实例     所属分类 aerospike 浏览量 1032
基于 generation 实现乐观锁
更新记录时比较版本号


WritePolicy policy = new WritePolicy();
policy.generationPolicy = GenerationPolicy.EXPECT_GEN_EQUAL;
policy.generation = generation;

public enum GenerationPolicy {   
    NONE,EXPECT_GEN_EQUAL,EXPECT_GEN_GT
}

NONE  
Do not use record generation to restrict writes. 

EXPECT_GEN_EQUAL
Update/delete record if expected generation is equal to server generation. Otherwise, fail. 

EXPECT_GEN_GT   
Update/delete record if expected generation greater than the server generation. Otherwise, fail.
This is useful for restore after backup. 
     
    
记录不存在 generation 为 0

com.aerospike.client.AerospikeException: Error Code 3: Generation error


例子代码
https://gitee.com/dyyx/asdemo/blob/master/src/main/java/demo/GenerationTest.java

上一篇     下一篇
springboot REST api 实例

基于 HttpURLConnection 的 http 客户端

Spring5.2 @Configuration 属性 proxyBeanMethods 作用

Maven设置项目编码及jdk版本

springboot配置大全

催眠歌曲系列