英文:
Listen for changes to an object in a Redisson Object Holder (RBucket)?
问题
RBucket类提供:
addListener(ObjectListener listener)
我尝试使用这个方法,但据我所知,我只能监听对象被删除(DeletedObjectListener)或过期(ExpiredObjectListener)的情况。是否可以监听RBucket中对象的更改?
英文:
The RBucket class offers:
addListener(ObjectListener listener)
I tried to use this method but as far as I can tell, I could only listen for when an object is deleted (DeletedObjectListener) or expired (ExpiredObjectListener). Is it possible to listen to changes to an object in an RBucket?
答案1
得分: 1
Redisson允许跟踪RBucket
对象的集合事件。以下是代码示例:
RBucket<String> bucket = redisson.getBucket("myBucket");
bucket.addListener(new SetObjectListener() {
public void onSet(String name) {
// ...
}
});
英文:
Redisson allows to track set event of RBucket
object. Here is the code example:
RBucket<String> bucket = redisson.getBucket("myBucket");
bucket.addListener(new SetObjectListener() {
public void onSet(String name) {
// ...
}
});
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论