JCS 过期/删除通知
我们使用 JCS 非常简单。没有分布式或任何东西,简单地说:
JCS jcs = JCS.getInstance("region-name");
我正在尝试注册某种侦听器,该侦听器可用于在元素从缓存中删除或过期时接收通知/事件...
我一直在挖掘 JCS javadoc一段时间了,我尝试过: - 将 IElementEventHandler
的实现添加到缓存的默认 ElementAttributes ...它永远不会被调用。 - 使用 ICacheObserver
的各种实现来注册 ICacheListener
但也永远不会被调用。我不确定这一点是正确的方法,因为我认为这是为了 JCS 的更高级用途......
有谁知道如何(或者如果可能)注册某种监听器/观察者/其他什么那会完成这个吗?我的最终目标是能够在基本上从缓存中删除某些内容时收到通知......我并不特别关心如何提供它不是一个巨大的混乱:P
we use JCS very simply. Not distributed or anything, simply:
JCS jcs = JCS.getInstance("region-name");
I'm trying to register some kind of listener that can be used to receive a notification/event when an element is removed or expired from the cache...
I've been digging through the JCS javadoc for awhile now and I've tried:
- adding an Implementation of IElementEventHandler
to the default ElementAttributes of the cache ... it never gets called.
- using the various implementations of ICacheObserver
to register an ICacheListener
but that never gets called either. I'm not necessarily sure this point is the correct way of doing it as I think this is intended for more advanced uses of JCS ...
Does anyone know how (or if it's possible) to register some kind of listener/obsverver/whatever that will accomplish this? My final goal is to be able to be notified of when something is removed from the cache basically ... I don't particularly care about how provided it isn't a massive kludge :P
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在对 JCS 源代码进行简短审查后,我发现这些接口似乎只与远程缓存内容相关 - 我从未使用过这些内容。此外,我检查了 LRUMemoryCache 和其他一些,看起来对删除的调用没有链接到任何事件处理程序。长话短说,我在 JCS 中找不到任何可以满足您要求的内容。
我不会说这是不可能的,但我会说这看起来不太可能。
您可以在此处查看源代码并进一步查看。
祝你好运。
From what I can tell after a short review of the JCS source, it looks like those interfaces are only tied to the remote cache stuff - which I've never used. Additionally, I examined LRUMemoryCache and a few others and it looks like the calls to remove don't link in to any event handlers. Long story short, I couldn't find anything in JCS that does what you are asking.
I won't say it is impossible, but I would say it looks unlikely.
You can check out the source here and look further.
Good luck.
创建一个抽象类来注册您想要捕获的事件。这对我捕捉这两个事件很有用。
将此抽象事件处理程序添加到 jcs 工厂定义中,如下所示
Create an abstract class that registers the events your interested in capturing. This works for me to capture the two events.
Add this abstract event handler to the jcs factory definition as follows