Spring MVC的ehcache或spring cache中最好的Cache实践是什么? [英] What are the best Cache practices in ehcache or spring cache for spring MVC?

查看:314
本文介绍了Spring MVC的ehcache或spring cache中最好的Cache实践是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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?


  • EhCache

  • Spring Cache

推荐答案

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

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

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

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

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

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 4.1开始,Spring缓存支持 JSR-107 ,JVM上缓存的标准。

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

这意味着,您可以添加JSR-107缓存注释,然后选择您的缓存库( ehcache 2或3 / 番石榴 / 咖啡因 / ):你没有绑定任何缓存供应商,甚至没有绑定Spring缓存注释!

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 !

,如果您选择在Spring启动应用程序中使用Ehcache3,那么还有另一个有趣的博客文章,向您解释如何将其集成到您的应用中

这篇关于Spring MVC的ehcache或spring cache中最好的Cache实践是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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