{"id":8614,"date":"2012-09-25T20:13:49","date_gmt":"2012-09-25T14:43:49","guid":{"rendered":"http:\/\/www.tothenew.com\/blog\/?p=8614"},"modified":"2012-09-25T20:13:49","modified_gmt":"2012-09-25T14:43:49","slug":"attributes-of-spring-cache","status":"publish","type":"post","link":"https:\/\/www.tothenew.com\/blog\/attributes-of-spring-cache\/","title":{"rendered":"Attributes of Spring Cache"},"content":{"rendered":"<p>In my previous blog, i have mentioned how to integrate spring cache plugin in grails. In this blog we will see how we can use different attributes of cache.<\/p>\n<p style=\"padding-bottom: 10px\">\n<p>Different attributes of cache :-<\/p>\n<ol>\n<li>maxElementsInMemory- How many elements you can store in cache<\/li>\n<li>overflowToDisk-The attribute overflowToDisk is true, meaning that whenever the maximum number of in-memory objects is reached, objects are swapped to disk<\/li>\n<li>diskPersistent &#8211; if diskPersistent is false, it means when application server is restarted, in-memory cache is lost.<\/li>\n<li>ttl(time to live seconds)- It denotes for how many seconds element will remain in cache?<\/li>\n<li>memoryStoreEvictionPolicy &#8211; It is used to evict element from in-memory when the maximum number of in-memory objects is reached . Different type of eviction policy:<\/li>\n<p>a) LRU (Least Recently Used):  Oldest element will be evicted.<br \/>\nb) LFU (Least Frequently Used):  Element with least hits will be evicted.<\/ol>\n<p style=\"padding-bottom: 10px\">\n<p>In grails, you can implement different cache attributes like this way.<\/p>\n<p>[groovy]<br \/>\nstudentCache(EhCacheFactoryBean) { bean -&gt;<br \/>\ncacheManager = ref(&quot;springcacheCacheManager&quot;)<br \/>\ncacheName = &quot;studentCache&quot;<br \/>\neternal = false<br \/>\ndiskPersistent = false<br \/>\nmemoryStoreEvictionPolicy = &quot;LRU&quot;<br \/>\nttl = 3000<br \/>\n}<br \/>\n[\/groovy]<\/p>\n<p style=\"padding-bottom: 10px\">\n<p>Hope this code will help  you \ud83d\ude42<\/p>\n<p style=\"padding-bottom: 10px\">\n<p>To know more about Cache, you can take the reference by using below link.<br \/>\n<a href=\"http:\/\/grails.org\/plugin\/springcache\" target=\"_blank\">http:\/\/grails.org\/plugin\/springcache<\/a><br \/>\n<a href=\"http:\/\/www.tothenew.com\/blog\/how-to-integrate-spring-cache-plugin-with-grails\/\" target=\"_blank\">http:\/\/www.tothenew.com\/blog\/how-to-integrate-spring-cache-plugin-with-grails\/<\/a><\/p>\n<p style=\"padding-bottom: 10px\">\n","protected":false},"excerpt":{"rendered":"<p>In my previous blog, i have mentioned how to integrate spring cache plugin in grails. In this blog we will see how we can use different attributes of cache. Different attributes of cache :- maxElementsInMemory- How many elements you can store in cache overflowToDisk-The attribute overflowToDisk is true, meaning that whenever the maximum number of [&hellip;]<\/p>\n","protected":false},"author":47,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"iawp_total_views":0},"categories":[7],"tags":[350,1072,4840,4841],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/8614"}],"collection":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/users\/47"}],"replies":[{"embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/comments?post=8614"}],"version-history":[{"count":0,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/8614\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/media?parent=8614"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/categories?post=8614"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/tags?post=8614"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}