Redis

High-performance in-memory database for caching, data structures, and search.

Access

You can access Redis at redis://localhost:6379

Interactive shell access example:

redis-cli
127.0.0.1:6379> set example "Hello Redis"
127.0.0.1:6379> get example
"Hello Redis"

Important Files and Directories

  • /etc/redis/redis.conf → Main configuration file
  • /var/lib/redis/ → Data directory for persistence
  • /var/log/redis/redis-server.log → Log file
  • /usr/bin/redis-cli → Redis command-line tool
  • /usr/bin/redis-server → Redis daemon binary

Service Management

Common service operations:

systemctl restart redis-server   # Restart Redis
systemctl stop redis-server      # Stop Redis
systemctl status redis-server    # View Redis status

Configuration

Redis configuration file: /etc/redis/redis.conf

  • bind — Controls which network interfaces Redis listens on.
  • protected-mode — Must be disabled if you allow remote access.
  • requirepass — Set a password for client authentication.
  • maxmemory — Limit RAM usage (for caching use cases).
  • appendonly — Enable AOF persistence.

After making any change:

systemctl restart redis-server

Useful Tools and Commands

Redis includes several built-in tools:

  • redis-cli → Command-line interface for Redis
  • redis-benchmark → Benchmarking utility
  • redis-check-aof and redis-check-rdb → Validate AOF/RDB persistence files
  • redis-server → Manual start of the Redis daemon

Logs and Monitoring

Check logs:

journalctl -u redis-server -f

Monitor activity:

redis-cli monitor

View connected clients:

redis-cli client list

Persistence Modes

Redis supports two persistence options:

  1. RDB snapshots → Saves database state at intervals (lightweight).
  2. AOF (Append Only File) → Logs every write (safer but larger).

You can enable both in /etc/redis/redis.conf for durability.

Application Details