Spring MVC的ehcache或spring cache中最好的Cache实践是什么?

时间:2023-02-10 20:04:19

Planning to implement cache mechanism for static data in spring web based application, can any one explain which is the best and how it works?

计划在基于Spring网络的应用程序中实现静态数据的缓存机制,任何人都可以解释哪个是最好的以及它是如何工作的?

  • EhCache
  • 的Ehcache
  • Spring Cache
  • Spring Cache

1 个解决方案

#1


10  

Disclaimer : I am a Terracotta / Software AG employee, the maintainers of Ehcache

免责声明:我是Terracotta / Software AG的员工,也是Ehcache的维护者

Ehcache is a JVM caching library, famous for being used as the default 2nd level cache for the Hibernate ORM

Ehcache是​​一个JVM缓存库,以用作Hibernate ORM的默认二级缓存而闻名

Spring cache was introduced in Spring 3.1, and brought annotations such as @CachePut to define uses of caches in a Spring application; by default Spring cache uses a plain Map, but you can configure it to use any popular caching framework, including Ehcache

在Spring 3.1中引入了Spring缓存,并带来了诸如@CachePut之类的注释来定义Spring应用程序中缓存的使用;默认情况下,Spring缓存使用普通Map,但您可以将其配置为使用任何流行的缓存框架,包括Ehcache

Since Spring 4.1, Spring cache supports JSR-107, the standard for caching on the JVM.

从Spring 4.1开始,Spring缓存支持JSR-107,这是JVM上缓存的标准。

What that means, is that you can add JSR-107 caching annotations, and then choose your caching library (ehcache 2 or 3 / guava / caffeine / etc.) : you're not tied to any caching vendor, even not tied to Spring cache annotations !

这意味着,您可以添加JSR-107缓存注释,然后选择您的缓存库(ehcache 2或3 / guava / caffeine /等):您不依赖于任何缓存供应商,甚至不依赖于Spring缓存注释!

There's this nice blog post explaining the parallel between Spring cache annotations and JSR-107 annotations and if you choose to use Ehcache3 in your spring boot application, there's another interesting blog post explaining you how to integrate it in your app

有一篇很好的博客文章解释了Spring缓存注释和JSR-107注释之间的平行关系,如果你选择在Spring启动应用程序中使用Ehcache3,还有另一篇有趣的博客文章解释你如何将它集成到你的应用程序中

#1


10  

Disclaimer : I am a Terracotta / Software AG employee, the maintainers of Ehcache

免责声明:我是Terracotta / Software AG的员工,也是Ehcache的维护者

Ehcache is a JVM caching library, famous for being used as the default 2nd level cache for the Hibernate ORM

Ehcache是​​一个JVM缓存库,以用作Hibernate ORM的默认二级缓存而闻名

Spring cache was introduced in Spring 3.1, and brought annotations such as @CachePut to define uses of caches in a Spring application; by default Spring cache uses a plain Map, but you can configure it to use any popular caching framework, including Ehcache

在Spring 3.1中引入了Spring缓存,并带来了诸如@CachePut之类的注释来定义Spring应用程序中缓存的使用;默认情况下,Spring缓存使用普通Map,但您可以将其配置为使用任何流行的缓存框架,包括Ehcache

Since Spring 4.1, Spring cache supports JSR-107, the standard for caching on the JVM.

从Spring 4.1开始,Spring缓存支持JSR-107,这是JVM上缓存的标准。

What that means, is that you can add JSR-107 caching annotations, and then choose your caching library (ehcache 2 or 3 / guava / caffeine / etc.) : you're not tied to any caching vendor, even not tied to Spring cache annotations !

这意味着,您可以添加JSR-107缓存注释,然后选择您的缓存库(ehcache 2或3 / guava / caffeine /等):您不依赖于任何缓存供应商,甚至不依赖于Spring缓存注释!

There's this nice blog post explaining the parallel between Spring cache annotations and JSR-107 annotations and if you choose to use Ehcache3 in your spring boot application, there's another interesting blog post explaining you how to integrate it in your app

有一篇很好的博客文章解释了Spring缓存注释和JSR-107注释之间的平行关系,如果你选择在Spring启动应用程序中使用Ehcache3,还有另一篇有趣的博客文章解释你如何将它集成到你的应用程序中