Metadata-Version: 2.4
Name: redis-http-client
Version: 0.1.7
Summary: A Redis client over HTTP supporting both sync (requests) and async (aiohttp) modes.
Author-email: victor <xianyu.wu@innodealing.com>
License: MIT
Project-URL: Homepage, http://git.innodealing.cn/dm_spider_service/redis-http-client.git
Project-URL: Source, http://git.innodealing.cn/dm_spider_service/redis-http-client.git
Project-URL: Issues, http://git.innodealing.cn/dm_spider_service/redis-http-client.git/issues
Keywords: redis,http,client,asyncio,requests,aiohttp
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: Implementation :: CPython
Classifier: Operating System :: OS Independent
Classifier: Topic :: Database
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.8
Description-Content-Type: text/markdown
Requires-Dist: aiohttp>=3.9.0
Requires-Dist: requests>=2.31.0
Requires-Dist: urllib3>=2.0.0
Requires-Dist: loguru>=0.7.0
Provides-Extra: dev
Requires-Dist: build>=1.2.1; extra == "dev"
Requires-Dist: twine>=5.1.0; extra == "dev"

# redis-http-client

A lightweight Redis client over HTTP, supporting both async (`aiohttp`) and sync (`requests`) execution modes.

## Features

- Async mode based on `aiohttp`
- Sync mode based on `requests`
- Dynamic Redis command proxy via `__getattr__`
- Pipeline support (`redis_pipeline_async` / `redis_pipeline_sync`)
- Built-in retry and connection-pool handling

## Installation

```bash
pip install redis-http-client
```

## Quick Start

### Async

```python
import asyncio
from redis_http_client import RedisHttpClient


async def main():
    client = RedisHttpClient(
        spider_redis_manager_service_url="http://127.0.0.1:8000",
        mode="async",
    )

    result = await client.get("my_key")
    print(result)

    await client.close()


asyncio.run(main())
```

### Async With Bounded Concurrency

```python
client = RedisHttpClient(
    spider_redis_manager_service_url="http://127.0.0.1:8000",
    mode="async",
    limit=50,
    max_concurrency=15,
    max_retries=3,
    connect_timeout=3,
    sock_connect_timeout=3,
    sock_read_timeout=10,
    total_timeout=15,
    strict=False,
)
```

`limit` controls the aiohttp connector pool size. `max_concurrency`
controls how many HTTP requests may be in flight at the same time per
client instance.

The concurrency, timeout, and retry options above apply to async mode.
Sync mode keeps the requests session behavior for backward compatibility.
`strict` controls dynamic Redis commands such as `await client.get("key")`.
Pipeline methods keep raising `RedisHttpClientError` on invalid responses.

### Sync

```python
from redis_http_client import RedisHttpClient

client = RedisHttpClient(
    spider_redis_manager_service_url="http://127.0.0.1:8000",
    mode="sync",
)

result = client.get("my_key")
print(result)

# sync mode reuses internal requests session; close when done
import asyncio
asyncio.run(client.close())
```

### Pipeline

```python
commands = [
    {"command": "GET", "args": ["k1"], "kwargs": {}},
    {"command": "GET", "args": ["k2"], "kwargs": {}},
]

# async
# results = await client.redis_pipeline_async(commands)

# sync
# results = client.redis_pipeline_sync(commands)
```

## Build

```bash
python -m pip install --upgrade build twine
python -m build
```

Build outputs are generated in `dist/`.

## Upload To PyPI

### 1. TestPyPI (recommended first)

```bash
twine check dist/*
twine upload -r testpypi dist/*
```

### 2. PyPI

```bash
twine upload dist/*
```

You can use API token authentication:

- username: `__token__`
- password: `pypi-xxxx...`

## Versioning

Current version: `0.1.6`

When releasing a new version:

1. Update `version` in `pyproject.toml`
2. Update `__version__` in `redis_http_client/__init__.py`
3. Rebuild and upload

## License

MIT
