Google Guava Cache - Random Thoughts on Coding
Google Guava Cache Dec 14th, 2011 This Post is a continuation of my series on Google Guava, this time covering Guava Cache. Guava Cache offers more flexibility and power than either a HashMap or ConcurrentHashMap, but is not as heavy as using EHCache or Memcached (or robust for that matter, as Guava Cache operates solely in memory). The Cache interface has methods you would expect to see like 'get', and 'invalidate'. A method you won't find is 'put', because Guava Cache is 'self-populating', values that aren't present when requested are fetched or calculated, then stored. This means a 'get' call will never return null. In all fairness, the previous statement is not %100 accurate. There is another method 'asMap' that exposes the entries in the cache as a thread safe map. Using 'asMap' will result in not having any of the self loading operations performed, so calls to 'get' will return null if the value is not present (What fun is that?). Although this is a post about Guava Cache,Read full article from Google Guava Cache - Random Thoughts on Coding
No comments:
Post a Comment