Add Redis::CommandRecorder
What does this MR do and why?
Contributes to #368697 (closed)
Problem
We have tooling to detect N+1 database queries in tests, but we don't have a way to do the same for Redis.
Proposal
Introduce a RedisCommands::Recorder
class to record Redis queries and
allow to access them.
It's a MVC that only defines basic methods.
How to set up and validate locally
control = RedisCommands::Recorder.new do
# your code that sends Redis commands
end
# number of all requests
expect(control.count).to eq(5)
# number of all get requests
expect(control.by_command(:get).count).to eq(5)
# use a pattern to fetch only specific keys
control = RedisCommands::Recorder.new(pattern: 'branch_names') do
# your code that sends Redis commands
end
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.
Edited by Vasilii Iakliushin