rename class RedisStore -> RedisDB (uniform <Backend>DB naming); v0.1.1
Signed-off-by: disqualifier <dev@disqualifier.me>
This commit is contained in:
@@ -7,34 +7,34 @@ datastore trio (`redis` / `psql` / `mysql`), a sibling of the `mongo` lib.
|
||||
> **Import name ≠ repo name.** The repo/distribution is **`redis`**, but you import
|
||||
> **`redis_store`** — the driver package owns the `redis` import namespace, so the lib
|
||||
> can't also be `redis`. Install resolves `redis.git`; code does
|
||||
> `from redis_store import RedisStore`.
|
||||
> `from redis_store import RedisDB`.
|
||||
|
||||
## Install
|
||||
|
||||
`requirements.txt`:
|
||||
|
||||
```
|
||||
redis_store @ git+ssh://git@git.rethinkstudios.io/rethink-public/redis.git@v0.1.0
|
||||
redis_store @ git+ssh://git@git.rethinkstudios.io/rethink-public/redis.git@v0.1.1
|
||||
```
|
||||
|
||||
Direct:
|
||||
|
||||
```bash
|
||||
pip install "redis_store @ git+ssh://git@git.rethinkstudios.io/rethink-public/redis.git@v0.1.0"
|
||||
pip install "redis_store @ git+ssh://git@git.rethinkstudios.io/rethink-public/redis.git@v0.1.1"
|
||||
```
|
||||
|
||||
Pulls `redis>=5` (redis-py, which ships the asyncio client — **not** the dead standalone
|
||||
`aioredis`).
|
||||
|
||||
Drop the `@v0.1.0` suffix from the line above to install the latest unpinned.
|
||||
Drop the `@v0.1.1` suffix from the line above to install the latest unpinned.
|
||||
|
||||
## Usage
|
||||
|
||||
```python
|
||||
from redis_store import RedisStore
|
||||
from redis_store import RedisDB
|
||||
|
||||
# construction is sync and opens no socket; connect() pings to fail loud on bad config
|
||||
kv = await RedisStore(host="localhost", port=6379, db=0, password=None).connect()
|
||||
kv = await RedisDB(host="localhost", port=6379, db=0, password=None).connect()
|
||||
|
||||
await kv.set("user:1:name", "ada", ex=3600) # ex = ttl seconds (optional)
|
||||
name = await kv.get("user:1:name") # "ada" (None if absent)
|
||||
@@ -50,7 +50,7 @@ await kv.close() # on shutdown
|
||||
Context-manager form:
|
||||
|
||||
```python
|
||||
async with RedisStore(host="localhost") as kv:
|
||||
async with RedisDB(host="localhost") as kv:
|
||||
await kv.incr("hits")
|
||||
```
|
||||
|
||||
|
||||
Reference in New Issue
Block a user