Book Image

ServiceStack 4 Cookbook

Book Image

ServiceStack 4 Cookbook

Overview of this book

Table of Contents (18 chapters)
ServiceStack 4 Cookbook
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Preface
Index

Scripting Redis with Lua


Many modern NoSQL data stores offer a way to evaluate scripts within the remote server, often by way of sending bits of code to the remote server for execution. Redis offers this capability too, using the popular Lua scripting language. This unlocks capabilities not currently offered by the official Redis API or the ServiceStack Redis client API. In the RDBMS world, this might be like creating a stored procedure.

Scripts evaluated will be compiled and cached on the Redis server. Calling them again in the future will simply execute the cached, compiled function. Scripts can be stored on the server and named so that they can be referenced without resending the full text of the script over the wire.

We'll cover some very basic concepts about how you can script Redis operations in Lua, without getting into the full language specification. Lua itself is a lightweight, multi-paradigm programming language designed as a scripting language. Based on C, it's portable across...