pub struct Script { /* private fields */ }
Expand description
Represents a lua script.
Implementations
sourceimpl Script
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(&mut con);
assert_eq!(result, Ok(3));
sourcepub fn key<T: ToRedisArgs>(&self, key: T) -> ScriptInvocation<'_>
pub fn key<T: ToRedisArgs>(&self, key: T) -> ScriptInvocation<'_>
Creates a script invocation object with a key filled in.
sourcepub fn arg<T: ToRedisArgs>(&self, arg: T) -> ScriptInvocation<'_>
pub fn arg<T: ToRedisArgs>(&self, arg: T) -> ScriptInvocation<'_>
Creates a script invocation object with an argument filled in.
sourcepub fn prepare_invoke(&self) -> ScriptInvocation<'_>
pub 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.
sourcepub fn invoke<T: FromRedisValue>(
&self,
con: &mut dyn ConnectionLike
) -> RedisResult<T>
pub fn invoke<T: FromRedisValue>(
&self,
con: &mut dyn ConnectionLike
) -> RedisResult<T>
Invokes the script directly without arguments.
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for Script
impl Send for Script
impl Sync for Script
impl Unpin for Script
impl UnwindSafe for Script
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more