mblanc's posterous http://mblanc.posterous.com Most recent posts at mblanc's posterous posterous.com Thu, 09 Jun 2011 03:57:00 -0700 Non-blocking Asynchronous self populating cache with Ehcache http://mblanc.posterous.com/non-blocking-asynchronous-self-populating-cac http://mblanc.posterous.com/non-blocking-asynchronous-self-populating-cac

Suppose you would like to implement the following algorithm :

  • try to get an element from the cache
  • if the element is not expired
    • serve the value
  • else
    • serve the expired value
    • refresh the element in the background

Ehcache doesn't provide an out-of-the-box solution for this.

Here is an Ehcache decorator that does just that :

Permalink | Leave a comment  »

]]>
http://posterous.com/images/profile/missing-user-75.png http://posterous.com/users/3snwQSK3Txqp mblanc mblanc