Spring Boot,使用EhCache进行缓存 [英] Spring Boot, caching with EhCache

查看:192
本文介绍了Spring Boot,使用EhCache进行缓存的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I need to cache some data in my application and I am thinking about use Ehcache. And I have several questions:


  1. Ehcache需要另一台服务器吗?

  2. 我需要吗?另一个与Ehcache合作的客户?

  3. Ehcache如何处理多个实例?甚至可以使用Ehcache创建共享缓存之类的东西吗?


推荐答案


我是否需要另一台Ehcache服务器?

Do I need another server for Ehcache?

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

You can use Ehcache in Standalone mode. In this topology, the cache data is held in the application node. So you won't need another server in this mode. Ehcache also provides two other modes:


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

  1. Distributed – The data is held in a remote server (or array of servers) with a subset of recently used data held in each application node. This topology offers a rich set of consistency options. A distributed topology is the recommended approach in a clustered or scaled-out application environment. It provides the highest level of performance, availability, and scalability.

分布式拓扑以 Terracotta开源产品,没有客户限制,但对Terracotta集群大小有限制。使用商业 BigMemory Max 时会删除这些内容。

The distributed topology is available as a Terracotta open source offering with no client limitations but limitations on Terracotta cluster size. These are removed when using the commercial BigMemory Max.




我是否需要另一个客户端才能使用Ehcache?

Do I need some another client to work with Ehcache?

您应该使用Ehcache库以便能够与Ehache沟通。但Spring提供了一种缓存抽象,它更优雅,并且还具有独立于底层缓存实现的优势。因此,如果您使用Spring Caching Abstraction,您可以轻松地将表单Ehcache切换到Hazelcast。您可以在此处<了解更多有关Spring缓存抽象的内容。 / a>。

You should use Ehcache library in order to be able to communicate with Ehache. But Spring provides a Caching Abstraction which is more elegant to work with and also has the advantage of being independent from the underlying caching implementation. So if you use Spring Caching Abstraction you could easily switch form Ehcache to, say, Hazelcast. You can read more about Spring Caching Abstraction in here.

Spring Boot 提供 spring-boot-starter-cache 启动包,自动配置合适的只要启用了缓存支持,CacheManager 就会根据实现情况而定。

Spring Boot provides spring-boot-starter-cache starter package which auto-configures a suitable CacheManager according to the implementation as long as the caching support is enabled.


Ehcache如何处理多个实例?是否可以使用Ehcache创建类似共享缓存的

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

引自 Ehcache文档


Ehcache提供进程内缓存,您可以在
多个节点上进行复制。它也是BigMemory Go和BigMemory
Max,Terracotta的商业缓存和内存数据存储
产品的核心。 BigMemory Max
提供的Terracotta服务器阵列支持混合进程内/进程外配置和
兆兆字节大小的缓存。有关Terracotta的BigMemory
产品的信息,请参阅 http://上的BigMemory Go和BigMemory Max产品
文档。 terracotta.org/documentation

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

As stated above, there is a free clustering option available with Ehcache. For this requirement, Redis and Hazelcast are also good options.

这篇关于Spring Boot,使用EhCache进行缓存的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆