prefect.blocks.redis
RedisStorageContainer
Bases: WritableFileSystem
Block used to interact with Redis as a filesystem
Attributes:
Name | Type | Description |
---|---|---|
host |
str
|
The value to store. |
port |
int
|
The value to store. |
db |
int
|
The value to store. |
username |
str
|
The value to store. |
password |
str
|
The value to store. |
connection_string |
str
|
The value to store. |
Example
Create a new block from hostname, username and password:
from prefect.blocks.redis import RedisStorageContainer
block = RedisStorageContainer.from_host(
host="myredishost.com", username="redis", password="SuperSecret")
block.save("BLOCK_NAME")
Create a new block from a connection string
from prefect.blocks.redis import RedisStorageContainer
block = RedisStorageContainer.from_url(""redis://redis:SuperSecret@myredishost.com:6379")
block.save("BLOCK_NAME")
Source code in src/prefect/blocks/redis.py
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 |
|
from_connection_string(connection_string)
classmethod
Create block from a Redis connection string
Supports the following URL schemes:
- redis://
creates a TCP socket connection
- rediss://
creates a SSL wrapped TCP socket connection
- unix://
creates a Unix Domain Socket connection
See Redis docs for more info.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
connection_string
|
Union[str, SecretStr]
|
Redis connection string |
required |
Returns:
Type | Description |
---|---|
Self
|
|
Source code in src/prefect/blocks/redis.py
142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 |
|
from_host(host, port=6379, db=0, username=None, password=None)
classmethod
Create block from hostname, username and password
Parameters:
Name | Type | Description | Default |
---|---|---|---|
host
|
str
|
Redis hostname |
required |
username
|
Union[None, str, SecretStr]
|
Redis username |
None
|
password
|
Union[None, str, SecretStr]
|
Redis password |
None
|
port
|
int
|
Redis port |
6379
|
Returns:
Type | Description |
---|---|
Self
|
|
Source code in src/prefect/blocks/redis.py
116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 |
|
read_path(path)
async
Read the redis content at path
Parameters:
Name | Type | Description | Default |
---|---|---|---|
path
|
Union[Path, str]
|
Redis key to read from |
required |
Returns:
Type | Description |
---|---|
Contents at key as bytes |
Source code in src/prefect/blocks/redis.py
72 73 74 75 76 77 78 79 80 81 82 83 |
|
write_path(path, content)
async
Write content
to the redis at path
Parameters:
Name | Type | Description | Default |
---|---|---|---|
path
|
Union[Path, str]
|
Redis key to write to |
required |
content
|
bytes
|
Binary object to write |
required |
Source code in src/prefect/blocks/redis.py
85 86 87 88 89 90 91 92 93 94 95 |
|