Skip to content

c4geeks/valkey-demo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

valkey-demo

Companion code for Install Valkey on Ubuntu (Redis Replacement) on ComputingForGeeks.

A small FastAPI service that uses Valkey (a drop-in Redis replacement) for:

  • Cache-aside over a slow Postgres query (519 ms to 0.71 ms in testing)
  • Rate limiting (fixed-window, INCR + EXPIRE)
  • Sessions (keys with a TTL)

It connects with the standard redis-py client, unchanged, to show Valkey is wire-compatible with Redis.

Run it

docker compose up -d
python3 -m venv .venv && . .venv/bin/activate
pip install -r requirements.txt
uvicorn app:app --host 127.0.0.1 --port 8000

Then:

curl -s http://127.0.0.1:8000/products/1   # MISS -> Postgres
curl -s http://127.0.0.1:8000/products/1   # HIT  -> Valkey

Watch the live traffic with valkey-cli monitor in another terminal.

License

MIT

About

Companion repo for the ComputingForGeeks guide: Install Valkey on Ubuntu (Redis replacement). FastAPI cache-aside, rate limiting, sessions.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages