redis持久化问题
ringa_lee
ringa_lee 2017-04-25 09:02:36
0
2
824

如果用redis存储的数据都是有时间的,那么时间过期以后,

  1. redis是否会自动清除过期的key

  2. 如果不自动清除,那么岂不是持久化出来的文件会越来越大。

  3. 如果是手动清除,怎么清除。

  4. 我发现我重启一下redis可以减小存储的文件,是不是说重启可以清除过期的key。

用的是redis的RDB,如果使用AOF的话,是不是解决方案也是一样的。

ringa_lee
ringa_lee

ringa_lee

reply all(2)
巴扎黑

Introducing an article I wrote a long time ago to discuss the expired key deletion mechanism of redis

Then back to your question:

  1. Redis will automatically clear expired keys through lazy deletion and regular deletion.

  2. 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

  3. If you want to clear it manually, you can delete it through del or other methods.

  4. 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.

PHPzhong

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.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!