# Recent improvements to Redis Lua scripting

DevFeed: [Recent improvements to Redis Lua scripting](<https://devfeed.tech/articles/recent-improvements-to-redis-lua-scripting-20688.md>)

Original publisher: [Read original article](<http://antirez.com/news/97>)

Published: 2015-11-19T11:23:27Z

Content type: article

Language: en

Sources: [Antirez](<https://devfeed.tech/sources/antirez.md>)

Topics: [Lua](<https://devfeed.tech/topics/lua.md>), [Redis](<https://devfeed.tech/topics/redis.md>), [Scripting](<https://devfeed.tech/topics/scripting.md>), [Replication](<https://devfeed.tech/topics/replication.md>), [Database](<https://devfeed.tech/topics/database.md>)

Tags: [debugger](<https://devfeed.tech/tags/debugger.md>), [improvements](<https://devfeed.tech/tags/improvements.md>), [lua](<https://devfeed.tech/tags/lua.md>), [redis](<https://devfeed.tech/tags/redis.md>), [replication](<https://devfeed.tech/tags/replication.md>), [scripting](<https://devfeed.tech/tags/scripting.md>)

## AI overview

This article describes two improvements to Redis Lua scripting: a proper debugger and replication and AOF storage of scripts as the write commands representing their effects. It also discusses the design and implementation considerations behind these features.

## Source excerpt

Lua scripting is probably the most successful Redis feature, among the ones introduced when Redis was already pretty popular: no surprise that a few of the things users really want are about scripting. The following two features were suggested multiple times over the last two years, and many people tried to focus my attention into one or the other during the Redis developers meeting, a few weeks ago. 1. A proper debugger for Redis Lua scripts. 2. Replication, and storage on the AOF, of Lua scripts as a set of write commands materializing the *effects* of the script, instead of replicating the script itself as we normally do. The second feature is not just a matter of how scripts are replicated, but also touches what you can do with Lua scripting as we will see later. Back from London, I implemented both the features. This blog post describes both, giving a few hints about the design and implementation aspects that may be interesting for the readers. A proper Lua debugger --- Lua scripting was initially conceived in order to write really trivial scripts. Things like: if the key exists do this. A couple of lines in order to avoid bloating Redis with all the possible variations of commands. Of course users did a lot more with it, and started to write complex scripts: from quad-tree implementations to full featured messaging systems with non trivial semantics. Lua scripting makes Redis programmable, and usually programmers can't resist to programmable things. It helps that all the Lua scripts run using the same interpreter and are cached, so they are very fast. It is most of the time possible to do a lot more with a Redis instance by using Lua scripting, both functionally and in terms of operations per second. So complex scripts totally have their place today. We went from a very cold reception of the scripting feature (something as dynamic as a script sent to a database!), to mass usage, to writing complex scripts in a matter of a few years. However writing simple scri