Skip to content
Star
478
Star
478

Redis

This guide shows you how to work with Redis locally using Docker and Python. This lab demonstrates how to manage user status using Redis and a custom context manager for connection management.

  1. Setup Environment:

    Open VS Code in the project folder and execute this command in the Command Palette:

    Terminal window
    > Dev Containers: Reopen in Container
  2. Run the Example:

    Terminal window
    python main.py
  1. main.py:

    • Open: Open main.py.
    • Breakpoints: Set breakpoints in the code.
    • Run: Press F5 to start debugging.
  2. Tests:

    • Open: Open a test file (e.g., tests/providers/test_redis_client.py).
    • Breakpoints: Set breakpoints in the test code.
    • Run: Use the VS Code Testing tab and click the Debug Test icon next to the test you want to debug.
  • All tests: Run the automated script:
    Terminal window
    scripts/run_tests.sh
  • Individually: Use the VS Code Testing tab to run or debug specific test cases.
  1. Enter Shell:
    Terminal window
    scripts/redis_cli.sh
  2. Check the stored status:
    Terminal window
    GET raulcastillabravo:status
Terminal window
docker compose down -v