Last active
June 29, 2024 07:58
-
-
Save joychetry/de8c4d21ddac0b8bb00d3baa7fb56d10 to your computer and use it in GitHub Desktop.
Update maxmemory and maxmemory-policy in Redis Server
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
No need of changing any thing in the .conf file just follow the following steps | |
Step 1: First check whether redis-server is working or not | |
$ redis-cli | |
127.0.0.1:6379> ping | |
PONG | |
if the reply is PONG then your server is working absolutely fine. | |
Step 2: To get the current max memory run the following commands: | |
$ redis-cli | |
127.0.0.1:6379> config get maxmemory | |
1) "maxmemory" | |
2) "0" | |
Initially it is set to 0 by default. | |
Step 3: After running the above step run the following commands to set the maxmemory: | |
127.0.0.1:6379> config set maxmemory 128M | |
OK | |
To check whether the maxmemory is set to 128M run step 2 again. | |
Step 4: Set maxmemory-policy | |
127.0.0.1:6379> config set maxmemory-policy allkeys-lru | |
Step 6: After changing the maxmemory and maxmemory-policy exit Redis CLI | |
127.0.0.1:6379> exit | |
Step 6: Restart the redis-server | |
$ sudo systemctl restart redis | |
OR | |
$ sudo systemctl restart redis-server |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment