应用程序启动时如何将数据从数据库加载到Ehcache [英] How to load data from database to Ehcache when the application starts

查看:163
本文介绍了应用程序启动时如何将数据从数据库加载到Ehcache的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在应用程序启动时(即在服务器启动之前,调用任何其他方法之前)使用Spring ehCache将数据从数据库加载到缓存中.我不想使用构造函数. 请帮助我.

I want to load the data from database into cache memory using Spring ehCache when the application starts i.e when the server starts before any other method is called. I dont want to use a constructor. Please help me.

推荐答案

这正是BootstrapCacheLoader将为您做的事情.

This is exactly what the BootstrapCacheLoader will do for you.

请查看以下文档条目.

这似乎已完全集成在Spring Ehcache桥中-请参见

It seems this is fully integrated in the Spring Ehcache bridge - see here

简而言之,到达目的地的步骤有:

In short the steps to get there are:

  1. 确定如何知道启动时需要加载的内容-这就是您的密钥集
  2. 实施自己的BootstrapCacheLoader,将使用该集紧急加载所有条目,在缓存初始化时异步或同步.
  3. 使用BootstrapCacheLoaderFactory通过XML(Ehcache)甚至直接(Spring)进行布线
  1. Determine how you will know what needs to be loaded at startup - that is your set of keys
  2. Implement your own BootstrapCacheLoader that will use the set to load eagerly all entries, async or sync at cache initialisation time.
  3. Wire it using a BootstrapCacheLoaderFactory through XML (Ehcache) or even directly (Spring)

这篇关于应用程序启动时如何将数据从数据库加载到Ehcache的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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