Post#fast_count: raise min cache lifetime to 3 minutes (#3925).
This commit is contained in:
@@ -1267,7 +1267,7 @@ class Post < ApplicationRecord
|
||||
end
|
||||
|
||||
def set_count_in_cache(tags, count, expiry = nil)
|
||||
expiry ||= [count.seconds, 20.hours].min
|
||||
expiry ||= count.seconds.clamp(3.minutes, 20.hours).to_i
|
||||
|
||||
Cache.put(count_cache_key(tags), count, expiry)
|
||||
end
|
||||
|
||||
@@ -2557,7 +2557,7 @@ class PostTest < ActiveSupport::TestCase
|
||||
end
|
||||
|
||||
should "set the expiration time" do
|
||||
Cache.expects(:put).with(Post.count_cache_key("aaa score:42"), 1, 1)
|
||||
Cache.expects(:put).with(Post.count_cache_key("aaa score:42"), 1, 180)
|
||||
Post.fast_count("aaa score:42")
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user