GitHub

API reference for Script.

A Lua script called with P: params(*args) gives its keys then its arguments, number_of_keys(*args) how many of them are keys, and decode reads its reply. Scripts are cached by identity, so make each one once.

Attributes

AttributeTypeDescription
luastr
paramsCallable[P, Sequence[str | float]]
number_of_keysCallable[P, int]
decodeCallable[[RedisReply], A_co]

Functions

__init__

__init__(lua, params, number_of_keys, decode) -> None
ParameterTypeDescription
luastr
paramsCallable[P, Sequence[str | float]]
number_of_keysCallable[P, int]
decodeCallable[[RedisReply], A_co]

arguments

arguments(*args, **kwargs) -> list[str]

EVALSHA's arguments after the hash: the key count, the keys and the arguments, numbers written as JavaScript's String.

ParameterTypeDescription
argsP.args = ()
kwargsP.kwargs = {}

Returns list[str]

def arguments(self, *args: P.args, **kwargs: P.kwargs) -> list[str]:
    """``EVALSHA``'s arguments after the hash: the key count, the keys
    and the arguments, numbers written as JavaScript's ``String``."""
    params = [_argument(param) for param in self.params(*args, **kwargs)]
    return [str(self.number_of_keys(*args, **kwargs)), *params]