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)
if count.nil?
if tags.blank?
set_count_in_cache("", 1_000_000, rand(24) * 1.hour)
count = 1_000_000
else
count = Post.tag_match(tags).undeleted.count
if count > Danbooru.config.posts_per_page * 10
set_count_in_cache(tags, count)
begin
count = Post.tag_match(tags).undeleted.count
rescue ActiveRecord::StatementInvalid
count = 1_000_000
end
end
if count > Danbooru.config.posts_per_page * 10
set_count_in_cache(tags, count)
end
end
count
rescue ActiveRecord::StatementInvalid
set_count_in_cache(tags, 1_000_000, rand(24) * 1.hour)
1_000_000
rescue SearchError
0
end