Table of contents
1.
Introduction
2.
Primary Features
3.
Working of RedisGraph
4.
Using Docker
5.
Building the Repository
6.
Using RedisGraph
6.1.
Using Redis-CLI
6.2.
Using Other Clients
7.
RedisGraph Client Libraries
8.
Frequently Asked Questions
8.1.
What is RedisGraph?
8.2.
What does the Cypher programming language do in RedisGraph?
8.3.
How can you interact with RedisGraph with clients other than Redis-CLI?
8.4.
What sets RedisGraph apart from other graph databases?
9.
Conclusion
Last Updated: Aug 13, 2025

Graph and Redis Stack

Author Devansh
0 upvote

Introduction

RedisGraph is a relatively new graph database constructed as a Redis module. It has excellent speed, supports the Cypher query language, and is simple. RedisGraph is a Redis-based graph database. GraphBlas powers this graph database's sparse adjacency matrix graph representation. 

We utilize the Cipher programming language to store and query data in RedisGraph. Cypher, which was developed under the openCypher project after being established by rival Neo4j, employs ASCII art and SQL-like clauses to allow access to graph data. 

Primary Features

Some of the primary features of RedisGraph are:

1. Uses the property graph model.

2. Nodes can have an unlimited number of labels.

3. Relationships are classified according to their relationship type.

4. Sparse adjacency matrices are used to represent graphs.

5. The query language is Cypher.

6. Cypher queries are translated into linear algebra expressions.

Working of RedisGraph

RedisGraph employs the GraphBLAS library, which enables it to store and query graph data in a very compact manner. As a result, benchmarks reveal that RedisGraph surpasses some of its most renowned competitors, which is unexpected considering Redis's reputation for being single-threaded.

While Redis' single thread handles inbound requests, they are then sent to RedisGraph's internal thread pool, which can take several queries simultaneously. A query can only run on a single RedisGraph thread at a time, unlike rival graph databases, which distribute the same query over all system cores. While this may appear paradoxical, it is more suited to handling high throughput and low latency conditions and provides superior performance.

Using Docker

To get a quick preview of RedisGraph, use Docker to launch an instance:

docker run -p 6379:6379 -it --rm redislabs/redisgraph

 

RedisGraph may be interacted with using Redis-cli after it has been loaded.

In this section, we'll quickly develop a small graph depicting a subset of esports players and agents they are picking while participating in a match. We'll begin querying our data after it's been produced.

$ redis-cli
127.0.0.1:6379> GRAPH.QUERY AgentSel "CREATE (:Player {name:'Rossi'})-[:agent]->(:Team {name:'Jett'}), (:Player {name:'Deathmaker'})-[:agent]->(:Team {name:'Raze'}), (:Player {name:'Binks'})-[:agent]->(:Team {name:'Yoru'})"
1) 1) "Labels added: 2"
   2) "Nodes created: 6"
   3) "Properties set: 6"
   4) "Relationships created: 3"
   5) "Cached execution: 0"
   6) "Query internal execution time: 0.399000 milliseconds"

 

Now that our AgentSel graph is created, we can start asking questions. For example: Who is playing Jett?

127.0.0.1:6379> GRAPH.QUERY AgentSel "MATCH (r:Player)-[:agent]->(t:Team) WHERE t.name = 'Jett' RETURN r.name, t.name"
1) 1) "r.name"
   2) "t.name"
2) 1) 1) "Rossi"
      2) "Jett"
3) 1) "Cached execution: 0"
   2) "Query internal execution time: 0.625399 milliseconds"

Building the Repository

1. The RedisGraph repository:

git clone --recurse-submodules -j8 https://github.com/RedisGraph/RedisGraph.git.

 

2. On Ubuntu Linux, run: 

apt-get install build-essential cmake m4 automake peg libtool autoconf.

 

3. On OS X, run

brew install cmake m4 automake peg libtool autoconf

 

to ensure that homebrew is installed.

The Clang version included with the OS X toolchain does not support OpenMP, required for RedisGraph. One solution is running brew install gcc g++ and following the on-screen directions to update the symbolic links. This is a system-wide modification. If that is not an option, updating the environment variables for CC and CXX would suffice.

In the End, Run make in the project's directory to build.

Using RedisGraph

Using Redis-CLI

RedisGraph commands can be executed from any Redis client.

$ redis-cli
127.0.0.1:6379> GRAPH.QUERY social "CREATE (:person {name: 'roi', age: 25, gender: 'male', status: 'unmarried'})"

Using Other Clients

You may interact with RedisGraph by sending raw Redis instructions from your client. The specific procedure relies on your customer of choice. The following code illustrates how to utilize RedisGraph from Python with raw Redis commands using Redis-py:

import redis
r = redis.Redis()
reply = r.graph("social").query("MATCH (r:Player)-[:agent]->(t:Team {name:'Jett'}) RETURN count(r)")

RedisGraph Client Libraries

The community and the RedisGraph team have created language-specific clients for six languages. RedisGraph's complete capability is accessible via Redis-CLI and the Redis API. RedisInsight is a visual tool that combines design, development, and optimization capabilities into a single user-friendly environment, and it includes built-in support for RedisGraph. Other client libraries are available to increase abstractions and provide a more natural experience in a project's native language. Furthermore, these clients make use of various RedisGraph features that, in some cases, may impair network throughput.

Frequently Asked Questions

What is RedisGraph?

RedisGraph is a Redis-based graph database. RedisGraph employs the GraphBLAS library, which enables it to both store and query graph data in a very compact manner.

What does the Cypher programming language do in RedisGraph?

We utilize the Cipher programming language to store and query data in RedisGraph. Cypher employs ASCII art and SQL-like clauses to allow access to graph data. 

How can you interact with RedisGraph with clients other than Redis-CLI?

You may interact with RedisGraph by sending raw Redis instructions from your client. The specific procedure relies on your customer of choice.

What sets RedisGraph apart from other graph databases?

A query can only run on a single RedisGraph thread at a time, unlike rival graph databases, which distribute the same query over all system cores.

Conclusion

This article extensively discussed Graphs in Redis Stack using RedisGraph, its implementation, and features in the multi-platform database systems.

We hope this blog has helped you enhance your knowledge regarding RedisGraph. After reading about the Redis Database, are you not feeling excited to read/explore more articles on this topic? Don't worry; Coding Ninjas has you covered. To learn, see Operating SystemUnix File SystemFile System Routingand File Input/Output.

Refer to our Guided Path on Coding Ninjas Studio to upskill yourself in Data Structures and AlgorithmsCompetitive ProgrammingJavaScriptSystem Design, and many more! If you want to test your competency in coding, you may check out the mock test series and participate in the contests hosted on Coding Ninjas Studio! 

You can also consider our Mern Stack Course to give your career an edge over others.

Do upvote our blogs if you find them helpful and engaging!

 

Happy Learning!

Live masterclass