> ## Documentation Index
> Fetch the complete documentation index at: https://phidatainc-studio-tools-doc.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Memory with Redis

## Code

```python mem-redis-memory.py theme={null}
from agno.agent import Agent
from agno.db.redis import RedisDb

# Setup Redis
# Initialize Redis db (use the right db_url for your setup)
db = RedisDb(db_url="redis://localhost:6379")

# Create agent with Redis db
agent = Agent(
    db=db,
    update_memory_on_run=True,
)

agent.print_response("My name is John Doe and I like to play basketball on the weekends.")
agent.print_response("What's do I do in weekends?")
```

## Usage

<Steps>
  <Snippet file="create-venv-step.mdx" />

  <Step title="Set environment variables">
    ```bash theme={null}
    export OPENAI_API_KEY=xxx
    ```
  </Step>

  <Step title="Install dependencies">
    ```bash theme={null}
    uv pip install -U agno openai redis
    ```
  </Step>

  <Step title="Run Redis">
    ```bash theme={null}
    docker run --name my-redis -p 6379:6379 -d redis
    ```
  </Step>

  <Step title="Run Example">
    <CodeGroup>
      ```bash Mac/Linux theme={null}
      python mem-redis-memory.py
      ```

      ```bash Windows theme={null}
      python mem-redis-memory.py
      ```
    </CodeGroup>
  </Step>
</Steps>
