加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 大数据 > 正文

java – Spring Boot,使用EhCache进行缓存

发布时间:2020-12-15 01:41:26 所属栏目:大数据 来源:网络整理
导读:我需要在我的应用程序中缓存一些数据,我正在考虑使用Ehcache.我有几个问题: Ehcache需要另一台服务器吗? 我是否需要其他客户与Ehcache合作? Ehcache如何处理多个实例?甚至可以使用Ehcache创建共享缓存之类的东西吗? 最佳答案 Do I need another server

我需要在我的应用程序中缓存一些数据,我正在考虑使用Ehcache.我有几个问题:

> Ehcache需要另一台服务器吗?
>我是否需要其他客户与Ehcache合作?
> Ehcache如何处理多个实例?甚至可以使用Ehcache创建共享缓存之类的东西吗?

最佳答案

Do I need another server for Ehcache?

您可以在独立模式下使用Ehcache.在此拓扑中,缓存数据保存在应用程序节点中.所以在这种模式下你不需要另一台服务器. Ehcache还提供two other modes:

>分布式 – 数据保存在远程服务器(或服务器阵列)中,每个数据中都包含最近使用的数据子集
应用节点.此拓扑提供了丰富的一致性
选项.分布式拓扑是a中推荐的方法
集群或扩展的应用程序环境.它提供了
最高级别的性能,可用性和可伸缩性.

分布式拓扑以Terracotta open source offering的形式提供,没有客户端限制,但对Terracotta集群大小有限制.使用商业BigMemory Max时将删除这些内容.
>复制 ??- 缓存的数据集保存在每个应用程序节点中,数据在节点之间复制或无效
锁定.复制可以是异步的,也可以是同步的
写入线程在传播发生时阻塞的位置.唯一的
此拓扑中支持的一致性模式是弱一致性.

Do I need some another client to work with Ehcache?

您应该使用Ehcache库以便能够与Ehache通信.但是Spring提供了一个缓存抽象,它更优雅,并且还具有独立于底层缓存实现的优势.因此,如果您使用Spring Caching Abstraction,您可以轻松地将表单Ehcache切换到Hazelcast.您可以在here中阅读有关Spring Caching Abstraction的更多信息.

Spring Boot提供了spring-boot-starter-cache启动程序包,只要启用了缓存支持,它就会根据实现自动配置合适的CacheManager.

How Ehcache works with multiple instances? Is it even possible to
create something like shared cache using Ehcache?

引自Ehcache documentation:

Ehcache provides in-process cache,which you can replicate across
multiple nodes. It is also at the core of BigMemory Go and BigMemory
Max,Terracotta’s commercial caching and in-memory data-storage
products. The Terracotta Server Array provided with BigMemory Max
enables mixed in-process/out-of-process configurations with
terabyte-size caches. For information about Terracotta’s BigMemory
offerings,see the BigMemory Go and BigMemory Max product
documentation at 07006.

如上所述,Ehcache提供了一个免费的群集选项.
对于这个要求,Redis和Hazelcast也是不错的选择.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读