pub struct Script { /* private fields */ }Available on crate feature
i-scripts only.Expand description
An interface for caching and running lua scripts.
async fn example(client: &RedisClient) -> Result<(), RedisError> {
let script = Script::from_lua("return ARGV[1]");
assert_eq!(script.sha1(), "098e0f0d1448c0a81dafe820f66d460eb09263da");
let _ = script.load(client).await?;
let result: String = script.evalsha(client, "key", "arg").await?;
assert_eq!(result, "arg");
Ok(())
}Implementations§
source§impl Script
impl Script
sourcepub fn from_lua<S: Into<Str>>(lua: S) -> Self
Available on crate feature sha-1 only.
pub fn from_lua<S: Into<Str>>(lua: S) -> Self
sha-1 only.Create a new Script from a lua script.
sourcepub async fn load(&self, client: &RedisClient) -> RedisResult<()>
Available on crate feature sha-1 only.
pub async fn load(&self, client: &RedisClient) -> RedisResult<()>
sha-1 only.Call SCRIPT LOAD on all the associated servers. This must be
called once before calling evalsha.
sourcepub async fn evalsha<R, C, K, V>(
&self,
client: &C,
keys: K,
args: V,
) -> RedisResult<R>where
R: FromRedis,
C: LuaInterface + Send + Sync,
K: Into<MultipleKeys> + Send,
V: TryInto<MultipleValues> + Send,
V::Error: Into<RedisError> + Send,
pub async fn evalsha<R, C, K, V>(
&self,
client: &C,
keys: K,
args: V,
) -> RedisResult<R>where
R: FromRedis,
C: LuaInterface + Send + Sync,
K: Into<MultipleKeys> + Send,
V: TryInto<MultipleValues> + Send,
V::Error: Into<RedisError> + Send,
Send EVALSHA to the server with the provided arguments.
sourcepub async fn evalsha_with_reload<R, K, V>(
&self,
client: &RedisClient,
keys: K,
args: V,
) -> RedisResult<R>where
R: FromRedis,
K: Into<MultipleKeys> + Send,
V: TryInto<MultipleValues> + Send,
V::Error: Into<RedisError> + Send,
Available on crate feature sha-1 only.
pub async fn evalsha_with_reload<R, K, V>(
&self,
client: &RedisClient,
keys: K,
args: V,
) -> RedisResult<R>where
R: FromRedis,
K: Into<MultipleKeys> + Send,
V: TryInto<MultipleValues> + Send,
V::Error: Into<RedisError> + Send,
sha-1 only.Send EVALSHA to the server with the provided arguments. Automatically SCRIPT LOAD in case
of NOSCRIPT error and try EVALSHA again.
Trait Implementations§
source§impl Ord for Script
impl Ord for Script
source§impl PartialOrd for Script
impl PartialOrd for Script
impl Eq for Script
impl StructuralPartialEq for Script
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> CallHasher for T
impl<T> CallHasher for T
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit)§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> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§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