https://github.com/redislabs/luascript
Easy Lua Handling
https://github.com/redislabs/luascript
Last synced: about 1 year ago
JSON representation
Easy Lua Handling
- Host: GitHub
- URL: https://github.com/redislabs/luascript
- Owner: RedisLabs
- Created: 2016-03-02T15:55:24.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2016-03-02T16:32:37.000Z (over 10 years ago)
- Last Synced: 2025-04-06T17:04:39.074Z (about 1 year ago)
- Language: Java
- Size: 4.88 KB
- Stars: 6
- Watchers: 8
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# LuaScript - easily run Lua Redis scripts with Jedis
This library provides a nicer interface to handling Lua scripts with Jedis.
The idea is simple - instead of loading the script to redis, managing SHAs etc - just wrap it in a LuaScript object.
Scripts can be raw lua code, or loaded from project resources.
Scripts can then be called with or without arguments.
## Usage example
```java
import com.redislabs.luascript.LuaScript;
// loading a script from resource, and caching it on a redis server
LuaScript s = LuaScript.fromResource("lua/simple.lua", "redis://localhost:6379");
// now calling it is done simply with
Object o = s.execute();
```
### Scripts with arguments can be called like so:
```java
// the first argument is the number of keys in the variadic argument list
s.execute(1, key, value1, value2);
// or with lists of strings and keys
s.execute(keys, args);
```
### Scripts can also be used with pipelines or existing Jedis objects:
```java
Jedis conn = new Jedis(...);
s.execute(conn);
Pipeline pipe = conn.pipelined();
// note that executing on pipelines does not sync the pipeline
s.execute(pipe);
```