Skip to content

Cypht‐Redis setup

Alfred Syatsukwa edited this page Nov 11, 2025 · 2 revisions

Cypht-Redis: Local data cache to improve performance

Related issue: https://github.com/cypht-org/cypht/issues/1556

Overview

Cypht supports Redis as a caching backend to significantly improve performance for IMAP folder browsing and session management. This integration reduces database load and speeds up frequently accessed data operations.

Current Benefits:

  • Faster IMAP folder list retrieval
  • Improved session management
  • Reduced latency for repeated operations (folders browsing)

Install redis-server

Redis can be installed on Linux, Windows and Mac Os. Here are the instructions.

Check status

Once started, you need to check the status of your redis server using the command below:

redis-cli -h 127.0.0.1 -p 6379 ping

//output
PONG

Connect Cypht to your redis server

Manual Installation (Code/Tarball)

To make Cypht use redis, you need to configure these parameters from your .env file :

ENABLE_REDIS=
REDIS_SERVER=
REDIS_PORT=
REDIS_INDEX=
REDIS_PASS=
REDIS_SOCKET=

Enable redis

You need to have ENABLE_REDIS=true

Redis server

Specify the IP address of your redis server here REDIS_SERVER='127.0.0.1'.

Redis port

By default, redis port is 6379: REDIS_PORT=6379.

Redis Index

The REDIS_INDEX parameter specifies which Redis database index to use for storing Cypht's data. Redis supports multiple logical databases (numbered 0-15 by default) within a single Redis server instance. Each database is completely isolated from others. The index 0 is for the Default database and light be used by other applications. So we skip this. 1-15 is used for additional isolated databases.

So REDIS_INDEX=1 is fine for Cypht.

Redis pass

The REDIS_PASS parameter is for setting the Redis password (authentication) when your Redis server requires a password to connect. This is very recommended in production. For development environment, we often use Redis without authentication.

Redis socket

The REDIS_SOCKET parameter is for connecting to Redis using a Unix socket instead of TCP/IP. Note: A Unix socket is a inter-process communication (IPC) method that allows processes on the same host to communicate without using network protocols.

Using TCP/IP (Default) you don't need to provide a socket, only redis port is needed.

- REDIS_SERVER=127.0.0.1
- REDIS_PORT=6379
- REDIS_SOCKET=

** Session management**

For session management with redis, you need to change session type to redis:

SESSION_TYPE=redis

Using Unix socket

You can check your configured socket value

redis-cli config get unixsocket*

//output
1) "unixsocketperm"
2) "0"
3) "unixsocket"
4) ""

The value of the unix socket is empty in this case (socket not configured) 4) "".

Monitor

redis-cli monitor

The redis-cli monitor command is a powerful debugging tool that shows all commands received by the Redis server in real-time.

Redis with Docker

Here is a template docker-compose.yml for using cypht with redis:

# this is a demo of using the production cypht image with redis

services:
  db:
    image: mariadb:10
    ports:
      - "3306:3306"
    volumes:
      - ./data/mysql:/var/lib/mysql
    environment:
      - MYSQL_ROOT_PASSWORD=root_password
      - MYSQL_DATABASE=cypht
      - MYSQL_USER=cypht
      - MYSQL_PASSWORD=cypht_password
    healthcheck:
      test: ["CMD", "mysqladmin", "ping", "-h", "localhost", "-ucypht", "-pcypht_password"]
      interval: 10s
      timeout: 5s
      retries: 5

  redis:
    image: redis:7-alpine
    ports:
      - "6379:6379"
    volumes:
      - ./data/redis:/data
    command: redis-server --appendonly yes --requirepass ${REDIS_PASS:-}
    healthcheck:
      test: ["CMD", "redis-cli", "ping"]
      interval: 10s
      timeout: 3s
      retries: 5
    restart: unless-stopped

  cypht:
    image: cypht/cypht:2.4.2
    depends_on:
      db:
        condition: service_healthy
      redis:
        condition: service_healthy
    ports:
      - "80:80"
    environment:
      - AUTH_USERNAME=admin
      - AUTH_PASSWORD=admin
      - DB_CONNECTION_TYPE=host
      - DB_DRIVER=mysql
      - DB_HOST=db
      - DB_NAME=cypht
      - DB_USER=cypht
      - DB_PASS=cypht_password
      - SESSION_TYPE=DB
      - USER_CONFIG_TYPE=DB
      # Redis Configuration
      - ENABLE_REDIS=true
      - REDIS_SERVER=redis
      - REDIS_PORT=6379
      - REDIS_INDEX=1
      - REDIS_PASS=${REDIS_PASSWORD:-}
      - REDIS_SOCKET=
    volumes:
      - ./data/log/nginx:/var/log/nginx
      - ./data/log/php:/var/log/php
      - ./data/log/supervisord:/var/log/supervisord
      - ./data/fonts:/usr/local/share/cypht/site/fonts
    restart: unless-stopped

Final Notes

We hope this guide has been helpful in configuring your Cypht instance with Redis server. Thank you for choosing Cypht as your webmail solution.

The Cypht project thrives on feedback and contributions from its community. If you encounter any errors or have suggestions for improving this documentation, please do not hesitate to open an issue on the official Cypht GitHub repository. Your input is invaluable in helping to improve the software for everyone.

>

Clone this wiki locally