expire name cache after 1 hour
This commit is contained in:
@@ -1069,7 +1069,7 @@ class Post < ActiveRecord::Base
|
|||||||
"md5" => md5,
|
"md5" => md5,
|
||||||
"has_notes" => last_noted_at.present?,
|
"has_notes" => last_noted_at.present?,
|
||||||
"rating" => rating,
|
"rating" => rating,
|
||||||
"author" => uploader.name,
|
"author" => uploader_name,
|
||||||
"creator_id" => uploader_id,
|
"creator_id" => uploader_id,
|
||||||
"width" => image_width,
|
"width" => image_width,
|
||||||
"source" => source,
|
"source" => source,
|
||||||
|
|||||||
@@ -79,7 +79,7 @@ class User < ActiveRecord::Base
|
|||||||
end
|
end
|
||||||
|
|
||||||
def id_to_name(user_id)
|
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
|
select_value_sql("SELECT name FROM users WHERE id = ?", user_id) || Danbooru.config.default_guest_name
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -107,6 +107,8 @@ class User < ActiveRecord::Base
|
|||||||
Net::HTTP.delete(URI.parse("http://#{server}/users/#{id}/cache"))
|
Net::HTTP.delete(URI.parse("http://#{server}/users/#{id}/cache"))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
rescue Exception
|
||||||
|
# swallow, since it'll be expired eventually anyway
|
||||||
end
|
end
|
||||||
|
|
||||||
def validate_feedback_on_name_change
|
def validate_feedback_on_name_change
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<posts>
|
<posts>
|
||||||
<% @posts.each do |post| %>
|
<% @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 %>
|
<% end %>
|
||||||
</posts>
|
</posts>
|
||||||
|
|||||||
Reference in New Issue
Block a user