trabajo-afectivo/app/models/application_model.rb

26 lines
740 B
Ruby
Raw Normal View History

2012-04-16 08:04:49 +00:00
class ApplicationModel < ActiveRecord::Base
self.abstract_class = true
def cache_update(o)
# puts 'u ' + self.class.to_s
if self.respond_to?('cache_delete') then self.cache_delete end
# puts 'g ' + group.class.to_s
if o.respond_to?('cache_delete') then o.cache_delete end
end
def cache_delete
2012-04-18 13:13:09 +00:00
# puts 'cache_delete', self.id
2012-04-16 09:45:02 +00:00
key = self.class.to_s + '::' + self.id.to_s
Rails.cache.delete( key.to_s )
2012-04-16 08:04:49 +00:00
end
def self.cache_set(data_id, data)
2012-04-18 13:13:09 +00:00
# puts 'cache_set', data_id
2012-04-16 09:45:02 +00:00
key = self.to_s + '::' + data_id.to_s
2012-05-06 20:47:06 +00:00
Rails.cache.write( key.to_s, data )
2012-04-16 08:04:49 +00:00
end
def self.cache_get(data_id)
2012-04-18 13:13:09 +00:00
# puts 'cache_get', data_id
2012-04-16 09:45:02 +00:00
key = self.to_s + '::' + data_id.to_s
Rails.cache.read( key.to_s )
2012-04-16 08:04:49 +00:00
end
end