pub struct Script { /* private fields */ }
Expand description
Represents a lua script.
Implementations§
§impl 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));
pub fn key<T>(&self, key: T) -> ScriptInvocation<'_>where
T: ToRedisArgs,
pub fn key<T>(&self, key: T) -> ScriptInvocation<'_>where
T: ToRedisArgs,
Creates a script invocation object with a key filled in.
pub fn arg<T>(&self, arg: T) -> ScriptInvocation<'_>where
T: ToRedisArgs,
pub fn arg<T>(&self, arg: T) -> ScriptInvocation<'_>where
T: ToRedisArgs,
Creates a script invocation object with an argument filled in.
pub 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.
pub fn invoke<T>(&self, con: &mut dyn ConnectionLike) -> Result<T, RedisError>where
T: FromRedisValue,
pub fn invoke<T>(&self, con: &mut dyn ConnectionLike) -> Result<T, RedisError>where
T: FromRedisValue,
Invokes the script directly without arguments.
pub async fn invoke_async<C, T>(&self, con: &mut C) -> Result<T, RedisError>where
C: ConnectionLike,
T: FromRedisValue,
pub async fn invoke_async<C, T>(&self, con: &mut C) -> Result<T, RedisError>where
C: ConnectionLike,
T: FromRedisValue,
Asynchronously invokes the script without arguments.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Script
impl RefUnwindSafe for Script
impl Send for Script
impl Sync for Script
impl Unpin for Script
impl UnwindSafe for Script
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more