# Example Redis Configuration File # This file provides a starting point for configuring Redis for use with the API Cache Manager plugin. # Adjust these settings to match your specific Redis deployment and performance requirements. # --- Basic Configuration --- # Bind to all interfaces or specify an IP address (e.g., 127.0.0.1) for local access only. # bind 127.0.0.1 -::1 bind 0.0.0.0 # Listen on the default Redis port. Change if necessary. port 6379 # TCP keepalive. # # If non-zero, use SO_KEEPALIVE to send TCP ACKs to clients in absence # of communication. This is useful for two reasons: # # 1) Detect dead peers. # 2) Take advantage of the TCP keepalive period to half close idle # connections if the server wants to reduce resources usage. # # On Linux, the default keepalive settings are to send probes every # 75 seconds, with 9 failed probes before declaring the client dead. # This means that a broken connection is only discovered after 11 minutes # (75*9). # # To make connection alive detection more aggressive on Linux, it is # recommended to set the following TCP keepalive settings: # # tcp-keepalive 60 tcp-keepalive 300 # --- Memory Management --- # Set the maximum memory Redis will use. Adjust this based on your available RAM. # A good starting point is to allocate around half of your system's RAM to Redis. # Ensure you have enough memory for both Redis and your application. maxmemory 2gb # Eviction policy: how Redis will evict keys when it reaches maxmemory. # Common policies: # - volatile-lru: Evict keys with an expire set using an LRU algorithm. # - allkeys-lru: Evict any key using an LRU algorithm. # - volatile-ttl: Evict keys with an expire set, with the shortest remaining TTL. # - noeviction: Don't evict. Return an error when memory is full. maxmemory-policy allkeys-lru # --- Persistence --- # Redis offers different persistence options: # - RDB (Snapshotting): Saves the dataset to disk periodically. Good for backups. # - AOF (Append Only File): Logs every write operation. Provides better durability. # - Disable Persistence: Redis will only exist in memory. Data is lost on shutdown. # RDB Snapshotting configuration save 900 1 # Save the DB if 1 key changed in 900 seconds save 300 10 # Save the DB if 10 keys changed in 300 seconds save 60 10000 # Save the DB if 10000 keys changed in 60 seconds # AOF configuration (more durable, but can be slower) # appendonly yes # appendfsync everysec # Recommended for most use cases # appendfsync always # Slowest, but safest # appendfsync no # Fastest, but least safe (OS decides when to flush) # --- Security --- # Require a password for accessing Redis. Strongly recommended for production. # Replace 'YOUR_REDIS_PASSWORD' with a strong, unique password. # requirepass YOUR_REDIS_PASSWORD # Rename potentially dangerous commands. This is an optional security measure. # rename-command FLUSHALL "" # rename-command FLUSHDB "" # rename-command CONFIG "" # --- Advanced Configuration --- # Number of databases. The default is 16. # databases 16 # The idle time after which a client connection will be closed. # If set to 0, the connection will never be closed. # timeout 300 # --- Cluster Configuration (if applicable) --- # If you are using Redis Cluster, configure the following: # cluster-enabled yes # cluster-config-file nodes.conf # cluster-node-timeout 15000 # --- Logging --- # Specify the log file. Leave commented to log to stdout. # logfile /var/log/redis/redis-server.log # --- Important Notes --- # - Regularly review and adjust these settings based on your application's needs and performance monitoring. # - Monitor Redis memory usage and adjust 'maxmemory' accordingly. # - Consider using Redis Sentinel or Redis Cluster for high availability. # - Secure your Redis instance properly, especially if it's exposed to the internet.