Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/redis/redis/llms.txt

Use this file to discover all available pages before exploring further.

This quickstart guide will help you start a Redis server, connect to it, and run your first commands.

Prerequisites

This guide assumes you have Redis installed. If you haven’t installed Redis yet, see the installation guide.
The fastest way to get started is using Docker:
docker run -d -p 6379:6379 redis:latest

Start the Redis server

1

Navigate to the Redis directory

If you built Redis from source, navigate to your Redis installation directory:
cd /usr/src/redis-<version>
Replace <version> with your Redis version (e.g., 8.0.0).
2

Start the server

Launch Redis server with the default configuration:
./src/redis-server
For a Redis instance with all data structures enabled:
./src/redis-server redis-full.conf
You should see output indicating Redis is running:
[####] Server initialized
[####] Ready to accept connections
3

Verify the server is running

The server will start on port 6379 by default. Keep this terminal window open.

Connect with redis-cli

redis-cli is Redis’ command line interface, available as part of all Redis installations.
1

Open a new terminal

Keep your Redis server running in the original terminal and open a new terminal window.
2

Launch redis-cli

Navigate to the Redis source directory and start the CLI:
cd src
./redis-cli
You’ll see the Redis prompt:
redis>
3

Test the connection

Try the PING command to verify connectivity:
redis> ping
Expected response:
PONG

Run basic commands

Now that you’re connected, let’s try some fundamental Redis operations.

Store and retrieve data

Use SET to store a value and GET to retrieve it:
redis> set foo bar
OK

Work with counters

Redis excels at atomic operations like incrementing counters with INCR:
redis> incr mycounter
(integer) 1
redis> incr mycounter
(integer) 2

Store multiple values

Set multiple key-value pairs at once with MSET:
redis> mset key1 "Hello" key2 "World"
OK
redis> mget key1 key2
1) "Hello"
2) "World"

Work with expiration

Set a key with an expiration time using SETEX:
redis> setex session:user:123 3600 "user-data"
OK
redis> ttl session:user:123
(integer) 3600
This sets a key that expires in 3600 seconds (1 hour).

Explore data structures

Redis supports rich data structures beyond simple key-value pairs.

Lists

Use lists for queues and stacks:
redis> lpush mylist "world"
(integer) 1
redis> lpush mylist "hello"
(integer) 2
redis> lrange mylist 0 -1
1) "hello"
2) "world"

Sets

Track unique items with sets:
redis> sadd myset "apple"
(integer) 1
redis> sadd myset "banana"
(integer) 1
redis> sadd myset "apple"
(integer) 0
redis> smembers myset
1) "apple"
2) "banana"

Hashes

Store objects as hashes:
redis> hset user:1000 name "John Doe" email "john@example.com" age 30
(integer) 3
redis> hget user:1000 name
"John Doe"
redis> hgetall user:1000
1) "name"
2) "John Doe"
3) "email"
4) "john@example.com"
5) "age"
6) "30"

Sorted Sets

Build leaderboards with sorted sets:
redis> zadd leaderboard 100 "player1"
(integer) 1
redis> zadd leaderboard 200 "player2"
(integer) 1
redis> zadd leaderboard 150 "player3"
(integer) 1
redis> zrevrange leaderboard 0 -1 withscores
1) "player2"
2) "200"
3) "player3"
4) "150"
5) "player1"
6) "100"

Configuration options

Redis can be configured via the command line or using a configuration file.
./redis-server /path/to/redis.conf
The default Redis configuration binds to 127.0.0.1 -::1 (localhost only) for security. To accept connections from other hosts, you’ll need to modify the bind directive in redis.conf.

Test your installation

After building Redis from source, it’s recommended to run the test suite:
make test
If you built with TLS support, test with TLS enabled:
./utils/gen-test-certs.sh
./runtest --tls
You’ll need tcl-tls installed to run TLS tests.

Alternative tools

Redis Insight

For a more visual experience, use Redis Insight—a tool that lets you explore data, design, and optimize your applications. Redis Insight integrates Redis Copilot, a natural language AI assistant.

Client libraries

Connect your application to Redis using client libraries in your preferred language:

Next steps

Introduction to Redis data types

Learn about all available data types

Full command reference

Explore the complete Redis command set

Redis for AI

Use Redis for AI and ML applications

Starter projects

Browse language-specific starter projects