How RedisGears does interception of Redis commands

I investigate how RedisGears intercepts Redis commands and runs multiple callbacks before delivering these commands to Redis server. Specifically I interested in CommandReader and hooks to Redis vanilla API. I need to add own functionality to vanilla requests instead of overriding them with own “my.set, my.get, etc”.
Do you have some documentation how interception works under the hood and how it is possible to be done from Redis Module?
I already tried running own callbacks with RedisGears v1.2.5. It is exactly what I need, but I want to do it in C/C++ code without any python in it.
Can you help me by pointing into the code or any documentation, may be I miss something?
I want to know how this is done and where I can continue investigating or writing code.

Hey @Maksym

RedisGears uses CommandFIltrer API to hook the command (Modules API reference | Redis).

If gears catches a command it wants to hook it changes the command to be some gears internal command and cause the execution to reach gears costume code.
Inside the hook we can call the original command using RM_Call. For a reference you can look at the command_hook.c code: RedisGears/command_hook.c at 1.2 · RedisGears/RedisGears · GitHub

Hi @meirsh
Thanks for a links, it is really helpful. :relieved: