introduce rack:cache as a default, so users don't need to configure apache or nginx

under rack cache we are able to serve 620reqs a second per thin (on my machine) before it 12 (on my machine)

reorganised so mini profilers can be cleanly disabled from config file

added caching for categories index

move production.rb to production.sample.rb
This commit is contained in:
Sam
2013-04-11 16:24:08 +10:00
parent edd25e01a8
commit 850b042cab
16 changed files with 100 additions and 64 deletions

View File

@ -11,7 +11,12 @@ class DiscourseRedis
end
def self.config
YAML.load(ERB.new(File.new("#{Rails.root}/config/redis.yml").read).result)[Rails.env]
@config ||= YAML.load(ERB.new(File.new("#{Rails.root}/config/redis.yml").read).result)[Rails.env]
end
def self.url(config=nil)
config ||= self.config
"redis://#{(':' + config['password'] + '@') if config['password']}#{config['host']}:#{config['port']}/#{config['db']}"
end
def initialize
@ -19,6 +24,10 @@ class DiscourseRedis
@redis = DiscourseRedis.raw_connection(@config)
end
def url
self.class.url(@config)
end
# prefix the key with the namespace
def method_missing(meth, *args, &block)
if @redis.respond_to?(meth)
@ -52,8 +61,5 @@ class DiscourseRedis
redis_store
end
def url
"redis://#{(':' + @config['password'] + '@') if @config['password']}#{@config['host']}:#{@config['port']}/#{@config['db']}"
end
end