Module spin_sdk.wit.imports.redis
Expand source code
from typing import TypeVar, Generic, Union, Optional, Protocol, Tuple, List, Any, Self
from enum import Flag, Enum, auto
from dataclasses import dataclass
from abc import abstractmethod
import weakref
from ..types import Result, Ok, Err, Some
@dataclass
class Error_InvalidAddress:
pass
@dataclass
class Error_TooManyConnections:
pass
@dataclass
class Error_TypeError:
pass
@dataclass
class Error_Other:
value: str
Error = Union[Error_InvalidAddress, Error_TooManyConnections, Error_TypeError, Error_Other]
"""
Errors related to interacting with Redis
"""
@dataclass
class RedisParameter_Int64:
value: int
@dataclass
class RedisParameter_Binary:
value: bytes
RedisParameter = Union[RedisParameter_Int64, RedisParameter_Binary]
"""
A parameter type for the general-purpose `execute` function.
"""
@dataclass
class RedisResult_Nil:
pass
@dataclass
class RedisResult_Status:
value: str
@dataclass
class RedisResult_Int64:
value: int
@dataclass
class RedisResult_Binary:
value: bytes
RedisResult = Union[RedisResult_Nil, RedisResult_Status, RedisResult_Int64, RedisResult_Binary]
"""
A return type for the general-purpose `execute` function.
"""
class Connection:
@classmethod
def open(cls, address: str) -> Self:
"""
Open a connection to the Redis instance at `address`.
Raises: `spin_sdk.wit.types.Err(spin_sdk.wit.imports.redis.Error)`
"""
raise NotImplementedError
def publish(self, channel: str, payload: bytes) -> None:
"""
Publish a Redis message to the specified channel.
Raises: `spin_sdk.wit.types.Err(spin_sdk.wit.imports.redis.Error)`
"""
raise NotImplementedError
def get(self, key: str) -> Optional[bytes]:
"""
Get the value of a key.
Raises: `spin_sdk.wit.types.Err(spin_sdk.wit.imports.redis.Error)`
"""
raise NotImplementedError
def set(self, key: str, value: bytes) -> None:
"""
Set key to value.
If key already holds a value, it is overwritten.
Raises: `spin_sdk.wit.types.Err(spin_sdk.wit.imports.redis.Error)`
"""
raise NotImplementedError
def incr(self, key: str) -> int:
"""
Increments the number stored at key by one.
If the key does not exist, it is set to 0 before performing the operation.
An `error::type-error` is returned if the key contains a value of the wrong type
or contains a string that can not be represented as integer.
Raises: `spin_sdk.wit.types.Err(spin_sdk.wit.imports.redis.Error)`
"""
raise NotImplementedError
def del_(self, keys: List[str]) -> int:
"""
Removes the specified keys.
A key is ignored if it does not exist. Returns the number of keys deleted.
Raises: `spin_sdk.wit.types.Err(spin_sdk.wit.imports.redis.Error)`
"""
raise NotImplementedError
def sadd(self, key: str, values: List[str]) -> int:
"""
Add the specified `values` to the set named `key`, returning the number of newly-added values.
Raises: `spin_sdk.wit.types.Err(spin_sdk.wit.imports.redis.Error)`
"""
raise NotImplementedError
def smembers(self, key: str) -> List[str]:
"""
Retrieve the contents of the set named `key`.
Raises: `spin_sdk.wit.types.Err(spin_sdk.wit.imports.redis.Error)`
"""
raise NotImplementedError
def srem(self, key: str, values: List[str]) -> int:
"""
Remove the specified `values` from the set named `key`, returning the number of newly-removed values.
Raises: `spin_sdk.wit.types.Err(spin_sdk.wit.imports.redis.Error)`
"""
raise NotImplementedError
def execute(self, command: str, arguments: List[RedisParameter]) -> List[RedisResult]:
"""
Execute an arbitrary Redis command and receive the result.
Raises: `spin_sdk.wit.types.Err(spin_sdk.wit.imports.redis.Error)`
"""
raise NotImplementedError
def __enter__(self):
"""Returns self"""
return self
def __exit__(self, *args):
"""
Release this resource.
"""
raise NotImplementedError
Global variables
var Error
-
Errors related to interacting with Redis
var RedisParameter
-
A parameter type for the general-purpose
execute
function. var RedisResult
-
A return type for the general-purpose
execute
function.
Classes
class Connection
-
Expand source code
class Connection: @classmethod def open(cls, address: str) -> Self: """ Open a connection to the Redis instance at `address`. Raises: `spin_sdk.wit.types.Err(spin_sdk.wit.imports.redis.Error)` """ raise NotImplementedError def publish(self, channel: str, payload: bytes) -> None: """ Publish a Redis message to the specified channel. Raises: `spin_sdk.wit.types.Err(spin_sdk.wit.imports.redis.Error)` """ raise NotImplementedError def get(self, key: str) -> Optional[bytes]: """ Get the value of a key. Raises: `spin_sdk.wit.types.Err(spin_sdk.wit.imports.redis.Error)` """ raise NotImplementedError def set(self, key: str, value: bytes) -> None: """ Set key to value. If key already holds a value, it is overwritten. Raises: `spin_sdk.wit.types.Err(spin_sdk.wit.imports.redis.Error)` """ raise NotImplementedError def incr(self, key: str) -> int: """ Increments the number stored at key by one. If the key does not exist, it is set to 0 before performing the operation. An `error::type-error` is returned if the key contains a value of the wrong type or contains a string that can not be represented as integer. Raises: `spin_sdk.wit.types.Err(spin_sdk.wit.imports.redis.Error)` """ raise NotImplementedError def del_(self, keys: List[str]) -> int: """ Removes the specified keys. A key is ignored if it does not exist. Returns the number of keys deleted. Raises: `spin_sdk.wit.types.Err(spin_sdk.wit.imports.redis.Error)` """ raise NotImplementedError def sadd(self, key: str, values: List[str]) -> int: """ Add the specified `values` to the set named `key`, returning the number of newly-added values. Raises: `spin_sdk.wit.types.Err(spin_sdk.wit.imports.redis.Error)` """ raise NotImplementedError def smembers(self, key: str) -> List[str]: """ Retrieve the contents of the set named `key`. Raises: `spin_sdk.wit.types.Err(spin_sdk.wit.imports.redis.Error)` """ raise NotImplementedError def srem(self, key: str, values: List[str]) -> int: """ Remove the specified `values` from the set named `key`, returning the number of newly-removed values. Raises: `spin_sdk.wit.types.Err(spin_sdk.wit.imports.redis.Error)` """ raise NotImplementedError def execute(self, command: str, arguments: List[RedisParameter]) -> List[RedisResult]: """ Execute an arbitrary Redis command and receive the result. Raises: `spin_sdk.wit.types.Err(spin_sdk.wit.imports.redis.Error)` """ raise NotImplementedError def __enter__(self): """Returns self""" return self def __exit__(self, *args): """ Release this resource. """ raise NotImplementedError
Static methods
def open(address: str) ‑> Self
-
Expand source code
@classmethod def open(cls, address: str) -> Self: """ Open a connection to the Redis instance at `address`. Raises: `spin_sdk.wit.types.Err(spin_sdk.wit.imports.redis.Error)` """ raise NotImplementedError
Methods
def del_(self, keys: List[str]) ‑> int
-
Removes the specified keys.
A key is ignored if it does not exist. Returns the number of keys deleted.
Expand source code
def del_(self, keys: List[str]) -> int: """ Removes the specified keys. A key is ignored if it does not exist. Returns the number of keys deleted. Raises: `spin_sdk.wit.types.Err(spin_sdk.wit.imports.redis.Error)` """ raise NotImplementedError
def execute(self, command: str, arguments: List[Union[RedisParameter_Int64, RedisParameter_Binary]]) ‑> List[Union[RedisResult_Nil, RedisResult_Status, RedisResult_Int64, RedisResult_Binary]]
-
Expand source code
def execute(self, command: str, arguments: List[RedisParameter]) -> List[RedisResult]: """ Execute an arbitrary Redis command and receive the result. Raises: `spin_sdk.wit.types.Err(spin_sdk.wit.imports.redis.Error)` """ raise NotImplementedError
def get(self, key: str) ‑> Optional[bytes]
-
Expand source code
def get(self, key: str) -> Optional[bytes]: """ Get the value of a key. Raises: `spin_sdk.wit.types.Err(spin_sdk.wit.imports.redis.Error)` """ raise NotImplementedError
def incr(self, key: str) ‑> int
-
Increments the number stored at key by one.
If the key does not exist, it is set to 0 before performing the operation. An
error::type-error
is returned if the key contains a value of the wrong type or contains a string that can not be represented as integer.Expand source code
def incr(self, key: str) -> int: """ Increments the number stored at key by one. If the key does not exist, it is set to 0 before performing the operation. An `error::type-error` is returned if the key contains a value of the wrong type or contains a string that can not be represented as integer. Raises: `spin_sdk.wit.types.Err(spin_sdk.wit.imports.redis.Error)` """ raise NotImplementedError
def publish(self, channel: str, payload: bytes) ‑> None
-
Expand source code
def publish(self, channel: str, payload: bytes) -> None: """ Publish a Redis message to the specified channel. Raises: `spin_sdk.wit.types.Err(spin_sdk.wit.imports.redis.Error)` """ raise NotImplementedError
def sadd(self, key: str, values: List[str]) ‑> int
-
Add the specified
values
to the set namedkey
, returning the number of newly-added values.Expand source code
def sadd(self, key: str, values: List[str]) -> int: """ Add the specified `values` to the set named `key`, returning the number of newly-added values. Raises: `spin_sdk.wit.types.Err(spin_sdk.wit.imports.redis.Error)` """ raise NotImplementedError
def set(self, key: str, value: bytes) ‑> None
-
Expand source code
def set(self, key: str, value: bytes) -> None: """ Set key to value. If key already holds a value, it is overwritten. Raises: `spin_sdk.wit.types.Err(spin_sdk.wit.imports.redis.Error)` """ raise NotImplementedError
def smembers(self, key: str) ‑> List[str]
-
Expand source code
def smembers(self, key: str) -> List[str]: """ Retrieve the contents of the set named `key`. Raises: `spin_sdk.wit.types.Err(spin_sdk.wit.imports.redis.Error)` """ raise NotImplementedError
def srem(self, key: str, values: List[str]) ‑> int
-
Remove the specified
values
from the set namedkey
, returning the number of newly-removed values.Expand source code
def srem(self, key: str, values: List[str]) -> int: """ Remove the specified `values` from the set named `key`, returning the number of newly-removed values. Raises: `spin_sdk.wit.types.Err(spin_sdk.wit.imports.redis.Error)` """ raise NotImplementedError
class Error_InvalidAddress
-
Error_InvalidAddress()
Expand source code
@dataclass class Error_InvalidAddress: pass
class Error_Other (value: str)
-
Error_Other(value: str)
Expand source code
@dataclass class Error_Other: value: str
Class variables
var value : str
class Error_TooManyConnections
-
Error_TooManyConnections()
Expand source code
@dataclass class Error_TooManyConnections: pass
class Error_TypeError
-
Error_TypeError()
Expand source code
@dataclass class Error_TypeError: pass
class RedisParameter_Binary (value: bytes)
-
RedisParameter_Binary(value: bytes)
Expand source code
@dataclass class RedisParameter_Binary: value: bytes
Class variables
var value : bytes
class RedisParameter_Int64 (value: int)
-
RedisParameter_Int64(value: int)
Expand source code
@dataclass class RedisParameter_Int64: value: int
Class variables
var value : int
class RedisResult_Binary (value: bytes)
-
RedisResult_Binary(value: bytes)
Expand source code
@dataclass class RedisResult_Binary: value: bytes
Class variables
var value : bytes
class RedisResult_Int64 (value: int)
-
RedisResult_Int64(value: int)
Expand source code
@dataclass class RedisResult_Int64: value: int
Class variables
var value : int
class RedisResult_Nil
-
RedisResult_Nil()
Expand source code
@dataclass class RedisResult_Nil: pass
class RedisResult_Status (value: str)
-
RedisResult_Status(value: str)
Expand source code
@dataclass class RedisResult_Status: value: str
Class variables
var value : str