Categories
Coding

How to Disable Persistence in Redis

To disable persistence in Redis you need to modify its configuration.

Find the Redis Configuration File

Found at /etc/redis/redis.conf or /usr/local/etc/redis.conf

Edit the Configuration File

Use a text editor like vim or nano with sudo.

sudo nano /etc/redis/redis.conf

Disable RDB Persistence

Find the line with save commands and comment them out or remove them.

Example:

# save 900 1
# save 300 10
# save 60 10000

Disable AOF Persistence

Find the appendonly directive and set it to no.

appendonly no

Save the file and exit the editor.

Restart Redis to Apply Changes

sudo systemctl restart redis

or

sudo service redis restart

Verify the Changes

Connect to Redis CLI:

redis-cli

Check persistence status:

CONFIG GET save
CONFIG GET appendonly

Disabling persistence means all data will be lost when Redis restarts. This configuration is only good for caching scenarios where data loss is acceptable.

Leave a Reply

Your email address will not be published. Required fields are marked *