> ## Documentation Index
> Fetch the complete documentation index at: https://alibi.itsdote.tech/llms.txt
> Use this file to discover all available pages before exploring further.

# alibi_sdk.plugins.redis_plugin

> Redis plugin — generated from python/alibi_sdk source.

Redis plugin — DB index / key-prefix isolation + observation wrappers.

*Source:* [`python/alibi_sdk/alibi_sdk/plugins/redis_plugin.py`](https://github.com/valid22/alibi-ai/blob/main/python/alibi_sdk/alibi_sdk/plugins/redis_plugin.py)

## `RedisPlugin`

**Bases:** `Plugin`

#### `__init__`

```python theme={null}
def __init__(url: Optional[str] = None, prefix: str = 'alibi:', db: int = 1) -> None
```

**Parameters**

| Name | Type |
| - | - |
| `url` | `Optional[str]` |
| `prefix` | `str` |
| `db` | `int` |

**Returns**

`None`

#### `active_prefix`

```python theme={null}
def active_prefix() -> str
```

**Returns**

`str`

#### `active_db`

```python theme={null}
def active_db() -> int
```

**Returns**

`int`

#### `active_url`

```python theme={null}
def active_url() -> str
```

**Returns**

`str`

#### `connect`

```python theme={null}
async def connect() -> Any
```

**Returns**

`Any`

#### `close`

```python theme={null}
async def close() -> None
```

**Returns**

`None`

#### `get`

```python theme={null}
async def get(key: str) -> Any
```

**Parameters**

| Name | Type |
| - | - |
| `key` | `str` |

**Returns**

`Any`

#### `set`

```python theme={null}
async def set(key: str, value: Any, ex: Optional[int] = None) -> bool
```

**Parameters**

| Name | Type |
| - | - |
| `key` | `str` |
| `value` | `Any` |
| `ex` | `Optional[int]` |

**Returns**

`bool`

#### `delete`

```python theme={null}
async def delete(*keys: str) -> int
```

**Returns**

`int`

#### `hset`

```python theme={null}
async def hset(key: str, mapping: dict[str, Any]) -> int
```

**Parameters**

| Name | Type |
| - | - |
| `key` | `str` |
| `mapping` | `dict[str, Any]` |

**Returns**

`int`

#### `hgetall`

```python theme={null}
async def hgetall(key: str) -> dict[str, Any]
```

**Parameters**

| Name | Type |
| - | - |
| `key` | `str` |

**Returns**

`dict[str, Any]`

#### `xadd`

```python theme={null}
async def xadd(key: str, fields: dict[str, Any], id: str = '*', maxlen: Optional[int] = None) -> str
```

Append to a Redis stream (observed as mutation).

**Parameters**

| Name | Type |
| - | - |
| `key` | `str` |
| `fields` | `dict[str, Any]` |
| `id` | `str` |
| `maxlen` | `Optional[int]` |

**Returns**

`str`

#### `xread`

```python theme={null}
async def xread(streams: dict[str, str], count: Optional[int] = None, block: Optional[int] = None) -> list[Any]
```

Read from Redis streams (observed as read). Keys are unprefixed logical names.

**Parameters**

| Name | Type |
| - | - |
| `streams` | `dict[str, str]` |
| `count` | `Optional[int]` |
| `block` | `Optional[int]` |

**Returns**

`list[Any]`

#### `xrange`

```python theme={null}
async def xrange(key: str, start: str = '-', end: str = '+', count: Optional[int] = None) -> list[Any]
```

**Parameters**

| Name | Type |
| - | - |
| `key` | `str` |
| `start` | `str` |
| `end` | `str` |
| `count` | `Optional[int]` |

**Returns**

`list[Any]`

#### `snapshot`

```python theme={null}
async def snapshot(span: SpanContext) -> SnapshotHandle
```

**Parameters**

| Name | Type |
| - | - |
| `span` | `SpanContext` |

**Returns**

`SnapshotHandle`

#### `observe`

```python theme={null}
async def observe(span: SpanContext) -> dict[str, Any]
```

**Parameters**

| Name | Type |
| - | - |
| `span` | `SpanContext` |

**Returns**

`dict[str, Any]`

#### `restore`

```python theme={null}
async def restore(span: SpanContext, handle: SnapshotHandle) -> None
```

**Parameters**

| Name | Type |
| - | - |
| `span` | `SpanContext` |
| `handle` | `SnapshotHandle` |

**Returns**

`None`

### `create_redis_plugin`

```python theme={null}
def create_redis_plugin(url: Optional[str] = None, prefix: str = 'alibi:', db: int = 1) -> RedisPlugin
```

**Parameters**

| Name | Type |
| - | - |
| `url` | `Optional[str]` |
| `prefix` | `str` |
| `db` | `int` |

**Returns**

`RedisPlugin`


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.