API Reference¶
redgrease.utils module¶
Utility and boilerplate functions, such as parsers, value transformers etc.
- class redgrease.utils.CaseInsensitiveDict(data)[source]¶
Bases:
dict
Case insensitive dict implementation. Assumes string keys only. Heavily derived from redis.client `https://github.com/andymccurdy/redis-py/blob/master/redis/client.py`_
- redgrease.utils.as_is(value: redgrease.typing.T) redgrease.typing.T [source]¶
Passthrough parser / identity function
- Parameters
value (T) – Input value
- Returns
The value, unmodified.
- Return type
T
- redgrease.utils.str_if_bytes(value: redgrease.typing.T) Union[redgrease.typing.T, str] [source]¶
Parses byte values into a string, non-byte values passthrough unchanged Slightly modified from redis.utils, as it is not exported
- Parameters
value (T) – Any serialized Redis value
- Returns
Either a string or the input unchanged
- Return type
Union[T, str]
- redgrease.utils.safe_str(value: Any) str [source]¶
Parse anything to a string
- Parameters
value (Any) – Input value
- Returns
String
- Return type
str
- redgrease.utils.safe_str_upper(value: Any) str [source]¶
Parse anything to an uppercase string
- Parameters
value (Any) – Input value
- Returns
Parsed uppercase string
- Return type
str
- redgrease.utils.bool_ok(value: Any) bool [source]¶
Parse redis response as bool, such that:
"Ok"
=>True
Anything else =>
False
Same name as in redis.client but slightly different implementation. Should be better for long non-Ok replies, e.g. images, erroneously passed to it
- Parameters
value (Any) – Input value
- Returns
Parsed boolean
- Return type
bool
- redgrease.utils.optional(constructor: Union[Type[redgrease.typing.T], Callable[[Any], redgrease.typing.T]]) Union[Type[Optional[redgrease.typing.T]], Callable[[Any], Optional[redgrease.typing.T]]] [source]¶
Create parser that accepts
None
values, but otherwise behaves like the provided parser.- Parameters
constructor (Constructor[T]) – constructor to apply, unless the value is None.
- redgrease.utils.safe_bool(input: Any) bool [source]¶
Parse a bool, slightly more accepting
allowing for literal
"True"
/"False"
, integer 0 or1, as well as"Ok"
and"yes"
/"no"
values.- Parameters
input (Any) – Input value
- Returns
Parsed boolean
- Return type
bool
- redgrease.utils.to_int_if_bool(value: Any) Union[int, Any] [source]¶
Transforms any boolean into an integer As booleans are not natively supported as a separate datatype in Redis
True
=>1
False
=>0
- Parameters
value (Union[bool,Any]) – A boolean value
- Returns
Integer representation of the bool
- Return type
Union[int, Any]
- redgrease.utils.to_redis_type(value: Any) Union[bytes, int, float] [source]¶
Attempts to serialize a value to a Redis-native type. I.e. either: bytes, int or float It will serialize most primitive types (str, bool, int, float), as well as any complex type that implements
__bytes__
method- Parameters
value (Any) – Value to serialize for Redis
- Returns
A serialized version
- Return type
RedisType
- redgrease.utils.to_list(mapping: Optional[Dict[redgrease.typing.Key, redgrease.typing.Val]], key_transform: Callable[[redgrease.typing.Key], Any] = <function str_if_bytes>, val_transform: Callable[[redgrease.typing.Val], Any] = <function to_redis_type>) List [source]¶
Flattens a Dict to a list consisting of the of keys and values altertnating. This is useful generating the arguments for Redis commands.
- Parameters
mapping (Dict[Key, Val]) – The dict to flatten.
key_transform (Callable[[Key], Any], optional) – Transformation function for the keys. Defaults to ‘str_if_bytes’
val_transform (Callable[[Val], Any], optional) – Transformation function for the values. Defaults to ‘to_redis_type’.
- Returns
Flattened list of the transformed keys and values
- Return type
List
- redgrease.utils.transform(value: Any, constructor: Union[Type[redgrease.typing.T], Callable[[Any], redgrease.typing.T], Dict[redgrease.typing.Key, Union[Type[redgrease.typing.T], Callable[[Any], redgrease.typing.T]]]], key: Optional[redgrease.typing.Key] = None) redgrease.typing.T [source]¶
Applies a transformation to a value. The tranformation function could either be passed directly or in a dictionary along with a key to look it up. This is mostly only useful as a helper function for constructors of composite types, where the value may need to be transformed differently depending on the field/key.
- Parameters
value (Any) – Value to transform
constructor (Union[Constructor[T], Dict[Any, Constructor[T]]]) – Transformation function or a dict of transformation functions. If a dict is used, the key argument is used to look up the transformation. If the key is not present in the dict, but there is a ‘None’-key mapping to a functsion, this function will be used as a default. Otherwise, the value will be returned untransformed.
key (Key) – key to use to look up the appropriate transforpation
- Returns
Transformed value
- Return type
T
- redgrease.utils.to_dict(items: Iterable, keys: Optional[Iterable] = None, key_transform: Optional[Union[Type[redgrease.typing.Key], Callable[[Any], redgrease.typing.Key], Dict[Any, Union[Type[redgrease.typing.Key], Callable[[Any], redgrease.typing.Key]]]]] = None, val_transform: Optional[Union[Type[redgrease.typing.Val], Callable[[Any], redgrease.typing.Val], Dict[redgrease.typing.Key, Union[Type[redgrease.typing.Val], Callable[[Any], redgrease.typing.Val]]]]] = None) Dict[redgrease.typing.Key, redgrease.typing.Val] [source]¶
Folds an iterable of values into a dict. This is useful for parsing Redis’ list responseses into a more manageable structure. It can be used on lists of alternating unnamed Key and values, i.e:
[key_1, value_1, key_2, value_2, ... ]
eg:
to_dict(["foo", 42, 13, 37]) == {"foo": 42, 13: 37} to_dict(["foo", 42, 13, 37], key_transform=str) == {"foo": 42, "13": 37} to_dict(["foo", 42, 13, 37], val_transform=str) == {"foo": "42", 13: "37"} to_dict( ["foo", 42, 13, 37], val_transform={"foo":int, 13:float} ) == {"foo": 42, 13: 37.0} to_dict( ["foo", 42, 13, 37], key_transform=str, val_transform={"foo":int, "13":float} ) == {"foo": 42, "13": 37.0}
- Parameters
items (Iterable) – Iterable to “fold” into a dict
key_transform (Union[Constructor[Key], Dict[Any, Constructor[Key]]], optional) – Transformation function / type / constructor to apply to keys. It can either be a callable, which is then applied to all keys. Altertnatively, it can be a mapping from ‘raw’ key to a specific transform for that key Defaults to None (No key transformation).
val_transform (Union[Constructor[Val], Dict[Key, Constructor[Val]]], optional) – Transformation function / type / constructor to apply to values. It can either be a callable, which is then applied to all values. Altertnatively, it can be a mapping from (transformed) key to a specific transform for the value of that key Defaults to None (No value transformation).
- Returns
Folded dictionary
- Return type
Dict[Key, Val]
- redgrease.utils.to_kwargs(items: Iterable) Dict[str, Any] [source]¶
Folds an iterable of values into a ‘kwargs-compatible’ dict. This is useful for constructing objects from Redis’ list responseses, by means of an intermediate kwargs dict that can be passed to for example a constructor. It behaves exactly as ‘to_dict’ but enforces keys to be parsed to strings.
- Alternating unnamed Key and values, i.e::
[key_1, value_1, key_2, value_2, … ]
eg:
input:
["foo", 42, 13, 37]
output:
{"foo": 42, "13": 37}
- Parameters
items (Iterable) – Iterable to “fold” into a dict
- Returns
Folded dictionary
- Return type
Dict[str, Any]
- redgrease.utils.list_parser(item_parser: Union[Type[redgrease.typing.T], Callable[[Any], redgrease.typing.T]]) Callable[[Iterable], List[redgrease.typing.T]] [source]¶
Creates a list parser for lists of objects created with a given constructor. E.g:
parser = list_parser(bool) parser(['', 1, None])
=>
[False, True, False]
- Parameters
item_parser (Constructor[T]) – The constructor to apply to each element.
- Returns
Function that takes maps the constructor on to the iterable and returns the result as a list.
- Return type
Callable[[Iterable[Any]], List[T]]
- redgrease.utils.list_of_str(input_list)¶
- redgrease.utils.dict_of(constructors: Dict[redgrease.typing.Key, Union[Type[Any], Callable[[Any], Any]]]) Callable[[Iterable, Iterable[redgrease.typing.Key]], Dict[redgrease.typing.Key, Any]] [source]¶
Creates a parser that parses a list of values to a dict, according to a dict of named constructors.
The generated parser takes both the iterable of values to parse, as well as, an equally long, iterable of names/keys to to use to lookup the corresponding parser/constructor in the constructor lookup dict.
The parser for the Nth value is using the parser found by looking up the Nth name/key in the key list in the lookup dict. This key is also used as the key in the resulting dict.
E.g:
parser = dict_of({"b":bool, "i":int, "s":str, "f":float}) parser([0,1,0,1], ["b","f","s","i"])
=>
{"b":False, "f":1.0, "i":1, "s":"0"}
- Parameters
constructors (Dict[str, Constructor[Any]]) – Dict of named constructors
- Returns
Dict parser
- Return type
Callable[…, Dict[str, Any]]
- class redgrease.utils.Record(key: str, value: Optional[Any] = None, type: Optional[str] = None, event: Optional[str] = None, **kwargs)[source]¶
Bases:
object
Class representing a Redis Record, as generated by KeysReader.
- key¶
The name of the Redis key.
- Type
str
- value¶
The value corresponting to the key. None if deleted.
- Type
Any
- type¶
The core Redis type. Either ‘string’, ‘hash’, ‘list’, ‘set’, ‘zset’ or ‘stream’.
- Type
str
- event¶
The event that triggered the execution. (None if the execution was created via the run function.)
- Type
str
- class redgrease.utils.StreamRecord(key: str, id: Optional[str] = None, value: Optional[Any] = None, **kwargs)[source]¶
Bases:
object
Class representing a Redis Record, as generated by KeysReader.
- key¶
The name of the Redis key.
- Type
str
- value¶
The value corresponting to the key. None if deleted.
- Type
Any
- type¶
The core Redis type. Either ‘string’, ‘hash’, ‘list’, ‘set’, ‘zset’ or ‘stream’.
- Type
str
- event¶
The event that triggered the execution. (None if the execution was created via the run function.)
- Type
str
- redgrease.utils.record(rec: Any) redgrease.utils.Record [source]¶
Create a Record
- Parameters
rec (Any) – the value to parse. Either a string (key only) or a dict with at minimum the key key present and optionally any of the keys value, type and/or event.
- Returns
Parsed Record object.
- Return type
- redgrease.utils.stream_record(rec: Any) redgrease.utils.StreamRecord [source]¶
Create a Record
- Parameters
rec (Any) – the value to parse. Either a string (key only) or a dict with at minimum the key key present and optionally any of the keys value, type and/or event.
- Returns
Parsed Record object.
- Return type
- redgrease.utils.compose(*function: Callable) Callable [source]¶
Compose functions. I.e:
lambda x: f(g(x))
can be written:
compose(f, g)``
- Parameters
*function (Callable) – Any number of functions to compose together. Output type of function N must be the input type of function N+1.
- Returns
A composed function with input type same as the firs function, and output type same as the last function.
- Return type
Callable
- redgrease.utils.dict_filter(**kwargs) Callable[[Dict[str, Any]], bool] [source]¶
Create a dictionary matching predicate function.
This function takes any number of keyword arguments, and returns a predicate function that takes a single dict as argument and returns a bool.
The predicate function returns True if, and only if, for all keyword arguments:
The keyword argument name is a key in the dict, and
Depending on the value, V, of the keyword argument, either:
- V is Container type (excluding
str
) The dict value for the key is present in V
- V is Container type (excluding
- V is a Type (e.g.
bool
) The dict value for the key is of type V.
- V is a Type (e.g.
- V is any value, except
...
(Ellipsis) The dict value for the key equals V.
- V is any value, except
- V is
...
(Ellipsis) The dict value can be any value.
- V is
- redgrease.utils.passfun(fun: Optional[redgrease.typing.T] = None, default: Optional[redgrease.typing.T] = None) redgrease.typing.T [source]¶
Create a Python ‘function’ object from any ‘Callable’, or constant.
RedisGears operator callbacks ony accept proper ‘function’s and not every type of ‘Callable’, such as for example ‘method’s (e.g. redgrease.cmd.incr) or ‘method-desriptor’s (e.g. str.split), which forces users to write seemingly “unnecessary” lambda-functions to wrap these.
This function ensures that the argument is a proper ‘function’, and thus will be accepted as RedisGears operator callback (assuming the type signature is correct).
It can also be used to create ‘constant’-functions, if passing a non-callable, or to create the ‘identity-function`, if called with no arguments.
- Parameters
fun (Optional[T], optional) – Callable to turn into a ‘function` Alternatively a constant, to use to create a constant function, i.e. a function that alway return the same thing, regarding of input. If None, and no default, the ‘identity-function’ is returned. Defaults to None.
default (Optional[T], optional) – Default Callable to use as fallback if the ‘fun’ argument isn’t a callable. Defaults to None.
- Returns
[description]
- Return type
T
redgrease.data module¶
Datatypes and parsers for the various structures, specific to Redis Gears.
These datatypes are returned from various redgrease functions, merely for the purpose of providing more convenient structure, typing and documentation compared to the native ‘list-based’ structures.
They are generally not intended to be instantiated by end-users.
- class redgrease.data.ExecID(shard_id: str = '0000000000000000000000000000000000000000', sequence: int = 0)[source]¶
Bases:
object
Execution ID
- shard_id¶
Shard Identifier
- Type
str
- sequence¶
Sequence number
- Type
in
Method generated by attrs for class ExecID.
- shard_id: str¶
- sequence: int¶
- static parse(value: Union[str, bytes]) redgrease.data.ExecID [source]¶
Parses a string or bytes representation into a redgrease.data.ExecID
- Returns
The parsed ExecID
- Return type
- Raises
ValueError – If the the value cannot be parsed.
- class redgrease.data.ExecutionResult(value: redgrease.data.T, errors: Optional[List] = None)[source]¶
Bases:
ObjectProxy
,Generic
[redgrease.data.T
]Common class for all types of execution results. Generic / Polymorphic on the result type (T) of the Gears function.
Redis Gears specifies a few different commands for getting the results of a function execution (pyexecute, getresults, getresultsblocking and trigger), each potentially having more than one different possible value type, depending on context.
In addition, while most gears functions result in collection of values, some functions (notably those ending with a count or avg operation) semantically always have scalar results, but are still natively returned as a list.
redgrease.data.ExecutionResult is a unified result type for all scenarios, aiming at providing as intuitive API experience as possible.
It is generic and walks and quacks just like the main result type (T) it wraps. With some notable exceptions:
It has an additional property errors containing any accumulated errors
Scalar results, behaves like scalars, but also like a single element list.
This behavior isn’t always perfect but gives for the most part an intuitive api experience.
If the behavior in some situations are confusing, the raw wrapped value can be accessed through the value property.
- property value¶
Gets the raw result value of the Gears function execution.
- Returns
The result value / values
- Return type
T
- property errors: Optional[List]¶
- redgrease.data.parse_execute_response(response) redgrease.data.ExecutionResult [source]¶
Parses raw responses from pyexecute, getresults and getresultsblocking into a redgrease.data.ExecuteResponse object.
- Parameters
response (Any) –
The raw gears function response. This is most commonly a tuple of a list with the actual results and a list of errors List[List[Union[T, Any]]].
For some scenarios the response may take other forms, like a simple Ok (e.g. in the absence of a closing run() operation) or an execution ID (e.g. for non-blocking executions).
- Returns
A parsed execution response
- Return type
- redgrease.data.parse_trigger_response(response) redgrease.data.ExecutionResult [source]¶
Parses raw responses from trigger into a redgrease.data.ExecuteResponse object.
- Parameters
response (Any) – The gears function response. This is a tuple of a list with the actual results and a list of errors List[List[Union[T, Any]]].
pickled (bool, optional) – Indicates if the response is pickled and need to be unpickled. Defaults to False.
- Returns
A parsed execution response
- Return type
- class redgrease.data.ExecutionStatus(value)[source]¶
Bases:
redgrease.utils._REnum
Representation of the various states an execution could be in.
- created = b'created'¶
Created - The execution has been created.
- running = b'running'¶
Running - The execution is running.
- done = b'done'¶
Done - Thee execution is done.
- aborted = b'aborted'¶
Aborted - The execution has been aborted.
- pending_cluster = b'pending_cluster'¶
Pending Cluster - Initiator is waiting for all workers to finish.
- pending_run = b'pending_run'¶
Pending Run - Worker is pending ok from initiator to execute.
- pending_receive = b'pending_receive'¶
Pending Receive - Initiator is pending acknowledgement from workers on receiving execution.
- pending_termination = b'pending_termination'¶
Pending Termination - Worker is pending termination messaging from initiator
- class redgrease.data.ExecLocality(value)[source]¶
Bases:
redgrease.utils._REnum
Locality of execution: Shard or Cluster
- Shard = 'Shard'¶
- Cluster = 'Cluster'¶
- class redgrease.data.RedisObject[source]¶
Bases:
object
Base class for many of the more complex Redis Gears configuration values
- classmethod from_redis(params) redgrease.data.RedisObject [source]¶
Default parser
Assumes the object is seralized as a list of alternating attribute names and values.
Note: This method should not be invoked directly on the ‘RedisObject’ base class. It should be only be invoked on subclasses of RedisObjects.
- Returns
Returns the RedisObject subclass if, and only if, its constructor argument names and value types exactly match the names and values in the input list.
- Return type
- Raises
TypeError – If either the input list contains attributes not defined in the subclass constructor, or if the subclass defines mandatory constructor arguments that are not present in the input list.
- redgrease.data.parse_PD(value: Union[str, bytes]) Dict [source]¶
Parses str or bytes to a dict.
Used for the ‘PD’ field in the ‘Registration’ type, returned by ‘getregistrations’.
- Parameters
value (Union[str,bytes]) – Serialized version of a dict.
- Returns
A dictionary
- Return type
Dict
- class redgrease.data.ExecutionInfo(executionId: Union[str, bytes], status, registered: Any)[source]¶
Bases:
redgrease.data.RedisObject
Return object for redgrease.client.Redis.dumpexecutions command.
Method generated by attrs for class ExecutionInfo.
- executionId: redgrease.data.ExecID¶
The execution Id
- status: redgrease.data.ExecutionStatus¶
The status
- registered: bool¶
Indicates whether this is a registered execution
- class redgrease.data.RegData(mode: Any, numTriggered: int, numSuccess: int, numFailures: int, numAborted: int, lastError: str, args: Iterable, status=None)[source]¶
Bases:
redgrease.data.RedisObject
Object reprenting the values for the Registration.RegistrationData, part of the return value of redgrease.client.dupregistrations command.
Method generated by attrs for class RegData.
- mode: str¶
Registration mode.
- numTriggered: int¶
A counter of triggered executions.
- numSuccess: int¶
A counter of successful executions.
- numFailures: int¶
A counter of failed executions.
- numAborted: int¶
A conter of aborted executions.
- lastError: str¶
The last error returned.
- args: Dict[str, Any]¶
Reader-specific arguments
- status: Optional[bool]¶
Undocumented status field
- class redgrease.data.Registration(id: Union[str, bytes], reader: Any, desc: str, RegistrationData, PD: Union[str, bytes], ExecutionThreadPool: Optional[Any] = None)[source]¶
Bases:
redgrease.data.RedisObject
Return object for redgrease.client.Redis.dumpregistrations command. Contains the information about a function registration.
Method generated by attrs for class Registration.
- id: redgrease.data.ExecID¶
The registration ID.
- reader: str¶
The Reader.
- desc: str¶
The description.
- RegistrationData: redgrease.data.RegData¶
Registration Data, see RegData.
- PD: Dict[Any, Any]¶
Private data
- ExecutionThreadPool: Optional[str]¶
- class redgrease.data.ExecutionStep(type: Any, duration: int, name: Any, arg: Any)[source]¶
Bases:
redgrease.data.RedisObject
Object reprenting a ‘step’ in the ExecutionPlan.steps, attribute of the return value of redgrease.client.getexecution command.
Method generated by attrs for class ExecutionStep.
- type: str¶
Step type.
- duration: int¶
The step’s duration in milliseconds (0 when ProfileExecutions is disabled)
- name: str¶
Step callback
- arg: str¶
Step argument
- class redgrease.data.ExecutionPlan(status, shards_received: int, shards_completed: int, results: int, errors: int, total_duration: int, read_duration: int, steps)[source]¶
Bases:
redgrease.data.RedisObject
Object representing the execution plan for a given shard in the response from the redgrease.client.Redis.getexecution command.
Method generated by attrs for class ExecutionPlan.
- status: redgrease.data.ExecutionStatus¶
The current status of the execution.
- shards_received: int¶
Number of shards that received the execution.
- shards_completed: int¶
Number of shards that completed the execution.
- results: int¶
Count of results returned.
- errors: int¶
Count of the errors raised.
- total_duration: int¶
Total execution duration in milliseconds.
- read_duration: int¶
Reader execution duration in milliseconds.
- steps: List[redgrease.data.ExecutionStep]¶
The steps of the execution plan.
- static parse(res: Iterable[bytes]) Dict[str, redgrease.data.ExecutionPlan] [source]¶
Parse the raw results of redgrease.client.Redis.getexecution into a dict that maps from shard identifiers to ExecutionStep objects.
- Returns
Execution plan mapping.
- Return type
Dict[str, ExecutionPlan]
- class redgrease.data.ShardInfo(id: Any, ip: Any, port: int, unixSocket: Any, runid: Any, minHslot: int, maxHslot: int, pendingMessages: int)[source]¶
Bases:
redgrease.data.RedisObject
Object representing a shard in the ClusterInfo.shards attribute in the response from redgrease.client.Redis.infocluster command.
Method generated by attrs for class ShardInfo.
- id: str¶
The shard’s identifier int the cluster.
- ip: str¶
The shard’s IP address.
- port: int¶
The shard’s port.
- unixSocket: str¶
The shards UDS.
- runid: str¶
The engines run identifier.
- minHslot: int¶
Lowest hash slot served by the shard.
- maxHslot: int¶
Highest hash slot served by the shard.
- pendingMessages: int¶
Number of pending messages
- class redgrease.data.ClusterInfo(my_id: str, my_run_id: str, shards)[source]¶
Bases:
redgrease.data.RedisObject
Information about the Redis Gears cluster.
Return object for redgrease.client.Redis.infocluster command.
Method generated by attrs for class ClusterInfo.
- my_id: str¶
The identifier of the shard the client is connected to.
- my_run_id: str¶
- shards: List[redgrease.data.ShardInfo]¶
List of the all the shards in the cluster.
- static parse(res: bytes) Optional[redgrease.data.ClusterInfo] [source]¶
Parses the response from redgrease.client.Redis.infocluster into a ClusterInfo object.
If the client is not connected to a Redis Gears cluster, None is returned.
- Returns
A ClusterInfo object or None (if not in cluster mode).s
- Return type
Optional[ClusterInfo]
- class redgrease.data.PyStats(TotalAllocated: int, PeakAllocated: int, CurrAllocated: int)[source]¶
Bases:
redgrease.data.RedisObject
Memory usage statistics from the Python interpreter. As returned by redgrease.client.Redis.pystats
Method generated by attrs for class PyStats.
- TotalAllocated: int¶
A total of all allocations over time, in bytes.
- PeakAllocated: int¶
The peak allocations, in bytes.
- CurrAllocated: int¶
The currently allocated memory, in bytes.
- class redgrease.data.PyRequirementInfo(GearReqVersion: int, Name: Any, IsDownloaded: Any, IsInstalled: Any, CompiledOs: Any, Wheels)[source]¶
Bases:
redgrease.data.RedisObject
Information about a Python requirement / dependency.
Method generated by attrs for class PyRequirementInfo.
- GearReqVersion: int¶
An internally-assigned version of the requirement. (note: this isn’t the package’s version)
- Name: str¶
The name of the requirement as it was given to the ‘requirements’ argument of the pyexecute command.
- IsDownloaded: bool¶
True if the requirement wheels was successfully download, otherwise False.
- IsInstalled: bool¶
True if the requirement wheels was successfully installed, otherwise False.
- CompiledOs: str¶
The underlying Operating System
- Wheels: List[str]¶
A List of Wheels required by the requirement.
redgrease.sugar module¶
Basic syntactic sugar.
- class redgrease.sugar.ReaderType[source]¶
Bases:
object
Redis Gears Reader Types
- KeysReader = 'KeysReader'¶
KeysReader
- KeysOnlyReader = 'KeysOnlyReader'¶
KeysOnlyReader
- StreamReader = 'StreamReader'¶
StreamReader
- PythonReader = 'PythonReader'¶
PythonReader
- ShardsIDReader = 'ShardsIDReader'¶
ShardsIDReader
- CommandReader = 'CommandReader'¶
CommandReader
- class redgrease.sugar.TriggerMode[source]¶
Bases:
object
Redis Geears Trigger modes for registered actions
- Async = 'async'¶
Async
- AsyncLocal = 'async_local'¶
AsyncLocal
- Sync = 'sync'¶
Sync
- class redgrease.sugar.KeyType[source]¶
Bases:
object
Redis Key Types
- String = 'string'¶
String
- Hash = 'hash'¶
Hash
- List = 'list'¶
List
- Set = 'set'¶
Set
- ZSet = 'zset'¶
ZSet
- Stream = 'stream'¶
Stream
- Module = 'module'¶
Module
- static of(python_type: Any) str [source]¶
Get the corresponding Redis key type string for a given Python type or value, if it exists. The only valid types are ‘str’, ‘dict’, ‘list’ and ‘set’.
- Parameters
python_type (Any) – A python type or any value value.
- Raises
ValueError – If there is no valid Redis key type for the Python type.
- Returns
The string representing the Redis key type.
- Return type
str
- class redgrease.sugar.FailurePolicy[source]¶
Bases:
object
Redis event handler failure policy
- Continue = 'continue'¶
Continue
- Abort = 'abort'¶
Abort
- Retry = 'retry'¶
Retry