Get started

Get Redis running and connect your first application, however you deploy it.

Redis can be used as a database, cache, streaming engine, message broker, context engine, feature platform, and more. In this guide, you'll learn how to create a Redis deployment in Redis Open Source, Redis Cloud, or Redis Software. Then, you'll learn how to create an application that connects to your deployment.

Create a Redis deployment

This section shows how to set up a Redis deployment and connect to it with redis-cli.

  1. Install dependencies

  2. Set up a fully-featured deployment

    Redis Open Source is the free, self-managed core Redis server. The fastest way to run it is with Docker:

    docker run -d --name redis -p 6379:6379 redis:latest
    

    Starting the server creates your database — there's no separate create step. See Run Redis on Docker for the full procedure, or Install Redis on Linux, macOS, or from source to install without Docker.

  3. Connect to your deployment

    If you started Redis with the docker run command from step 2 then you can connect to the database with the following command:

    docker exec -it redis redis-cli
    

    See Redis CLI for the full procedure, including non-Docker installs and Redis Insight as a GUI alternative to the CLI.

Congratulations! You have successfully set up your Redis deployment and connected to it.

In the next section, you'll learn how to create an application that connects to your deployment and interacts with data.

Create your first Redis application

To connect to your Redis deployment in an application, you can use one of the official Redis client libraries.

  1. Initialize your application

    Create a project directory and install redis-py:

    mkdir python-quickstart
    cd python-quickstart
    pip install redis
    
  2. Create your application

    Copy the following code into app.py. This connects to your database and sets and retrieves a value.

    import redis
    
    r = redis.Redis(host='localhost', port=6379, decode_responses=True)
    
    r.set('bike:1', 'Process 134')
    print(r.get('bike:1'))
    
  3. Add your connection string

    The examples in step 2 connect to localhost:6379, which works as is if you're running Redis Open Source locally. Otherwise, replace it with your deployment's host, port, and password from the Redis Cloud connection wizard or the Redis Software connection details.

       r = redis.from_url("redis://default:<password>@<host>:<port>")
    
  4. Run your application

       python app.py
    

    Each program prints Process 134 — the value you stored and then retrieved. (RedisVL's example instead confirms the index was created.)

  5. Explore a use case

    Each of the following quick starts shows a complete example application for a specific use case:

    Refer to the Redis use cases page for a complete set of use cases with code examples in your programming language.

Next steps

To learn more about developing with Redis, see the following resources:

RATE THIS PAGE
Back to top ↑