0
0
Redisquery~5 mins

Redis configuration file

Choose your learning style9 modes available
Introduction

A Redis configuration file sets up how Redis works on your computer or server. It tells Redis what to do and how to behave.

When you want to change the default settings of Redis to fit your needs.
When you need to set a password to protect your Redis server.
When you want to adjust memory limits to avoid using too much RAM.
When you want to enable or disable features like persistence (saving data to disk).
When you want to configure network settings like which port Redis listens on.
Syntax
Redis
# Lines starting with # are comments
setting_name setting_value

# Example:
port 6379
requirepass yourpassword
maxmemory 256mb
Each line sets one configuration option with its value.
Lines starting with # are comments and ignored by Redis.
Examples
Sets the port Redis listens on to 6379 (default port).
Redis
port 6379
Requires clients to provide this password to connect.
Redis
requirepass mysecretpassword
Limits Redis to use at most 100 megabytes of RAM.
Redis
maxmemory 100mb
Configures Redis to save data to disk if at least 1 change in 900 seconds, or 10 changes in 300 seconds, or 10000 changes in 60 seconds.
Redis
save 900 1
save 300 10
save 60 10000
Sample Program

This example changes the port to 6380, sets a password, limits memory to 128MB, and configures saving data to disk at certain intervals.

Redis
# Redis configuration example
port 6380
requirepass examplepass
maxmemory 128mb
save 900 1
save 300 10
save 60 10000
OutputSuccess
Important Notes

After changing the configuration file, you must restart Redis for changes to take effect.

Keep your password safe and do not share it publicly.

Use comments (#) to explain your settings for future reference.

Summary

The Redis configuration file controls how Redis runs.

It uses simple lines with setting names and values.

Changing this file customizes Redis behavior like security, memory, and saving data.