The delete key redis

redis set an expiration time
  Redis has a function of setting time expires, i.e., the values ​​stored in the database may redis set an expiration time. As a cache database, which is very useful. As we generally project or some token login information, especially SMS verification code is time-limited, according to the traditional database approach, usually their own judgment expired, so no doubt will seriously affect project performance.
When we set key, you can give a expire time, time is expired, we can specify the key by the expiration time
It can survive time.
  If you set a number of key assumptions can only survive one hour, then the next after 1 hour, redis is how to carry out these key delete
In addition to the? + Inert periodically delete delete.
 
 Delete Policy
   regularly delete: redis default is every 100ms on a random sample of some of the key set expiration time, check if it has expired, expired delete. Note that this is randomly selected.
   inert Delete: Delete a regular basis may lead to a lot of back key time has not been removed. So there will be inert deleted. If your expired key, not deleted on a regular basis is deleted, still remain in memory, unless your system to check the key, only to be redis deleted. This is the so-called inert deleted!
   Problems and Solutions
    But only by setting an expiration time still a problem. We think about it: If you delete regularly missed a lot of back key, then you have no time to investigate, also did not go inert delete, then what will happen? If the accumulation of a large number of expired key in memory, resulting in a block of memory redis exhausted. How to solve this problem? ------- strategy out of memory

Guess you like

Origin www.cnblogs.com/crazy-lc/p/11945826.html