DEV: Remove Discourse.redis.delete_prefixed (#22103)

This method is a huge footgun in production, since it calls
the Redis KEYS command. From the Redis documentation at
https://redis.io/commands/keys/:

> Warning: consider KEYS as a command that should only be used in
production environments with extreme care. It may ruin performance when
it is executed against large databases. This command is intended for
debugging and special operations, such as changing your keyspace layout.
Don't use KEYS in your regular application code.

Since we were only using `delete_prefixed` in specs (now that we
removed the usage in production in 24ec06ff85c7acbad9621092b5e50eec2ede7b83)
we can remove this and instead rely on `use_redis_snapshotting` on the
particular tests that need this kind of clearing functionality.
This commit is contained in:
Martin Brennan
2023-06-16 12:44:35 +10:00
committed by GitHub
parent e89c70643b
commit 9174716737
24 changed files with 225 additions and 224 deletions

View File

@ -756,10 +756,9 @@ RSpec.describe ApplicationController do
after { I18n.reload! }
context "with rate limits" do
before do
RateLimiter.clear_all!
RateLimiter.enable
end
before { RateLimiter.enable }
use_redis_snapshotting
it "serves a LimitExceeded error in the preferred locale" do
SiteSetting.max_likes_per_day = 1
@ -974,10 +973,9 @@ RSpec.describe ApplicationController do
describe "Discourse-Rate-Limit-Error-Code header" do
fab!(:admin) { Fabricate(:admin) }
before do
RateLimiter.clear_all!
RateLimiter.enable
end
before { RateLimiter.enable }
use_redis_snapshotting
it "is included when API key is rate limited" do
global_setting :max_admin_api_reqs_per_minute, 1
@ -1021,10 +1019,9 @@ RSpec.describe ApplicationController do
end
describe "crawlers in slow_down_crawler_user_agents site setting" do
before do
RateLimiter.enable
RateLimiter.clear_all!
end
before { RateLimiter.enable }
use_redis_snapshotting
it "are rate limited" do
SiteSetting.slow_down_crawler_rate = 128