Navicat Blog

Getting started with Redis Jun 16, 2023 by Robert Gravelle

Redis is an open source, BSD licensed, advanced key-value store, written in C. It's also referred to as a data structure server, since the keys can contain strings, hashes, lists, sets and sorted sets. This tutorial will provide the fundamentals of Redis concepts needed to start using it right away.

Why Use Redis?

Redis is certainly not the only key-value store to choose from. However, it does offer some advantages over its competitors. For instance:

  • Redis supports more data types than most other key-value data stores. Developers already know most types, including list, set, sorted set, and hashes. This makes it easy to solve problems since developers tend to know which data type to use for a task.
  • Redis holds its database entirely in memory, using the disk only for persistence, making it exceptionally fast. In fact, it can perform about 110,000 SETs per second, about 81,000 GETs per second!
  • Redis can replicate data to any number of slaves.
  • All Redis operations are atomic, which ensures that if two clients concurrently access the same data, Redis server will receive the updated value(s).
  • Redis natively supports Publish/Subscribe, making it ideal for messaging-queues.
  • Redis is well suited for managing any short-lived data in your application, such as web application sessions, web page hit counts, etc.

When Not to Use Redis

Of course, Redis is not without its flaws. It's not your best choice if you need to minimize the chance of data loss in case of outages, such as a sudden loss of power. You can configure multiple save points, such as every five minutes and/or 100 writes against the data set. However should Redis stop working without a proper shutdown for any reason, you should be prepared to lose the latest several minutes of data.

Another issue is that Redis often needs to fork a child process in order to persist data to disk. This can consume a lot of system resources if the dataset is large, and may result in an interruption of service for clients ranging from a few milliseconds to a full second, depending on dataset size and CPU power.

Installing Redis

How you install Redis depends on your operating system and whether you'd like to install it bundled with Redis Stack and Redis UI. The official Redis site has guides for every O/S:

Once you have Redis up and running, and can connect using Navicat for Redis, and continue with the tutorial below.

Exploring the Redis CLI

Navicat for Redis includes a console, which allows you to communicate directly with a database instance:

console (42K)

One advantage to using the CLI in Navicat is that it provides auto-completion on every aspect of CLI commands, including command names as well as their parameters:

auto-complete_in_console (38K)

Conclusion

This tutorial provided the fundamentals of Redis concepts needed to start using it right away. There will be plenty more articles on Redis in the coming weeks, so be sure to check back often!

Navicat Blogs
Feed Entries
Blog Archives
Share