PERF: use distributed cache for site text and category slugs

This commit is contained in:
Sam
2014-11-12 09:44:32 +11:00
parent c55fa9d5c8
commit a97f2eee05
5 changed files with 43 additions and 61 deletions

View File

@@ -1,18 +1,16 @@
require_dependency 'site_text_type'
require_dependency 'site_text_class_methods'
require_dependency 'distributed_cache'
class SiteText < ActiveRecord::Base
# needed for site text class methods
@mutex = Mutex.new
@text_for_cache = {}
extend SiteTextClassMethods
self.primary_key = 'text_type'
validates_presence_of :value
after_save do
MessageBus.publish '/text_for', self.text_type
SiteText.text_for_cache.clear
end
def self.formats