2022-02-15 01:35:00 +01:00
# Redis
2018-08-11 12:58:29 +02:00
2022-02-15 01:35:00 +01:00
This project illustrates how to send multiple cache requests to Redis in bulk, asynchronously. This approach resembles traditional Redis pipelining. [See here for more details about this approach. ](https://github.com/benashford/redis-async-rs/issues/19#issuecomment-412208018 )
2018-08-11 12:58:29 +02:00
2022-02-15 01:35:00 +01:00
## Start Server
2018-08-11 12:58:29 +02:00
2022-02-15 01:35:00 +01:00
```sh
2022-02-18 03:13:55 +01:00
cd databases/redis
2022-02-15 01:35:00 +01:00
cargo run
```
2018-08-11 12:58:29 +02:00
2022-02-15 01:35:00 +01:00
## Endpoints
### `POST /stuff`
To test the demo, POST a json object containing three strings to the `/stuff` endpoint:
```json
{
"one": "first entry",
"two": "second entry",
"three": "third entry"
}
```
2018-08-11 12:58:29 +02:00
These three entries will cache to redis, keyed accordingly.
2018-08-11 15:59:07 +02:00
2022-02-15 01:35:00 +01:00
Using [HTTPie]:
```sh
http :8080/stuff one="first entry" two="second entry" three="third entry"
```
Using [cURL]:
```sh
curl localhost:8080/stuff -H 'content-type: application/json' -d '{"one":"first entry","two":"second entry","three":"third entry"}'
```
### `DELETE /stuff`
To delete these, simply issue a DELETE http request to /stuff endpoint
Using [HTTPie]:
```sh
http DELETE :8080/stuff
```
Using [cURL]:
```sh
curl -XDELETE 127.0.0.1:8080/stuff
```
## Verify Redis Contents
At any time, verify the contents of Redis using its CLI:
```sh
echo "MGET mydomain:one mydomain:two mydomain:three" | redis-cli
```
[HTTPie]: https://httpie.org
[cURL]: https://curl.haxx.se