{"id":366,"date":"2011-02-16T00:11:00","date_gmt":"2011-02-16T00:11:00","guid":{"rendered":"http:\/\/www.javacodegeeks.com\/2012\/10\/spring-3-1-cache-abstraction-tutorial.html"},"modified":"2012-10-24T14:05:24","modified_gmt":"2012-10-24T14:05:24","slug":"spring-31-cache-abstraction-tutorial","status":"publish","type":"post","link":"https:\/\/www.javacodegeeks.com\/2011\/02\/spring-31-cache-abstraction-tutorial.html","title":{"rendered":"Spring 3.1 Cache Abstraction Tutorial"},"content":{"rendered":"<div dir=\"ltr\" style=\"text-align: left\">One of the new features introduced in the <a href=\"http:\/\/gordondickens.com\/wordpress\/2011\/02\/11\/spring-3-1-whats-up-and-coming\/\">forthcoming Spring 3.1 version<\/a> is the one of <a href=\"http:\/\/static.springsource.org\/spring\/docs\/3.1.0.M1\/spring-framework-reference\/html\/cache.html\">cache abstraction<\/a>. <\/p>\n<p><i>Spring Framework provides support for transparently adding caching into an existing Spring application. Similar to the <a href=\"http:\/\/static.springsource.org\/spring\/docs\/3.1.0.M1\/spring-framework-reference\/html\/transaction.html\">transaction<\/a> support, the caching abstraction allows consistent use of various caching solutions with minimal impact on the code.<\/i><\/p>\n<p>At its core, the abstraction applies caching to Java methods, reducing thus the number of executions based on the information available in the cache. That is, each time a targeted method is invoked, the abstraction will apply a caching behaviour checking whether the method has been already executed for the given arguments. If it has, then the cached result is returned without having to execute the actual method; if it has not, then method is executed, the result cached and returned to the user so that, the next time the method is invoked, the cached result is returned.<\/p>\n<p>This concept is of course not something new. You can check out <a href=\"http:\/\/www.briandupreez.net\/2010\/06\/spring-aspectj-ehcache-method-caching.html\">Spring, AspectJ, Ehcache Method Caching Aspect<\/a> a very interesting post from <a href=\"http:\/\/www.briandupreez.net\/\">Brian Du Preez<\/a>, one of our <a href=\"http:\/\/www.javacodegeeks.com\/p\/jcg.html\">JCG partners<\/a>, in which <a href=\"http:\/\/www.javacodegeeks.com\/?tag=aspect-oriented-programming\">Aspect Oriented Programming<\/a> is used.<\/p>\n<p>As its name implies, Cache Abstraction is not an actual implementation, so it requires the use of an actual storage to store the cache data. As you might have guessed, <a href=\"http:\/\/ehcache.org\/\">Ehcache<\/a> support is provided out of the box. There is also an implementation based on JDK&#8217;s <a href=\"http:\/\/download.oracle.com\/javase\/6\/docs\/api\/java\/util\/concurrent\/ConcurrentMap.html\">ConcurrentMap<\/a> and you can actually <a href=\"http:\/\/static.springsource.org\/spring\/docs\/3.1.0.M1\/spring-framework-reference\/html\/cache.html#cache-plug\">plug-in different back-end caches<\/a>.<\/p>\n<p>Now, let&#8217;s see some sample code on caching abstraction. For this purpose, I will use the very informative <a href=\"http:\/\/blog.james-carr.org\/2011\/02\/12\/cache-abstraction-in-spring-3-1-0-m1\/\">Cache Abstraction in Spring 3.1.0.M1<\/a> post by <a href=\"http:\/\/blog.james-carr.org\/about\/\">James Carr<\/a>, another of our <a href=\"http:\/\/www.javacodegeeks.com\/p\/jcg.html\">JCG partners<\/a>. Make sure to bookmark the <a href=\"http:\/\/static.springsource.org\/spring\/docs\/3.1.0.M1\/javadoc-api\/index.html?org\/springframework\/cache\/package-summary.html\">Spring Cache package Javadocs<\/a> along the way.<\/p>\n<p>(NOTE: The original post has been slightly edited to improve readability)<\/p>\n<p>Another new feature released yesterday came in parallel with me trying out some annotation based caching strategies. <a href=\"http:\/\/static.springsource.org\/spring\/docs\/3.1.0.M1\/spring-framework-reference\/html\/cache.html\">Caching Abstraction<\/a> basically takes convention from an <a href=\"http:\/\/code.google.com\/p\/ehcache-spring-annotations\/\">existing project<\/a> and makes it part of Spring core.<div style=\"display:inline-block; margin: 15px 0;\"> <div id=\"adngin-JavaCodeGeeks_incontent_video-0\" style=\"display:inline-block;\"><\/div> <\/div><\/p>\n<p>Essentially it introduces a new interface, <a href=\"http:\/\/static.springsource.org\/spring\/docs\/3.1.0.M1\/javadoc-api\/org\/springframework\/cache\/CacheManager.html\">CacheManager<\/a>, which can be implemented by a specific cache implementation. From there it adds a few new annotations to make methods cacheable. Here\u2019s an example using my <a href=\"http:\/\/blog.james-carr.org\/2011\/02\/12\/new-for-spring-3-1-0-m1-componentscan\/\">previous posts objects<\/a>.<\/p>\n<pre class=\"brush:java\">package com.jamescarr.example;\r\n\r\nimport java.util.Collection;\r\nimport java.util.Map;\r\nimport java.util.concurrent.ConcurrentHashMap;\r\n\r\nimport javax.annotation.PostConstruct;\r\n\r\nimport org.slf4j.Logger;\r\nimport org.slf4j.LoggerFactory;\r\nimport org.springframework.cache.annotation.CacheEvict;\r\nimport org.springframework.cache.annotation.Cacheable;\r\nimport org.springframework.stereotype.Repository;\r\n\r\n@Repository\r\npublic class MemoryMessageRepository implements MessageRepository {\r\n\r\n    private static final Logger LOG =\r\n           LoggerFactory.getLogger(MemoryMessageRepository.class);\r\n\r\n    private final Map&lt;String, Message&gt; messages = \r\n           new ConcurrentHashMap&lt;String, Message&gt;();\r\n\r\n    @Cacheable(\"message\")\r\n    public Message getMessage(String title){\r\n        LOG.info(\"Fetching message\");\r\n        return messages.get(title);\r\n    }\r\n    @CacheEvict(value=\"message\", key=\"message.title\")\r\n    public void save(Message message){\r\n        LOG.info(\"Saving message\");\r\n        messages.put(message.getTitle(), message);\r\n    }\r\n    public Collection&lt;Message&gt; findAll() {\r\n        return messages.values();\r\n    }\r\n    \r\n    @PostConstruct\r\n    public void addSomeDefaultMessages(){\r\n        save(new Message(\"Hello\", \"Hello World\"));\r\n        save(new Message(\"Appointment\", \"Remember the milk!\"));\r\n    }\r\n    \r\n}\r\n<\/pre>\n<p>Here you\u2019ll notice that the finder method has a <a href=\"http:\/\/static.springsource.org\/spring\/docs\/3.1.0.M1\/javadoc-api\/org\/springframework\/cache\/annotation\/Cacheable.html\">@Cachable<\/a> annotation on it with a name that specifies the cache to store to. It can also use additional attributes, for example a key which uses an expression language to determine a key from the arguments that are passed in. The default is the value of all the method arguments. On the save method I use <a href=\"http:\/\/static.springsource.org\/spring\/docs\/3.1.0.M1\/javadoc-api\/org\/springframework\/cache\/annotation\/CacheEvict.html\">@CacheEvict<\/a> to remove the cached element from the cache if it already exists.<\/p>\n<p>This of course won\u2019t work on it\u2019s own, so you\u2019ll have to enable it yourself (which is good\u2026 the last thing you need is to discover a production app caching things it shouldn\u2019t be caching). Sadly as of the time of this writing I haven\u2019t discovered how to do this in non-xml, so here is the spring xml file to enable it and use ehcache as the implementation.<\/p>\n<pre class=\"brush:xml\">&lt;beans xmlns=\"http:\/\/www.springframework.org\/schema\/beans\"\r\n        xmlns:xsi=\"http:\/\/www.w3.org\/2001\/XMLSchema-instance\"\r\n        xmlns:cache=\"http:\/\/www.springframework.org\/schema\/cache\"\r\n        xmlns:p=\"http:\/\/www.springframework.org\/schema\/p\"\r\n        xsi:schemaLocation=\"http:\/\/www.springframework.org\/schema\/beans http:\/\/www.springframework.org\/schema\/beans\/spring-beans.xsd\r\n                http:\/\/www.springframework.org\/schema\/cache http:\/\/www.springframework.org\/schema\/cache\/spring-cache.xsd\"&gt;\r\n  &lt;cache:annotation-driven \/&gt;\r\n  \r\n        &lt;bean id=\"cacheManager\" class=\"org.springframework.cache.ehcache.EhCacheCacheManager\" p:cache-manager-ref=\"ehcache\"\/&gt;\r\n        &lt;bean id=\"ehcache\" class=\"org.springframework.cache.ehcache.EhCacheManagerFactoryBean\" \r\n                p:config-location=\"classpath:com\/jamescarr\/example\/ehcache.xml\"\/&gt;\r\n &lt;\/beans&gt;\r\n<\/pre>\n<p>The ehcache configuration:<\/p>\n<pre class=\"brush:xml\">&lt;ehcache&gt;\r\n    &lt;diskStore path=\"java.io.tmpdir\"\/&gt;\r\n    &lt;cache name=\"message\"\r\n       maxElementsInMemory=\"100\"\r\n            eternal=\"false\"\r\n            timeToIdleSeconds=\"120\"\r\n            timeToLiveSeconds=\"120\"\r\n            overflowToDisk=\"true\"\r\n            maxElementsOnDisk=\"10000000\"\r\n            diskPersistent=\"false\"\r\n            diskExpiryThreadIntervalSeconds=\"120\"\r\n            memoryStoreEvictionPolicy=\"LRU\"\/&gt;\r\n    \r\n&lt;\/ehcache&gt;\r\n<\/pre>\n<p>And finally adding this to the AppConfiguration, which includes doing a simple <a href=\"http:\/\/static.springsource.org\/spring\/docs\/3.1.0.M1\/javadoc-api\/org\/springframework\/context\/annotation\/ImportResource.html\">@ImportResource<\/a>.<\/p>\n<pre class=\"brush:java\">package com.jamescarr.configuration;\r\nimport javax.annotation.PostConstruct;\r\n\r\nimport org.springframework.beans.factory.annotation.Autowired;\r\nimport org.springframework.context.annotation.AnnotationConfigApplicationContext;\r\nimport org.springframework.context.annotation.ComponentScan;\r\nimport org.springframework.context.annotation.Configuration;\r\nimport org.springframework.context.annotation.ImportResource;\r\n\r\nimport com.jamescarr.example.MessagePrinter;\r\n\r\n@Configuration\r\n@ComponentScan(\"com.jamescarr.example\")\r\n@ImportResource(\"classpath:com\/jamescarr\/example\/cache-context.xml\")\r\npublic class AppConfig {\r\n        @Autowired\r\n        private MessagePrinter messagePrinter;\r\n        @PostConstruct\r\n        public void doSomething(){\r\n                messagePrinter.printMessage(\"Hello\");\r\n                messagePrinter.printMessage(\"Hello\");\r\n                \r\n        }\r\n        public static void main(String[] args) {\r\n                new AnnotationConfigApplicationContext(AppConfig.class);\r\n        }\r\n}\r\n<\/pre>\n<p>When running this example there should be a log message for the first time the method is hit, then it is not seen the second time (since it is being pulled from the cache. This is definitely pretty awesome for implementing <a href=\"http:\/\/en.wikipedia.org\/wiki\/Memoization\">Memoization<\/a> for methods that might just have some CPU intensive computations (but give the exact expected results given a set of of inputs). I\u2019m excited about doing some more work in this area\u2026 I\u2019ve done method level caching before (it\u2019s common) but it is awesome to be able to use it without having to DIY.<\/p>\n<p>That&#8217;s it guys. A straightforward guide to get you started with Spring&#8217;s <a href=\"http:\/\/static.springsource.org\/spring\/docs\/3.1.0.M1\/spring-framework-reference\/html\/cache.html\">Cache Abstraction<\/a> from <a href=\"http:\/\/blog.james-carr.org\/\">James Carr<\/a>. Don&#8217;t forget to share!<\/p>\n<p><strong>Related Articles:<\/strong><\/p>\n<ul style=\"text-align: left\">\n<li><a href=\"http:\/\/www.javacodegeeks.com\/2011\/01\/aspect-oriented-programming-spring-aop.html\">Aspect Oriented Programming with Spring AOP<\/a><\/li>\n<li><a href=\"http:\/\/www.javacodegeeks.com\/2010\/11\/jaxws-with-spring-and-maven-tutorial.html\">JAX\u2013WS with Spring and Maven Tutorial<\/a><\/li>\n<li><a href=\"http:\/\/www.javacodegeeks.com\/2010\/07\/java-mail-spring-gmail-smtp.html\">Sending e-mails in Java with Spring \u2013 GMail SMTP server example<\/a><\/li>\n<li><a href=\"http:\/\/www.javacodegeeks.com\/2010\/07\/aspect-oriented-programming-with-spring.html\">Aspect Oriented Programming with Spring AspectJ and Maven<\/a><\/li>\n<\/ul>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>One of the new features introduced in the forthcoming Spring 3.1 version is the one of cache abstraction. Spring Framework provides support for transparently adding caching into an existing Spring application. Similar to the transaction support, the caching abstraction allows consistent use of various caching solutions with minimal impact on the code. At its core, &hellip;<\/p>\n","protected":false},"author":19,"featured_media":240,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8],"tags":[30,148],"class_list":["post-366","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-enterprise-java","tag-spring","tag-spring-cache"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.5 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Spring 3.1 Cache Abstraction Tutorial - Java Code Geeks<\/title>\n<meta name=\"description\" content=\"One of the new features introduced in the forthcoming Spring 3.1 version is the one of cache abstraction. Spring Framework provides support for\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.javacodegeeks.com\/2011\/02\/spring-31-cache-abstraction-tutorial.html\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Spring 3.1 Cache Abstraction Tutorial - Java Code Geeks\" \/>\n<meta property=\"og:description\" content=\"One of the new features introduced in the forthcoming Spring 3.1 version is the one of cache abstraction. Spring Framework provides support for\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.javacodegeeks.com\/2011\/02\/spring-31-cache-abstraction-tutorial.html\" \/>\n<meta property=\"og:site_name\" content=\"Java Code Geeks\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/javacodegeeks\" \/>\n<meta property=\"article:published_time\" content=\"2011-02-16T00:11:00+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2012-10-24T14:05:24+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/spring-logo.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"150\" \/>\n\t<meta property=\"og:image:height\" content=\"150\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"James Carr\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@javacodegeeks\" \/>\n<meta name=\"twitter:site\" content=\"@javacodegeeks\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"James Carr\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"5 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2011\\\/02\\\/spring-31-cache-abstraction-tutorial.html#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2011\\\/02\\\/spring-31-cache-abstraction-tutorial.html\"},\"author\":{\"name\":\"James Carr\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/person\\\/7558615091dc8194304741268f9a90f9\"},\"headline\":\"Spring 3.1 Cache Abstraction Tutorial\",\"datePublished\":\"2011-02-16T00:11:00+00:00\",\"dateModified\":\"2012-10-24T14:05:24+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2011\\\/02\\\/spring-31-cache-abstraction-tutorial.html\"},\"wordCount\":697,\"commentCount\":2,\"publisher\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2011\\\/02\\\/spring-31-cache-abstraction-tutorial.html#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/spring-logo.jpg\",\"keywords\":[\"Spring\",\"Spring Cache\"],\"articleSection\":[\"Enterprise Java\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.javacodegeeks.com\\\/2011\\\/02\\\/spring-31-cache-abstraction-tutorial.html#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2011\\\/02\\\/spring-31-cache-abstraction-tutorial.html\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2011\\\/02\\\/spring-31-cache-abstraction-tutorial.html\",\"name\":\"Spring 3.1 Cache Abstraction Tutorial - Java Code Geeks\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2011\\\/02\\\/spring-31-cache-abstraction-tutorial.html#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2011\\\/02\\\/spring-31-cache-abstraction-tutorial.html#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/spring-logo.jpg\",\"datePublished\":\"2011-02-16T00:11:00+00:00\",\"dateModified\":\"2012-10-24T14:05:24+00:00\",\"description\":\"One of the new features introduced in the forthcoming Spring 3.1 version is the one of cache abstraction. Spring Framework provides support for\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2011\\\/02\\\/spring-31-cache-abstraction-tutorial.html#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.javacodegeeks.com\\\/2011\\\/02\\\/spring-31-cache-abstraction-tutorial.html\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2011\\\/02\\\/spring-31-cache-abstraction-tutorial.html#primaryimage\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/spring-logo.jpg\",\"contentUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/spring-logo.jpg\",\"width\":150,\"height\":150,\"caption\":\"spring-interview-questions-answers\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2011\\\/02\\\/spring-31-cache-abstraction-tutorial.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.javacodegeeks.com\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Java\",\"item\":\"https:\\\/\\\/www.javacodegeeks.com\\\/category\\\/java\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Enterprise Java\",\"item\":\"https:\\\/\\\/www.javacodegeeks.com\\\/category\\\/java\\\/enterprise-java\"},{\"@type\":\"ListItem\",\"position\":4,\"name\":\"Spring 3.1 Cache Abstraction Tutorial\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#website\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/\",\"name\":\"Java Code Geeks\",\"description\":\"Java Developers Resource Center\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#organization\"},\"alternateName\":\"JCG\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.javacodegeeks.com\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#organization\",\"name\":\"Exelixis Media P.C.\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2022\\\/06\\\/exelixis-logo.png\",\"contentUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2022\\\/06\\\/exelixis-logo.png\",\"width\":864,\"height\":246,\"caption\":\"Exelixis Media P.C.\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/javacodegeeks\",\"https:\\\/\\\/x.com\\\/javacodegeeks\"]},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/person\\\/7558615091dc8194304741268f9a90f9\",\"name\":\"James Carr\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/751c55f22a64fa5ac630c3bddaf1a4f4e11c442aaa9fc308004564cdca64b900?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/751c55f22a64fa5ac630c3bddaf1a4f4e11c442aaa9fc308004564cdca64b900?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/751c55f22a64fa5ac630c3bddaf1a4f4e11c442aaa9fc308004564cdca64b900?s=96&d=mm&r=g\",\"caption\":\"James Carr\"},\"sameAs\":[\"http:\\\/\\\/blog.james-carr.org\\\/\"],\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/author\\\/James-Carr\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Spring 3.1 Cache Abstraction Tutorial - Java Code Geeks","description":"One of the new features introduced in the forthcoming Spring 3.1 version is the one of cache abstraction. Spring Framework provides support for","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.javacodegeeks.com\/2011\/02\/spring-31-cache-abstraction-tutorial.html","og_locale":"en_US","og_type":"article","og_title":"Spring 3.1 Cache Abstraction Tutorial - Java Code Geeks","og_description":"One of the new features introduced in the forthcoming Spring 3.1 version is the one of cache abstraction. Spring Framework provides support for","og_url":"https:\/\/www.javacodegeeks.com\/2011\/02\/spring-31-cache-abstraction-tutorial.html","og_site_name":"Java Code Geeks","article_publisher":"https:\/\/www.facebook.com\/javacodegeeks","article_published_time":"2011-02-16T00:11:00+00:00","article_modified_time":"2012-10-24T14:05:24+00:00","og_image":[{"width":150,"height":150,"url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/spring-logo.jpg","type":"image\/jpeg"}],"author":"James Carr","twitter_card":"summary_large_image","twitter_creator":"@javacodegeeks","twitter_site":"@javacodegeeks","twitter_misc":{"Written by":"James Carr","Est. reading time":"5 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.javacodegeeks.com\/2011\/02\/spring-31-cache-abstraction-tutorial.html#article","isPartOf":{"@id":"https:\/\/www.javacodegeeks.com\/2011\/02\/spring-31-cache-abstraction-tutorial.html"},"author":{"name":"James Carr","@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/person\/7558615091dc8194304741268f9a90f9"},"headline":"Spring 3.1 Cache Abstraction Tutorial","datePublished":"2011-02-16T00:11:00+00:00","dateModified":"2012-10-24T14:05:24+00:00","mainEntityOfPage":{"@id":"https:\/\/www.javacodegeeks.com\/2011\/02\/spring-31-cache-abstraction-tutorial.html"},"wordCount":697,"commentCount":2,"publisher":{"@id":"https:\/\/www.javacodegeeks.com\/#organization"},"image":{"@id":"https:\/\/www.javacodegeeks.com\/2011\/02\/spring-31-cache-abstraction-tutorial.html#primaryimage"},"thumbnailUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/spring-logo.jpg","keywords":["Spring","Spring Cache"],"articleSection":["Enterprise Java"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.javacodegeeks.com\/2011\/02\/spring-31-cache-abstraction-tutorial.html#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.javacodegeeks.com\/2011\/02\/spring-31-cache-abstraction-tutorial.html","url":"https:\/\/www.javacodegeeks.com\/2011\/02\/spring-31-cache-abstraction-tutorial.html","name":"Spring 3.1 Cache Abstraction Tutorial - Java Code Geeks","isPartOf":{"@id":"https:\/\/www.javacodegeeks.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.javacodegeeks.com\/2011\/02\/spring-31-cache-abstraction-tutorial.html#primaryimage"},"image":{"@id":"https:\/\/www.javacodegeeks.com\/2011\/02\/spring-31-cache-abstraction-tutorial.html#primaryimage"},"thumbnailUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/spring-logo.jpg","datePublished":"2011-02-16T00:11:00+00:00","dateModified":"2012-10-24T14:05:24+00:00","description":"One of the new features introduced in the forthcoming Spring 3.1 version is the one of cache abstraction. Spring Framework provides support for","breadcrumb":{"@id":"https:\/\/www.javacodegeeks.com\/2011\/02\/spring-31-cache-abstraction-tutorial.html#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.javacodegeeks.com\/2011\/02\/spring-31-cache-abstraction-tutorial.html"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.javacodegeeks.com\/2011\/02\/spring-31-cache-abstraction-tutorial.html#primaryimage","url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/spring-logo.jpg","contentUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/spring-logo.jpg","width":150,"height":150,"caption":"spring-interview-questions-answers"},{"@type":"BreadcrumbList","@id":"https:\/\/www.javacodegeeks.com\/2011\/02\/spring-31-cache-abstraction-tutorial.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.javacodegeeks.com\/"},{"@type":"ListItem","position":2,"name":"Java","item":"https:\/\/www.javacodegeeks.com\/category\/java"},{"@type":"ListItem","position":3,"name":"Enterprise Java","item":"https:\/\/www.javacodegeeks.com\/category\/java\/enterprise-java"},{"@type":"ListItem","position":4,"name":"Spring 3.1 Cache Abstraction Tutorial"}]},{"@type":"WebSite","@id":"https:\/\/www.javacodegeeks.com\/#website","url":"https:\/\/www.javacodegeeks.com\/","name":"Java Code Geeks","description":"Java Developers Resource Center","publisher":{"@id":"https:\/\/www.javacodegeeks.com\/#organization"},"alternateName":"JCG","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.javacodegeeks.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.javacodegeeks.com\/#organization","name":"Exelixis Media P.C.","url":"https:\/\/www.javacodegeeks.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/logo\/image\/","url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","contentUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","width":864,"height":246,"caption":"Exelixis Media P.C."},"image":{"@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/javacodegeeks","https:\/\/x.com\/javacodegeeks"]},{"@type":"Person","@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/person\/7558615091dc8194304741268f9a90f9","name":"James Carr","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/751c55f22a64fa5ac630c3bddaf1a4f4e11c442aaa9fc308004564cdca64b900?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/751c55f22a64fa5ac630c3bddaf1a4f4e11c442aaa9fc308004564cdca64b900?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/751c55f22a64fa5ac630c3bddaf1a4f4e11c442aaa9fc308004564cdca64b900?s=96&d=mm&r=g","caption":"James Carr"},"sameAs":["http:\/\/blog.james-carr.org\/"],"url":"https:\/\/www.javacodegeeks.com\/author\/James-Carr"}]}},"_links":{"self":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/366","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/users\/19"}],"replies":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/comments?post=366"}],"version-history":[{"count":0,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/366\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/media\/240"}],"wp:attachment":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/media?parent=366"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/categories?post=366"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/tags?post=366"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}