You’ve heard that Redis has an embedded scripting language, but haven’t given it a try yet? Here’s a tour of what you need to understand to use the power of Lua with your Redis server.
https://www.redisgreen.net/blog/intro-to-lua-for-redis-programmers/