Introducing an article I wrote a long time ago to discuss the expired key deletion mechanism of redis
Then back to your question:
Redis will automatically clear expired keys through lazy deletion and regular deletion.
This is inevitable. All redis have a regular deletion mechanism to help you check the redis database every once in a while and delete the expired keys in it
If you want to clear it manually, you can delete it through del or other methods.
Because redis data is stored in memory (although there is persistence, the purpose of persistence is only backup), so after you restart, the data in the memory will be gone, and the file will naturally be smaller.
RDB and AOF have nothing to do with the deletion mechanism, they are just persistence methods.
You can set the expiration time when creating the key value. You can also use commands to delete the specified key. You can also delete the data in the redis storage memory by restarting.
Introducing an article I wrote a long time ago to discuss the expired key deletion mechanism of redis
Then back to your question:
Redis will automatically clear expired keys through lazy deletion and regular deletion.
This is inevitable. All redis have a regular deletion mechanism to help you check the redis database every once in a while and delete the expired keys in it
If you want to clear it manually, you can delete it through del or other methods.
Because redis data is stored in memory (although there is persistence, the purpose of persistence is only backup), so after you restart, the data in the memory will be gone, and the file will naturally be smaller.
RDB and AOF have nothing to do with the deletion mechanism, they are just persistence methods.
You can set the expiration time when creating the key value. You can also use commands to delete the specified key. You can also delete the data in the redis storage memory by restarting.