Struct redis::Script
[−]
[src]
pub struct Script { // some fields omitted }
Represents a lua script.
Methods
impl Script
The script object represents a lua script that can be executed on the redis server. The object itself takes care of automatic uploading and execution. The script object itself can be shared and is immutable.
Example:
let script = redis::Script::new(r" return tonumber(ARGV[1]) + tonumber(ARGV[2]); "); let result = script.arg(1).arg(2).invoke(&con); assert_eq!(result, Ok(3));
fn new(code: &str) -> Script
Creates a new script object.
fn get_hash(&self) -> &str
Returns the script's SHA1 hash in hexadecimal format.
fn key<T: ToRedisArgs>(&self, key: T) -> ScriptInvocation
Creates a script invocation object with a key filled in.
fn arg<T: ToRedisArgs>(&self, arg: T) -> ScriptInvocation
Creates a script invocation object with an argument filled in.
fn prepare_invoke(&self) -> ScriptInvocation
Returns an empty script invocation object. This is primarily useful
for programmatically adding arguments and keys because the type will
not change. Normally you can use arg
and key
directly.
fn invoke<T: FromRedisValue>(&self, con: &ConnectionLike) -> RedisResult<T>
Invokes the script directly without arguments.