From d25309a0785cea3cedf51982d4e53f242eb7afee Mon Sep 17 00:00:00 2001 From: Philip Hofstetter Date: Wed, 28 May 2008 22:49:13 +0200 Subject: [PATCH] remove settings cache (which only worked per request anyways) --- app/controllers/application.rb | 2 -- app/models/setting.rb | 19 +------------------ 2 files changed, 1 insertions(+), 20 deletions(-) diff --git a/app/controllers/application.rb b/app/controllers/application.rb index abf6216..cc73c1c 100644 --- a/app/controllers/application.rb +++ b/app/controllers/application.rb @@ -31,8 +31,6 @@ class ApplicationController < ActionController::Base end def user_setup - # Check the settings cache for each request - Setting.check_cache # Find the current user User.current = find_current_user end diff --git a/app/models/setting.rb b/app/models/setting.rb index 5a98de0..24720b0 100644 --- a/app/models/setting.rb +++ b/app/models/setting.rb @@ -50,10 +50,6 @@ class Setting < ActiveRecord::Base validates_inclusion_of :name, :in => @@available_settings.keys validates_numericality_of :value, :only_integer => true, :if => Proc.new { |setting| @@available_settings[setting.name]['format'] == 'int' } - # Hash used to cache setting values - @cached_settings = {} - @cached_cleared_on = Time.now - def value v = read_attribute(:value) # Unserialize serialized settings @@ -69,14 +65,12 @@ class Setting < ActiveRecord::Base # Returns the value of the setting named name def self.[](name) - v = @cached_settings[name] - v ? v : (@cached_settings[name] = find_or_default(name).value) + find_or_default(name).value end def self.[]=(name, v) setting = find_or_default(name) setting.value = (v ? v : "") - @cached_settings[name] = nil setting.save setting.value end @@ -106,17 +100,6 @@ class Setting < ActiveRecord::Base per_page_options.split(%r{[\s,]}).collect(&:to_i).select {|n| n > 0}.sort end - # Checks if settings have changed since the values were read - # and clears the cache hash if it's the case - # Called once per request - def self.check_cache - settings_updated_on = Setting.maximum(:updated_on) - if settings_updated_on && @cached_cleared_on <= settings_updated_on - @cached_settings.clear - @cached_cleared_on = Time.now - logger.info "Settings cache cleared." if logger - end - end private # Returns the Setting instance for the setting named name -- 1.5.5.1