mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
PERF: Use Redis SET EX GET instead of LUA script for counting (#15939)
This will prevent Discourse from booting on Redis < 6.2.0
This commit is contained in:
committed by
GitHub
parent
a48231041b
commit
4d3da70bc6
@@ -30,14 +30,14 @@ describe ApplicationRequest do
|
||||
inc(:http_total)
|
||||
|
||||
Discourse.redis.without_namespace.stubs(:incr).raises(Redis::CommandError.new("READONLY"))
|
||||
Discourse.redis.without_namespace.stubs(:eval).raises(Redis::CommandError.new("READONLY"))
|
||||
Discourse.redis.without_namespace.stubs(:set).raises(Redis::CommandError.new("READONLY"))
|
||||
|
||||
# flush will be deferred no error raised
|
||||
inc(:http_total, autoflush: 3)
|
||||
ApplicationRequest.write_cache!
|
||||
|
||||
Discourse.redis.without_namespace.unstub(:incr)
|
||||
Discourse.redis.without_namespace.unstub(:eval)
|
||||
Discourse.redis.without_namespace.unstub(:set)
|
||||
|
||||
inc(:http_total, autoflush: 3)
|
||||
expect(ApplicationRequest.http_total.first.count).to eq(3)
|
||||
|
||||
@@ -32,13 +32,13 @@ describe WebCrawlerRequest do
|
||||
inc('Googlebot')
|
||||
|
||||
Discourse.redis.without_namespace.stubs(:incr).raises(Redis::CommandError.new("READONLY"))
|
||||
Discourse.redis.without_namespace.stubs(:eval).raises(Redis::CommandError.new("READONLY"))
|
||||
Discourse.redis.without_namespace.stubs(:set).raises(Redis::CommandError.new("READONLY"))
|
||||
|
||||
inc('Googlebot', autoflush: 3)
|
||||
WebCrawlerRequest.write_cache!
|
||||
|
||||
Discourse.redis.without_namespace.unstub(:incr)
|
||||
Discourse.redis.without_namespace.unstub(:eval)
|
||||
Discourse.redis.without_namespace.unstub(:set)
|
||||
|
||||
inc('Googlebot', autoflush: 3)
|
||||
expect(web_crawler_request('Googlebot').count).to eq(3)
|
||||
|
||||
Reference in New Issue
Block a user