search

Home  >  Q&A  >  body text

redis中的数据过期后是如何处理的呢?

redis可以设置数据过期时间,如果一个数据过期是如何处理的呢?是有一个计时器实时删除吗?这样太低效了。是下次使用的时候再判断吗?这样随着数据的增多,会不会判断时间越来越长?

黄舟黄舟2798 days ago666

reply all(3)I'll reply

  • 黄舟

    黄舟2017-04-21 11:20:35

    In this regard, you can search for Redis expiration strategy. There are many related articles. I only understand and use Redis and have not studied the principles in depth.

    reply
    0
  • 怪我咯

    怪我咯2017-04-21 11:20:35

    This article has instructions: http://www.cppblog.com/richbirdandy/archive/2011/11/29/161184.html

    The above three ways to delete expired keys. The second way is to regularly delete a certain proportion of keys. The first way is "delete while reading" to ensure that expired keys will not be accessed. The third way is to delete expired keys when the memory is exceeded. Violent means during setting. From this we can also see the ingenuity of redis design,

    reply
    0
  • 黄舟

    黄舟2017-04-21 11:20:35

    Lazy deletion and regular deletion, please see "Redis Design and Implementation" for detailed explanation

    reply
    0
  • Cancelreply