luaudis is a library that allows you to write Redis scripts using Luau, a statically typed language that is highly compatible with Lua.
- Type Safety: Write Redis scripts with Luau's type system to catch errors at compile time.
- Tree Shaking: Automatically removes unused Redis commands from the final script, keeping the output size small.
- Reach Redis Command Support: Includes wrappers for most common Redis commands (String, List, Hash, Set, Sorted Set, etc.).
- Minification: Outputs minified Lua scripts ready for production.
- Luau - A fast, safe, gradually typed scripting language derived from Lua.
- darklua - A Luau code processor.
- lune - A Luau runtime.
- Taskfile - A task runner for automating development workflows.
luaudis is designed to be used as a template for your Redis Lua script projects.
-
Click the "Use this template" button on GitHub to create a new repository based on
luaudis. -
Clone your new repository:
git clone https://github.com/your-username/your-repo-name.git cd your-repo-name
Create a Luau file (e.g., src/main.luau) and import the redis module:
local redis = require("./redis")
-- Use Redis commands with type checking
redis.set("mykey", "Hello, Redis!")
local value = redis.get("mykey")
return valueUse task to build, optimize, and minify your script:
task buildThis command performs the following steps:
- Process: Converts Luau code to Lua 5.1 compatible code using
darklua. - Diet: Analyzes
src/main.luauand removes unused Redis command wrappers from the output. - Minify: Minifies the final Lua script.
The output will be generated at out/main.diet.min.lua.
You can execute the built script using redis-cli:
redis-cli --eval out/main.diet.min.luaOr use the provided task:
task runluaudis supports a wide range of Redis commands, including:
- Keys:
del,exists,expire,ttl,type,copy - Strings:
get,set,setnx,append,strlen,getrange,setrange,mget,mset,incr,decr - Lists:
lpush,rpush,lpop,rpop,llen,lrange,lindex,lrem,lset,ltrim - Hashes:
hset,hget,hmget,hdel,hexists,hgetall,hkeys,hvals,hlen,hincrby - Sets:
sadd,srem,smembers,sismember,scard,spop,srandmember - Sorted Sets:
zadd,zrem,zscore,zincrby,zcard,zrange,zrevrange,zrank,zrevrank,zcount
Apache License 2.0