diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index a398c12ef..228150b47 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -148,21 +148,21 @@ class ApplicationController < ActionController::Base user['links'] = [] # TEMP: compat. reasons - user[:preferences] = {} if !user[:preferences] + user['preferences'] = {} if user['preferences'] == nil topic = { :title => 'Tickets', :items => [ { :url => '', - :name => 'open (' + user[:preferences][:tickets_open].to_s + ')', + :name => 'open (' + user['preferences'][:tickets_open].to_s + ')', :title => 'Open Tickets', :class => 'user-tickets', :data => 'open' }, { :url => '', - :name => 'closed (' + user[:preferences][:tickets_closed].to_s + ')', + :name => 'closed (' + user['preferences'][:tickets_closed].to_s + ')', :title => 'Closed Tickets', :class => 'user-tickets', :data => 'closed' diff --git a/app/models/application_model.rb b/app/models/application_model.rb index 265607ed1..89a166874 100644 --- a/app/models/application_model.rb +++ b/app/models/application_model.rb @@ -1,8 +1,6 @@ class ApplicationModel < ActiveRecord::Base self.abstract_class = true - @@cache = {} - def cache_update(o) # puts 'u ' + self.class.to_s if self.respond_to?('cache_delete') then self.cache_delete end @@ -11,21 +9,24 @@ class ApplicationModel < ActiveRecord::Base end def cache_delete # puts 'cache_delete', self.inspect -# puts 'cache_delete', self.id - @@cache[self.to_s] = {} if !@@cache[self.to_s] - @@cache[self.to_s][self.id] = nil + puts 'cache_delete', self.id + key = self.class.to_s + '::' + self.id.to_s + puts key + Rails.cache.delete( key.to_s ) end def self.cache_set(data_id, data) # puts 'cache_set', self.inspect # puts 'cache_set', self.to_s -# puts 'cache_set', data_id - @@cache[self.to_s] = {} if !@@cache[self.to_s] - @@cache[self.to_s][data_id] = data + puts 'cache_set', data_id + key = self.to_s + '::' + data_id.to_s + puts key + Rails.cache.write( key.to_s, data) +# @@cache[self.to_s][data_id] = data end def self.cache_get(data_id) -# puts 'cache_get', data_id + puts 'cache_get', data_id # puts 'cache_get', self.inspect - @@cache[self.to_s] = {} if !@@cache[self.to_s] - return @@cache[self.to_s][data_id] if @@cache[self.to_s] + key = self.to_s + '::' + data_id.to_s + Rails.cache.read( key.to_s ) end end diff --git a/config/application.rb b/config/application.rb index 0abdbc09b..5797669c4 100644 --- a/config/application.rb +++ b/config/application.rb @@ -61,5 +61,9 @@ module Zammad # Version of your assets, change this if you want to expire all your assets config.assets.version = '1.0' + + + # Use a different cache store in production + config.cache_store = :file_store, 'tmp/cache/file_store' end end diff --git a/config/initializers/cache.rb b/config/initializers/cache.rb new file mode 100644 index 000000000..6f5dd270b --- /dev/null +++ b/config/initializers/cache.rb @@ -0,0 +1,7 @@ +# clear cache +Rails.cache.clear + +# to get rails caching working, load models +Dir.foreach("#{Rails.root}/app/models") do |model_name| + require_dependency model_name unless model_name == '.' || model_name == '..' || model_name == '.gitkeep' +end \ No newline at end of file