Command like redis incr :atomic increment operations

Unless if -2 is passed in the policy, right?

That’s now correct - a lot can change in 4 years :laughing:.

What to we need to do for multiple counter with some value ?

You can, in the same operation, increment multiple bins with different increments by chaining the different operations… I am not a client developer so maybe this is a very poor way of doing this but it seems to work as one would expect…

    Bin incr1 = new Bin ("bin1", 1);
    Bin incr2 = new Bin ("bin2", 3);

    Bin bin1 = new Bin ("bin1", 5);
    Bin bin2 = new Bin ("bin2", 8);
    Key key = new Key("test", "testset", "key1");
    client.put(null, key, bin1, bin2);

    Record record = client.get(null, key);
    client.operate(null, key, Operation.add(incr1), Operation.add(incr2));
    Record record2 = client.get(null, key);
    
    System.out.println("Record before operate: " + record);
    System.out.println("Record after  operate: " + record2);


Record before operate: (gen:1),(exp:355024488),(bins:(bin1:5),(bin2:8))
Record after  operate: (gen:2),(exp:355024488),(bins:(bin1:6),(bin2:11))
1 Like

This topic was automatically closed 84 days after the last reply. New replies are no longer allowed.