Results 1 to 5 of 5

Thread: Where can I put a caching object into the application scope on startup the app?

  1. #1
    Join Date
    Dec 2011
    Posts
    7

    Question Where can I put a caching object into the application scope on startup the app?

    I'm using Spring 3 and I want to put a caching object using Ehcache, JCS, or something else, to the application scope when my application starts...
    What module of Spring I must to use and how?
    Do you know some tutorial about how to do this?
    I need this feature of my application because every user from any session must can have eccess to this object.

    Also, do you know some caching library implementation that can support the update of my caching objects in a defined time? Something like a scheduler that can update my caching object automaticaly? Or some way to do this using Quartz or Spring Batch?

    I hope my questions are clear, or tell me if I need to explain more clearly my doubts.

    Thanks in advance...

  2. #2
    Join Date
    Jan 2009
    Location
    Huntington Beach, CA
    Posts
    718

    Default

    By default all Spring Beans are configured to be Singleton scope, and the Spring Container is almost always application scope, I say almost, just because it depends on when and where you create your App context. So by default if you define your bean for your cache, then it is already how you need it.

    For time based invalidation of cache's. That is based on the cache implementation you use and its configuration. I believe in your ehcache.xml for your cache region you can set a time based invalidation.

    As far as pre-populating your cache, you can always use init-method in <bean> tag or if you have the code you can add @PostConstruct and <context:annotation-config> to have a method run after the object has been instantiated.

    Mark

  3. #3
    Join Date
    Dec 2011
    Posts
    7

    Default

    Thanks for your approaches...

    So, if I use the invalitation approach, how can I re-populate the cache with the new contents of the objects automatically?

  4. #4
    Join Date
    Jan 2009
    Location
    Huntington Beach, CA
    Posts
    718

    Default

    That would be a caching product feature. I recommend checking out the ehcache documentation to see if they have that feature. Typically they have a refresh feature.

    Mark

  5. #5
    Join Date
    Dec 2011
    Posts
    7

    Default

    Thanks for your replies... I'm testing the approaches...

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •