Announcement Announcement Module
No announcement yet.
strategies for caching persistent data Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • strategies for caching persistent data

    hi all,
    i've read both of rod's books and have a question about caching strategies. in rod's first book (with ejbs) he developed a sample ticketing application that (from memory) used a very basic cache to access pricing & availability information (for performances @ the venue). this cache was maintained in the business layer. in the second book (without ejbs) the concept of caching at the data access layer was discussed using products such as hibernate and ehcache etc. this seems very attractive but gives rise to my question.
    my question is where does caching 'logic' belong? should it always be in the data access layer or are there times when it is permissable to use caching 'logic' in the business layer (as in rod's first book).
    what form of caching strategy would work best for the sample ticketing application (in 'with ejb's)?
    ur feedback would be most enlightning - implementing caching in an application is very new to me.


  • #2
    Are you taking advantage of an ORM solution (e.g. Hibernate)?

    In applications I've written in the past, I have placed the caching logic in the business layer, it seemed like a good place to control the expiration of items in the cache. If I were doing the same today I would use AOP to place some advice around the data access layer to return the data from cache if it were appropriate.


    • #3
      aop advice

      thanks for the reply dan. that sounds like good advice (no bad pun intended) - i was thinking of using an aop approach - to implement a cache you just need a way to look up the necessary data (appropriate data structure) and a 'timer' field to indicate when the data goes 'stale' - is that all?


      • #4
        Re: strategies for caching persistent data

        In general ORM frameworks do a very good job for in this area, specialy Hibernate and iBatis.
        If you are using Spring JDBC layer or have a lot of data manipulation at the service layer, I'd recomend Wangy] for caching method results.