英文:
Redisson RRingBuffer capacity cannot be changed dynamically under the same key
问题
目前我正在开发的软件中,我希望使用Redis来存储一些数据。具体而言,我想使用RRingBuffer,我最初设置了容量,但它可以在运行时更改。我的想法是创建一个新的RB,并将旧RB中的数据移动到新RB中。例如,也许这是错误的:
// 之前以容量4创建的一些数据
final RRingBuffer<String> oldRB = cache.get(SOME_KEY);
log.info(oldRB);
// 新的环形缓冲区
final RRingBuffer<String> newRB = redisson.getRingBuffer(A_NEW_RING_BUFFER);
newRB.trySetCapacity(3);
将旧RB中的数据添加到新RB中...
cache.put(SOME_KEY, newRB)
log.info(newRB)
初始情况下,这似乎是有效的,但似乎Redis会将这个带有初始容量的RB缓存起来,而且无法更改它。
英文:
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);
log.info(oldRB);
// new ring buffer with
final RRingBuffer<String> newRB = redisson.getRingBuffer(A_NEW_RING_BUFFER);
newRB.trySetCapacity(3);
add the data from oldRB to newRB...
cache.put(SOME_KEY, newRB)
log.info(newRB)
-------------------------------------------
CONSOLE:
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.
答案1
得分: 1
RRingBuffer.setCapacity()
方法在Redisson 3.13.5中添加。因此,您可以在不复制缓冲区状态的情况下更改容量。
英文:
RRingBuffer.setCapacity()
method added in Redisson 3.13.5. So you can change capacity without buffer state copying.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论