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:
Rafael dos Santos Silva
2022-02-15 10:36:07 -03:00
committed by GitHub
parent a48231041b
commit 4d3da70bc6
4 changed files with 10 additions and 14 deletions

View File

@ -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)