Moved to rails cache.
This commit is contained in:
parent
1b3066a8b7
commit
5b988d073c
4 changed files with 26 additions and 14 deletions
|
@ -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'
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
7
config/initializers/cache.rb
Normal file
7
config/initializers/cache.rb
Normal file
|
@ -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
|
Loading…
Reference in a new issue