Skip to content

Commit

Permalink
Fix download page caching.
Browse files Browse the repository at this point in the history
When the admin user modified the displayed Grails versions, he or she had to wait up to 5 mins to see whether the change was successful or not because the page remained cached. Now, changing the display versions results in the cache being cleared.
  • Loading branch information
pledbrook committed May 18, 2012
1 parent ad000ad commit a1739a2
Showing 1 changed file with 16 additions and 14 deletions.
Expand Up @@ -2,16 +2,16 @@ package org.grails.downloads

import grails.converters.JSON
import grails.converters.XML
import grails.plugin.springcache.annotations.*
import grails.plugin.cache.Cacheable
import grails.plugin.cache.CacheEvict
import grails.validation.Validateable
import net.sf.ehcache.Element
import net.sf.ehcache.Ehcache
import org.hibernate.FetchMode

class DownloadController {
def grailsApplication
def downloadCache

def grailsCacheAdminService

def index() { redirect action: "list", params: params }

def latest() {
Expand Down Expand Up @@ -197,12 +197,12 @@ class DownloadController {
}
}

def list = {
def list() {
if (!params.max) params.max = 10
[ downloadList: Download.list( params ) ]
}

def show = {
def show() {
def download = Download.get( params.id )

if(!download) {
Expand All @@ -212,7 +212,7 @@ class DownloadController {
else { return [ download : download ] }
}

def delete = {
def delete() {
def download = Download.get( params.id )
if(download) {
download.delete()
Expand All @@ -225,7 +225,7 @@ class DownloadController {
}
}

def edit = {
def edit() {
def download = Download.get( params.id )

if(!download) {
Expand All @@ -237,7 +237,7 @@ class DownloadController {
}
}

def update = {
def update() {
def download = Download.get( params.id )
if(download) {
download.properties = params
Expand All @@ -255,12 +255,12 @@ class DownloadController {
}
}

def create = {
def create() {
def download = new Download(params)
return ['download':download]
}

def save = {
def save() {
def download = new Download(params)
if(!download.hasErrors() && download.save()) {
flash.message = "Download ${download.id} created"
Expand All @@ -271,15 +271,15 @@ class DownloadController {
}
}

def adminShowVersionOrder = {
def adminShowVersionOrder() {
render template: "showDisplayedVersions", model: [versions: versionOrder]
}

def adminEditVersionOrder = {
def adminEditVersionOrder() {
render template: "editDisplayedVersions", model: [versions: versionOrder]
}

def adminUpdateVersionOrder = {
def adminUpdateVersionOrder() {
def hasError = false
def versions = params.versions?.split(/\s*,\s*/)

Expand All @@ -294,6 +294,8 @@ class DownloadController {
}
}

grailsCacheAdminService.clearBlocksCache()

render template: "showDisplayedVersions", model: [versions: versionOrder, hasError: hasError]
}

Expand Down

0 comments on commit a1739a2

Please sign in to comment.