Document new storage back-end

This commit is contained in:
Luke Murphy 2021-01-15 21:13:17 +01:00
parent 71493c4732
commit c2a0b5c326
No known key found for this signature in database
GPG Key ID: 5E2EF5A63E3718CC

View File

@ -161,6 +161,31 @@ deployments.
See [bots.varia.zone](https://bots.varia.zone/). See [bots.varia.zone](https://bots.varia.zone/).
## Persistent storage
## Redis key/value
`xbotlib` supports using [Redis](https://redis.io/) as a storage back-end. It
is simple to work with because the interface is exactly like a dictionary. Here
is how to quickly run Redis locally (using
[Docker](https://docs.docker.com/engine/install/debian/)).
```bash
$ docker run --network=host --name redis -d redis
$ export REDIS_URL=redis://localhost:6379/0
```
And you access the interface via the `self.db` attribute.
```python
def direct(self, message):
self.db["my-message"] = message.body
```
You should see `INFO Successfully connected to storage` when your bot
initialises. Please see the `GlossBot` example for more on how to work with
this type of storage.
## Roadmap ## Roadmap
See the [issue tracker](https://git.autonomic.zone/decentral1se/xbotlib/issues). See the [issue tracker](https://git.autonomic.zone/decentral1se/xbotlib/issues).