监听Redisson Object Holder(RBucket)中对象的更改?

huangapple go评论107阅读模式
英文:

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&lt;String&gt; bucket = redisson.getBucket(&quot;myBucket&quot;);  
bucket.addListener(new SetObjectListener() {  
    public void onSet(String name) {  
        // ...  
    }  
});

huangapple
  • 本文由 发表于 2020年4月7日 02:14:04
  • 转载请务必保留本文链接:https://go.coder-hub.com/61066239.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定