expire name cache after 1 hour

This commit is contained in:
albert
2011-12-22 12:47:13 -05:00
parent 7aca7f3e2f
commit 5d71f005b0
3 changed files with 5 additions and 3 deletions

View File

@@ -1069,7 +1069,7 @@ class Post < ActiveRecord::Base
"md5" => md5,
"has_notes" => last_noted_at.present?,
"rating" => rating,
"author" => uploader.name,
"author" => uploader_name,
"creator_id" => uploader_id,
"width" => image_width,
"source" => source,

View File

@@ -79,7 +79,7 @@ class User < ActiveRecord::Base
end
def id_to_name(user_id)
Cache.get("uin:#{user_id}") do
Cache.get("uin:#{user_id}", 1.hour) do
select_value_sql("SELECT name FROM users WHERE id = ?", user_id) || Danbooru.config.default_guest_name
end
end
@@ -107,6 +107,8 @@ class User < ActiveRecord::Base
Net::HTTP.delete(URI.parse("http://#{server}/users/#{id}/cache"))
end
end
rescue Exception
# swallow, since it'll be expired eventually anyway
end
def validate_feedback_on_name_change

View File

@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<posts>
<% @posts.each do |post| %>
<post preview_url="<%= post.preview_file_url %>" file_size="<%= post.file_size %>" status="<%= post.status %>" score="<%= post.score %>" file_url="<%= post.file_url %>" height="<%= post.image_height %>" has_comments="<%= post.last_commented_at.present? %>" tags="<%= post.tag_string %>" source="<%= post.source %>" parent_id="<%= post.parent_id %>" created_at="<%= post.created_at.to_formatted_s(:db) %>" rating="<%= post.rating %>" has_notes="<%= post.last_noted_at.present? %>" id="<%= post.id %>" md5="<%= post.md5 %>" has_children="<%= post.has_children? %>" creator_id="<%= post.uploader_id %>" author="<%= post.uploader.name %>" width="<%= post.image_width %>"/>
<post preview_url="<%= post.preview_file_url %>" file_size="<%= post.file_size %>" status="<%= post.status %>" score="<%= post.score %>" file_url="<%= post.file_url %>" height="<%= post.image_height %>" has_comments="<%= post.last_commented_at.present? %>" tags="<%= post.tag_string %>" source="<%= post.source %>" parent_id="<%= post.parent_id %>" created_at="<%= post.created_at.to_formatted_s(:db) %>" rating="<%= post.rating %>" has_notes="<%= post.last_noted_at.present? %>" id="<%= post.id %>" md5="<%= post.md5 %>" has_children="<%= post.has_children? %>" creator_id="<%= post.uploader_id %>" author="<%= post.uploader_name %>" width="<%= post.image_width %>"/>
<% end %>
</posts>