cache improvements

This commit is contained in:
albert
2013-01-06 16:56:30 -05:00
parent 0481ee73f9
commit b1701b2bca

View File

@@ -621,18 +621,21 @@ class Post < ActiveRecord::Base
count = get_count_from_cache(tags) count = get_count_from_cache(tags)
if count.nil? if count.nil?
if tags.blank? if tags.blank?
set_count_in_cache("", 1_000_000, rand(24) * 1.hour) count = 1_000_000
else else
count = Post.tag_match(tags).undeleted.count begin
if count > Danbooru.config.posts_per_page * 10 count = Post.tag_match(tags).undeleted.count
set_count_in_cache(tags, count) rescue ActiveRecord::StatementInvalid
count = 1_000_000
end end
end end
if count > Danbooru.config.posts_per_page * 10
set_count_in_cache(tags, count)
end
end end
count count
rescue ActiveRecord::StatementInvalid
set_count_in_cache(tags, 1_000_000, rand(24) * 1.hour)
1_000_000
rescue SearchError rescue SearchError
0 0
end end