我开始使用Java客户端中的ListOperation,并且操作无法按预期工作。这是我的代码:
AerospikeClient client = new AerospikeClient("10.0.0.1", 3000);
Key key = new Key("test", "demo", "testlist");
Value vll = Value.get(123);
List<Value> itemList = new ArrayList<Value>();
itemList.add(Value.get("s11"));
itemList.add(Value.get("s22222"));
Bin bin01 = new Bin("bin3", Value.get(itemList));
client.put(null, key, bin01);
Record record0 = client.operate(null, key, Operation.put(new Bin("bin4", 90)), ListOperation.insertItems("bin6", 0, itemList) , Operation.get());
System.out.println("record0");
System.out.println(record0);
Record record1 = client.operate(null, key, ListOperation.append("bin3", vll), Operation.get());
System.out.println("record1");
System.out.println(record1);
itemList.add(Value.get("s3333333"));
itemList.add(Value.get("s4444444444"));
itemList.add(Value.get("s5555555555555555"));
Record record2 = client.operate(null, key,
ListOperation.insertItems("bin3", 0, itemList), Operation.get()
);
System.out.println("record2");
System.out.println(record2);
Record record3 = client.get(null, key);
System.out.println("record3");
System.out.println(record3);
以下是输出:
record0(gen:2),(exp:239021264),(bins:(bin3:[s11,s22222]),(bin4:90)) record1(gen:3),(exp:239021264),(bins:(bin3:[s11,s22222]),(bin4:90)) record2(gen:4),(exp:239021265),(bins:(bin3:[s11,s22222]),(bin4:90)) record3(gen:4),(exp:239021265),(bins:(bin3:[s11,s22222]),(bin4:90))
似乎我的代码中使用的所有ListOperations都未应用。我使用它错了吗?
感谢。
答案 0 :(得分:3)
需要服务器版本3.7.0.1+来执行上面的ListOperations。测试版本3.3.21。