From 489f62edb7992a5207a26da2cb7086cd0f4b1658 Mon Sep 17 00:00:00 2001 From: guange <8863824@gmail.com> Date: Fri, 19 Jun 2015 14:49:18 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E5=88=A0=E9=99=A4=E5=B8=96=E5=AD=90?= =?UTF-8?q?=E4=B9=9F=E8=A6=81=E6=9B=B4=E6=96=B0=E5=8A=A8=E6=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/trustie/cache/clear_course_event.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/trustie/cache/clear_course_event.rb b/lib/trustie/cache/clear_course_event.rb index a5f44bf45..cc643020d 100644 --- a/lib/trustie/cache/clear_course_event.rb +++ b/lib/trustie/cache/clear_course_event.rb @@ -6,6 +6,7 @@ module Trustie def self.included(base) base.class_eval{ after_create :clear_course_events + after_destroy :clear_course_events } end From e1cf19baacb1047c116f8d3cd9e11bc2825b8957 Mon Sep 17 00:00:00 2001 From: guange <8863824@gmail.com> Date: Fri, 19 Jun 2015 14:51:39 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E6=89=93=E5=BC=80=E8=AF=BE=E7=A8=8B?= =?UTF-8?q?=E7=BC=93=E5=AD=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/courses_controller.rb | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb index 210ac8f3d..3b25438df 100644 --- a/app/controllers/courses_controller.rb +++ b/app/controllers/courses_controller.rb @@ -695,13 +695,11 @@ class CoursesController < ApplicationController # 显示老师和助教的活动 # @authors = searchTeacherAndAssistant(@course) @authors = course_all_member(@course) - #TODO 貌似删除操作不会更新缓存 还是先不用缓存吧 - # Dir.glob("#{Rails.root}/app/models/*.rb").sort.each { |file| require file } events = [] - # key = "course_events_#{@course.id}".to_sym - # if Rails.env.production? && Setting.course_cahce_enabled? - # events = Rails.cache.read(key) || [] - # end + key = "course_events_#{@course.id}".to_sym + if Rails.env.production? && Setting.course_cahce_enabled? + events = Rails.cache.read(key) || [] + end if events.empty? @authors.each do |author| @activity = Redmine::Activity::Fetcher.new(User.current, :course => @course, @@ -717,7 +715,7 @@ class CoursesController < ApplicationController events += @activity.events(@days, @course.created_at, :is_public => 1) end end - # Rails.cache.write(key, events) if Rails.env.production? && Setting.course_cahce_enabled? + Rails.cache.write(key, events) if Rails.env.production? && Setting.course_cahce_enabled? end else # @author = @course.teacher