New from O’Reilly: The memory architecture behind adaptive AI agents

Read the report
For developersGetting Started
Fallback Image
Prasan Kumar
Will Johnston
Will Johnston

Welcome to the getting started for the official Redis Developer Hub!

If you are new to Redis, we recommend starting with Redis University (RU101). RU101 is an introductory course, perfect for developers new to Redis. In this course, you’ll learn about the data structures in Redis, and you’ll see how to practically apply them in the real world.

If you have questions related to Redis, come join the Redis Discord server. Our Discord server is a place where you can learn, share, and collaborate about anything and everything Redis. Connect with users from the community and Redis University. Get your questions answered and learn cool new tips and tricks! Watch for notifications of the latest content from Redis and the community. And share your own content with the community.

Setup Redis

There are essentially two ways you can use Redis:

  • Cloud Redis: A hosted and serverless Redis database-as-a-service (DBaaS). The fastest way to deploy Redis Cloud via Amazon AWS, Google Cloud Platform, or Microsoft Azure.
  • On-prem/local Redis: Self-managed Redis using your own server and any operating system (Mac OS, Windows, or Linux).

If you choose to use local Redis we strongly recommend using Docker. If you choose not to use Docker, use the following instructions based on your OS:

Docker

The docker run command below exposes redis-server on port 6379 and RedisInsight on port 8001. You can use RedisInsight by pointing your browser to http://localhost:8001.

You can use redis-cli to connect to the server at localhost:6379. If you don’t have redis-cli installed locally, you can run it from the Docker container like below:

Linux

Using APT with Ubuntu/Debian

Works with Ubuntu 16.04, 18.04, or 20.04 and Debian 11

From the official RPM Feed

Works with RHEL7/CentOS7 or RHEL8/CentOS8

Create the file /etc/yum.repos.d/redis.repo with the following contents:

With snap

Download the latest Redis Stack snap package.

To install, run:

With AppImage

Download the latest Redis Stack AppImage package.

To enable the install, run:

To install run:

Windows

Redis is not officially supported on Windows, so we recommend using Docker.

Please follow the Docker instructions, or watch the following video that covers using Redis through WSL on Windows.

Mac OS

Basic Querying with Redis

CLI

  • Connect to Redis using CLI or RedisInsight (a GUI tool to visualize data & run commands)

RedisInsight

Image

  • Basic CLI / RedisInsight workbench commands

Detailed CLI instructions can be viewed here and commands can be checked here

Javascript

Additional Resources

  1. node-redis Github repo
  2. Node.js Redis Crash Course
  3. JavaScript/NodeJS apps on the Redis Launchpad

Python

  • For more information, checkout the

Additional Resources

  1. redis-py Github repo
  2. Python apps on the Redis Launchpad

C#

The .NET Community has built many client libraries to help handle requests to Redis Server. In this guide, we'll mostly be concerned with using the StackExchange.Redis client library. As the name implies the StackExchange client is developed by StackExchange for use on popular websites like StackOverflow.

Additional Resources

  1. StackExchange.Redis Github repo
  2. C# apps on the Redis Launchpad

Secondary Indexing and Searching with Redis

CLI

Redis Stack enables the JSON data type in Redis.

More details can be found in the Redis Stack docs

Redis Stack enables a query and indexing engine for Redis, providing secondary indexing, full-text search and aggregations capabilities.

  • We have to create index on schema to be able to search on its data
  • More details on Indexing JSON can be found here

Once index is created, any pre-existing/ new/ modified JSON document is automatically indexed.

  • Search
  • Search & project required fields

More details on query syntax

  • Drop index

Useful Resources

  1. Redis and JSON explained (Revisited in 2022) video
  2. Searching with Redis Stack
  3. Redis University 204, Storing, Querying, and Indexing JSON at Speed

Javascript

The following example uses Redis OM Node, but you can also use Node RedisIO Redis, or any other supported client

  • create RedisOM Client & connect to redis
  • Create Entity, Schema & Repository
  • Insert example
  • Read example
  • Update example
  • Update location sample
  • Search examples
  • Delete example

Useful Resources

  1. Github repo
  2. Getting started docs
  3. Getting started video

Python

The following example uses Redis OM Python, but you can also use redis-py or any other supported client

Create a JSON model

  • Insert example
  • Read example
  • Update example
  • Update embedded JSON example
  • Search examples
  • Delete example

Useful Resources

  1. Github repo
  2. Getting started docs
  3. Getting started video

C#

The following example uses Redis OM .NET, but you can also use any other supported client. The examples also use the synchronous methods of Redis OM .NET, but it is recommended that you use the asynchronous methods in a production application.

  • Create a JSON model
  • Setup your main program

The rest of the code will be inside of Main.

  • Create your provider used to call into Redis
  • Conditionally create index necessary for searching
  • Initialize your collection
  • Insert example
  • Read example
  • Update example
  • Update location example
  • Search examples
  • Delete example

Useful Resources

  1. Github repo
  2. Getting started docs
  3. Getting started video

Probabilistic Data and Queries with Redis

Redis Stack supports probabilistic datatypes and queries. Below you will find a stock leaderboard example:

More details in docs

TimeSeries Data and Queries with Redis

Redis Stack supports time-series use cases such as IoT, stock prices, and telemetry. You can ingest and query millions of samples and events at the speed of Redis. You can also use a variety of queries for visualization and monitoring with built-in connectors to popular tools like Grafana, Prometheus, and Telegraf.

The following example demonstrates how you might store temperature sensor readings in Redis Stack:

More details in docs

Additional Resources