Redis Getting Started

Redis (Remote Dictionary Server) is a super-fast, in-memory database used for caching, real-time analytics, messaging, and more. Think of it as a key-value store that keeps data in memory instead of on disk, making it lightning-fast. Developers love Redis because it supports data types like strings, hashes, lists, and sets, allowing for a variety of use cases.

Why Redis?

Redis is widely used in modern applications, including:

  • Caching: Speeds up applications by storing frequently used data in memory.
  • Session Management: Keeps track of user sessions in web applications.
  • Messaging: Works as a publish/subscribe system for real-time notifications.
  • Rate Limiting: Helps prevent excessive API requests from users.
  • Leaderboard & Analytics: Great for ranking users in gaming apps or counting events in real-time.

How to Install Redis on Rocky Linux

Option 1: Install from the Package Repository (Easiest Way)

Rocky Linux, which is based on RHEL (Red Hat Enterprise Linux), makes it easy to install Redis using its package manager.

Step 1: Update System Packages

sudo dnf update -y

This ensures you get the latest software versions.

Step 2: Install Redis

sudo dnf install -y redis

This downloads and installs Redis from Rocky Linux’s official repository.

Step 3: Start and Enable Redis

sudo systemctl enable --now redis

This makes sure Redis starts automatically whenever the server reboots.

Step 4: Check If Redis is Running

systemctl status redis

If everything is working, you should see Redis running in the output.

Step 5: Test Redis

redis-cli ping

If Redis is working correctly, it should return:

PONG

Option 2: Install Redis from Source (For Latest Version)

If you want the absolute latest version or need custom settings, you can build Redis from source.

Step 1: Install Required Tools

sudo dnf groupinstall -y "Development Tools"
sudo dnf install -y gcc make wget tar

Step 2: Download Redis Source Code

wget http://download.redis.io/redis-stable.tar.gz
tar xzf redis-stable.tar.gz
cd redis-stable

Step 3: Compile Redis

make -j$(nproc)

The -j$(nproc) part makes sure all CPU cores are used to speed up the compilation.

Step 4: Install Redis

sudo make install

Step 5: Start Redis Manually

src/redis-server &

Step 6: Test Redis

src/redis-cli ping

If everything is fine, it will reply with PONG.


How to Install Redis on Windows

Redis doesn’t officially support Windows, but you still have two ways to install it:

Option 1: Use Windows Subsystem for Linux (WSL)

This method lets you run Redis on Windows using a Linux environment.

Step 1: Enable WSL

Open PowerShell as Administrator and run:

wsl --install

Restart your computer after installing WSL.

Step 2: Install Redis in WSL

Once WSL is set up, open a terminal and run:

sudo apt update && sudo apt install -y redis

Step 3: Start Redis

sudo service redis-server start

Step 4: Check Redis

redis-cli ping

If it works, you’ll see PONG.


Option 2: Use Memurai (Redis Alternative for Windows)

Since Redis doesn’t natively run on Windows anymore, Memurai is the best alternative.

Step 1: Download Memurai

Go to Memurai’s website and download the installer.

Step 2: Install and Run Memurai

Follow the setup instructions and start the Memurai service.

Step 3: Test Redis Commands

Open Command Prompt and type:

redis-cli.exe ping

If it works, you’ll see PONG.


Redis is a powerful tool that makes applications faster and more efficient. Whether you install it from the package manager, compile it from source, or run it on Windows using WSL or Memurai, getting Redis up and running is straightforward. If you’re building a high-performance app, Redis is definitely worth considering! 🚀

Leave a Comment

Share this