Hazelcast vs Ehcache + Hazelcast 注释用于使用 Spring 和 Hibernate 在服务/dao 层进行缓存?
我想评估 Hazecast 与 Ehcache 分布式缓存。
首先如何将它们与具有标准 dao/service 层的 Spring + Hibernate 项目一起使用。 Ehcache 有非常优雅且易于使用的注释,例如:
@Cacheable(cacheName = "test", keyGenerator = @KeyGenerator (
name = "SpELCacheKeyGenerator", properties = @Property(value = "#key.string(#args[0])", name = "expression")))
Hazelcast 有类似上面的注释吗?我没有找到任何关于如何以这种方式使用 Hazelcast 来处理实体/dtos 的信息。
I want to evaluate Hazecast vs Ehcache distributed caches.
First how to use them with Spring + Hibernate project which have standard dao/service layers.
Ehcache has very elegant and easy to use annotations like :
@Cacheable(cacheName = "test", keyGenerator = @KeyGenerator (
name = "SpELCacheKeyGenerator", properties = @Property(value = "#key.string(#args[0])", name = "expression")))
Is there anything like the above for Hazelcast? I didn't find any information how to use Hazelcast in that fashion for entities/dtos.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
Hazelcast 2.1 已经可用,并且它具有 Spring Cache 的实现。 Spring Cacheable 注解现在可以轻松地与 Hazelcast 一起使用。
http://www.hazelcast.com/docs/2.1/manual/multi_html /ch14s03.html
Hazelcast 2.1 is available and it has implementations for Spring Cache. Spring Cacheable annotation can be easily used with Hazelcast now.
http://www.hazelcast.com/docs/2.1/manual/multi_html/ch14s03.html
Spring 的 Cache 抽象是 Spring 3.1 引入的,旨在缓存方法的结果,从而减少基于缓存中可用信息的执行次数。
如果您想使用 EhCache 或 Hazelcast 作为 Hibernate 二级缓存,那么您应该使用 Hibernate 的配置(使用 Spring xml 或 Hibernate 注释)。 Hibernate二级缓存和Spring的缓存没有关系。
Spring 有两个开箱即用的缓存提供程序实现。来自官方文档: Spring 缓存抽象
目前 Hazelcast 没有内置的 Spring Cache Provider。但 Hazelcast 公共群组上有一个简单的实施帖子。请参阅下面的链接;
将 Spring 3.1 可缓存注解与 Hazelcast 集成
Spring's Cache abstraction is introduced by Spring 3.1 and designed to cache results of methods, reducing thus the number of executions based on the information available in the cache.
If you want to use EhCache or Hazelcast as Hibernate 2nd level cache then you should use Hibernate's configuration (either with Spring xml or Hibernate annotations). There is no relation between Hibernate L2 cache and Spring's cache.
Spring has two out-of-the-box implementations of cache providers. From official documentation: Spring Cache Abstraction
At the moment Hazelcast does not have built-in Spring Cache Provider. But there is a simple implementation post on Hazelcast public group. See the link below;
Integrating Spring 3.1 Cacheable Annotation with Hazelcast