Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Turn on caching for homepage and user.

  • Loading branch information...
commit da776a16ce6ac17eb65d66cb8a206b18a44a6536 1 parent ea911b6
@mraible mraible authored
View
1  grails-app/conf/BuildConfig.groovy
@@ -46,6 +46,7 @@ grails.project.dependency.resolution = {
}
plugins {
+ compile ":cache:1.0.1"
compile ":cache-headers:1.1.5"
compile ":cloud-bees:0.6.2"
compile ":commentable:0.8.1"
View
9 grails-app/conf/Config.groovy
@@ -143,3 +143,12 @@ grails.commentable.poster.evaluator = {
cloudbees.account = 'happytrails'
cloudbees.api.key = '3160AB4C28E2FC90'
cloudbees.api.secret = 'SHSLTMEQEQXKN8RI0IHOTUZVAMUPKGQFBMKGJT9YT7G='
+
+grails.cache.config = {
+ cache {
+ name 'home'
+ }
+ cache {
+ name 'user'
+ }
+}
View
2  grails-app/conf/DataSource.groovy
@@ -6,7 +6,7 @@ dataSource {
}
hibernate {
cache.use_second_level_cache = true
- cache.use_query_cache = false
+ cache.use_query_cache = true
cache.region.factory_class = 'net.sf.ehcache.hibernate.EhCacheRegionFactory'
}
// environment specific settings
View
2  grails-app/controllers/happytrails/HomeController.groovy
@@ -1,9 +1,11 @@
package happytrails
import org.grails.comments.Comment
+import grails.plugin.cache.Cacheable
class HomeController {
+ @Cacheable("home")
def index() {
params.max = Math.min(params.max ? params.int('max') : 10, 100)
[regions: Region.list(params), total: Region.count(),
View
2  grails-app/services/happytrails/UserDetailsService.groovy
@@ -3,6 +3,7 @@ package happytrails
import groovy.transform.CompileStatic
import org.codehaus.groovy.grails.plugins.springsecurity.GrailsUserDetailsService
import org.codehaus.groovy.grails.plugins.springsecurity.SpringSecurityUtils
+import grails.plugin.cache.Cacheable
import org.springframework.security.core.GrantedAuthority
import org.springframework.security.core.authority.GrantedAuthorityImpl
import org.springframework.security.core.userdetails.UserDetails
@@ -23,6 +24,7 @@ class UserDetailsService implements GrailsUserDetailsService {
return loadUserByUsername(username)
}
+ @Cacheable("user")
UserDetails loadUserByUsername(String _username) throws UsernameNotFoundException {
UserDetails userDetails = null
Please sign in to comment.
Something went wrong with that request. Please try again.