There are some use case for middlewares that only applies to a specific connection.
You could implement key namespacing as a middleware for instance, or use it to ban some commands etc, without impacting libraries that use redis-client too.
This can also be used to implement the Semian adapter as a middleware without any monkey patch.
I re-recorded the benchmark, and with this implementation there's no measurable perf impact.
The one downside of this implementation is that it makes it a bit harder for a middleware to be instantiated with some kind of configuration parameters, but it's not impossible at all.
Fix: https://github.com/redis-rb/redis-client/pull/52
There are some use case for middlewares that only applies to a specific connection.
You could implement key namespacing as a middleware for instance, or use it to ban some commands etc, without impacting libraries that use redis-client too.
This can also be used to implement the Semian adapter as a middleware without any monkey patch.
I re-recorded the benchmark, and with this implementation there's no measurable perf impact.
The one downside of this implementation is that it makes it a bit harder for a middleware to be instantiated with some kind of configuration parameters, but it's not impossible at all.
Co-Authored-By: @gremerritt