1
0
mirror of https://github.com/actix/examples synced 2024-12-12 14:13:11 +01:00
examples/databases/redis
2023-12-26 03:56:28 +00:00
..
src chore: remove deprecated calls 2023-12-26 03:56:28 +00:00
Cargo.toml Bump redis from 0.23.3 to 0.24.0 2023-12-18 17:42:43 +00:00
README.md format markdown 2022-03-06 00:43:10 +00:00

Redis

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.

Start Server

cd databases/redis
cargo run

Endpoints

POST /stuff

To test the demo, POST a json object containing three strings to the /stuff endpoint:

{
  "one": "first entry",
  "two": "second entry",
  "three": "third entry"
}

These three entries will cache to redis, keyed accordingly.

Using HTTPie:

http :8080/stuff one="first entry" two="second entry" three="third entry"

Using cURL:

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:

http DELETE :8080/stuff

Using cURL:

curl -XDELETE 127.0.0.1:8080/stuff

Verify Redis Contents

At any time, verify the contents of Redis using its CLI:

echo "MGET mydomain:one mydomain:two mydomain:three" | redis-cli