mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
Ensure we don't run $redis.keys
in production.
This commit is contained in:
parent
603fa685f0
commit
95c6e97587
@ -77,10 +77,6 @@ class RandomTopicSelector
|
|||||||
results
|
results
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.clear_cache!
|
|
||||||
$redis.keys('random_topic_cache*').each{|k| $redis.del k}
|
|
||||||
end
|
|
||||||
|
|
||||||
def self.cache_key(category=nil)
|
def self.cache_key(category=nil)
|
||||||
"random_topic_cache_#{category.try(:id)}"
|
"random_topic_cache_#{category.try(:id)}"
|
||||||
end
|
end
|
||||||
|
@ -642,9 +642,12 @@ describe TopicQuery do
|
|||||||
end
|
end
|
||||||
|
|
||||||
context 'suggested_for' do
|
context 'suggested_for' do
|
||||||
|
def clear_cache!
|
||||||
|
$redis.keys('random_topic_cache*').each{|k| $redis.del k}
|
||||||
|
end
|
||||||
|
|
||||||
before do
|
before do
|
||||||
RandomTopicSelector.clear_cache!
|
clear_cache!
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when anonymous' do
|
context 'when anonymous' do
|
||||||
@ -674,7 +677,7 @@ describe TopicQuery do
|
|||||||
let(:suggested_topics) {
|
let(:suggested_topics) {
|
||||||
tt = topic
|
tt = topic
|
||||||
# lets clear cache once category is created - working around caching is hard
|
# lets clear cache once category is created - working around caching is hard
|
||||||
RandomTopicSelector.clear_cache!
|
clear_cache!
|
||||||
topic_query.list_suggested_for(tt).topics.map{|t| t.id}
|
topic_query.list_suggested_for(tt).topics.map{|t| t.id}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -691,11 +694,11 @@ describe TopicQuery do
|
|||||||
SiteSetting.suggested_topics_max_days_old = 1365
|
SiteSetting.suggested_topics_max_days_old = 1365
|
||||||
tt = topic
|
tt = topic
|
||||||
|
|
||||||
RandomTopicSelector.clear_cache!
|
clear_cache!
|
||||||
expect(topic_query.list_suggested_for(tt).topics.length).to eq(2)
|
expect(topic_query.list_suggested_for(tt).topics.length).to eq(2)
|
||||||
|
|
||||||
SiteSetting.suggested_topics_max_days_old = 365
|
SiteSetting.suggested_topics_max_days_old = 365
|
||||||
RandomTopicSelector.clear_cache!
|
clear_cache!
|
||||||
|
|
||||||
expect(topic_query.list_suggested_for(tt).topics.length).to eq(1)
|
expect(topic_query.list_suggested_for(tt).topics.length).to eq(1)
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user