{"action":"created","issue":{"url":"https://api.github.com/repos/spring-projects/spring-boot/issues/2700","labels_url":"https://api.github.com/repos/spring-projects/spring-boot/issues/2700/labels{/name}","comments_url":"https://api.github.com/repos/spring-projects/spring-boot/issues/2700/comments","events_url":"https://api.github.com/repos/spring-projects/spring-boot/issues/2700/events","html_url":"https://github.com/spring-projects/spring-boot/pull/2700","id":63744680,"number":2700,"title":"Cache Auto-configuration","user":{"login":"snicoll","id":490484,"avatar_url":"https://avatars.githubusercontent.com/u/490484?v=3","gravatar_id":"","url":"https://api.github.com/users/snicoll","html_url":"https://github.com/snicoll","followers_url":"https://api.github.com/users/snicoll/followers","following_url":"https://api.github.com/users/snicoll/following{/other_user}","gists_url":"https://api.github.com/users/snicoll/gists{/gist_id}","starred_url":"https://api.github.com/users/snicoll/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/snicoll/subscriptions","organizations_url":"https://api.github.com/users/snicoll/orgs","repos_url":"https://api.github.com/users/snicoll/repos","events_url":"https://api.github.com/users/snicoll/events{/privacy}","received_events_url":"https://api.github.com/users/snicoll/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/spring-projects/spring-boot/labels/in%20progress","name":"in progress","color":"eac04b"}],"state":"open","locked":false,"assignee":null,"milestone":{"url":"https://api.github.com/repos/spring-projects/spring-boot/milestones/28","html_url":"https://github.com/spring-projects/spring-boot/milestones/1.3.0","labels_url":"https://api.github.com/repos/spring-projects/spring-boot/milestones/28/labels","id":818466,"number":28,"title":"1.3.0","description":"","creator":{"login":"philwebb","id":519772,"avatar_url":"https://avatars.githubusercontent.com/u/519772?v=3","gravatar_id":"","url":"https://api.github.com/users/philwebb","html_url":"https://github.com/philwebb","followers_url":"https://api.github.com/users/philwebb/followers","following_url":"https://api.github.com/users/philwebb/following{/other_user}","gists_url":"https://api.github.com/users/philwebb/gists{/gist_id}","starred_url":"https://api.github.com/users/philwebb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/philwebb/subscriptions","organizations_url":"https://api.github.com/users/philwebb/orgs","repos_url":"https://api.github.com/users/philwebb/repos","events_url":"https://api.github.com/users/philwebb/events{/privacy}","received_events_url":"https://api.github.com/users/philwebb/received_events","type":"User","site_admin":false},"open_issues":145,"closed_issues":20,"state":"open","created_at":"2014-10-08T15:00:46Z","updated_at":"2015-03-23T23:17:08Z","due_on":null,"closed_at":null},"comments":4,"created_at":"2015-03-23T15:01:13Z","updated_at":"2015-03-24T08:14:05Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/spring-projects/spring-boot/pulls/2700","html_url":"https://github.com/spring-projects/spring-boot/pull/2700","diff_url":"https://github.com/spring-projects/spring-boot/pull/2700.diff","patch_url":"https://github.com/spring-projects/spring-boot/pull/2700.patch"},"body":"Here's the initial support for cache auto-configuration aimed at Spring Boot 1.3 (#2633). This is a joint effort with @eddumelendez\r\n\r\nThe following cache libraries are supported:\r\n* Generic (via the presence of `org.springframework.cache.Cache` instances  in the context)\r\n* EhCache\r\n* Hazelcast\r\n* JSR-107 compliant provider\r\n* Redis\r\n* Guava\r\n* Simple (i.e. concurrent Map)\r\n* NoOp \r\n\r\nBy default, the environment is checked to determine which cache libraries should be used. In the case of ehcache and hazelcast, we check if the library is present of course but also if either a default configuration file is present (`/ehcache.xml`, `/hazelcast.xml`) or if a custom location has been set (via the common `spring.cache.config` property).\r\n\r\nThe `spring.cache.mode` allows to specify the caching library to use in case of conflict. It should be noted that only `noop` should be set explicitly. Maybe `redis` should be in that situation as well (right now the presence of a `RedisTemplate` enable a cache on redis, not sure this is appropriate).\r\n\r\n`spring.cache.cache-names` defines the comma-separated list of caches to create on startup. \r\n\r\nWe need to add several samples to showcase how this works (and validate that the conditions work has they should with different classpath content). \r\n\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/spring-projects/spring-boot/issues/comments/85391615","html_url":"https://github.com/spring-projects/spring-boot/pull/2700#issuecomment-85391615","issue_url":"https://api.github.com/repos/spring-projects/spring-boot/issues/2700","id":85391615,"user":{"login":"snicoll","id":490484,"avatar_url":"https://avatars.githubusercontent.com/u/490484?v=3","gravatar_id":"","url":"https://api.github.com/users/snicoll","html_url":"https://github.com/snicoll","followers_url":"https://api.github.com/users/snicoll/followers","following_url":"https://api.github.com/users/snicoll/following{/other_user}","gists_url":"https://api.github.com/users/snicoll/gists{/gist_id}","starred_url":"https://api.github.com/users/snicoll/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/snicoll/subscriptions","organizations_url":"https://api.github.com/users/snicoll/orgs","repos_url":"https://api.github.com/users/snicoll/repos","events_url":"https://api.github.com/users/snicoll/events{/privacy}","received_events_url":"https://api.github.com/users/snicoll/received_events","type":"User","site_admin":false},"created_at":"2015-03-24T08:14:05Z","updated_at":"2015-03-24T08:14:05Z","body":"Thanks for the review, I added a few comments on your commits. \r\n\r\nGood catch for `CachingConfigurer`, I should know better! I had a look (your new condition should be named `ConditionalOnMissingCacheConfiguration` IMO) and I tried to implement the condition. The easiest would be to inject the `CacheAspectSupport` and check if `getCacheResolver()` returns `true`. I tried that but then I ended up with early initialization problems. A much less nicer option would be to check if a `CachingConfigurer` bean exists and then look at the outcome of `cacheManager()` and `cacheResolver` but that's duplicating a bit of the logic. I could consider adding a boolean flag on that class to indicate if a \"cache configuration is set\" (no idea how to call that getter).\r\n\r\nMode was an enum initially and then I change it to a simple String. Here's why:\r\n\r\n1. We have a precedent with `shell.auth` (I am not saying it's a good one).\r\n2. We can expect IDE to catch up and offer auto-completion for such values (when we finally work on the domain thing in the meta-data). Right now the value is auto-completed in upper case which is less nicer and a reason why I don't like using them too much. \r\n\r\nI am ok if we go with an enum though.\r\n\r\n`CacheValidationConfiguration` is a weird beast. I added that at the very end because without it, the check in `@EnableCaching` barfs at you without giving any insight of what could have been gone wrong. I like this idea of having a \"last ressort check\" that throws a dedicated exception. I don't like how it's implemented though.\r\n\r\nThe if/else logic in `GuavaCacheConfiguration.createCacheManager()` can be refactored in a method named `setCacheBuilder` because this is really what it is about: `CacheBuilder`, `CacheBuilderSpec` and the specification string are 3 ways of initializing a `CacheBuilder`\r\n"}}