Redisson RRingBuffer capacity cannot be changed dynamically under the same key

Tags: , ,

currently I’m working on software where I would like to use Redis to store some data. Specifically, I would like to use the RRingBuffer where I initially set capacity and it can change during the runtime. My idea was that a new RB is created and the data from oldRB is moved to newRB For example, maybe this is wrong:

    // has some data that is created earlier with a capacity of 4
    final RRingBuffer<String> oldRB = cache.get(SOME_KEY);;

    // new ring buffer with  
    final RRingBuffer<String> newRB = redisson.getRingBuffer(A_NEW_RING_BUFFER);

    add the data from oldRB to newRB...

    cache.put(SOME_KEY, newRB)
    info: ["one", "two", "three", "four", "five"]
    info: ["three", "four", "five"]

This is initially working but it seems like Redis caches this RB with the initial capacity and cannot change it.


RRingBuffer.setCapacity() method added in Redisson 3.13.5. So you can change capacity without buffer state copying.

Source: stackoverflow